Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ utoipa = { version = "5", features = ["rocket_extras"] }
utoipa-swagger-ui = { version = "9", features = ["rocket"] }
tokio = { version = "1", features = ["full"] }
alloy = { version = "=1.0.12", default-features = false, features = ["std", "serde"] }
async-trait = "0.1"
tracing = "0.1"
tracing-subscriber = { version = "0.3", features = ["env-filter", "json"] }
tracing-appender = "0.2"
Expand All @@ -28,7 +29,6 @@ rain_orderbook_js_api = { path = "lib/rain.orderbook/crates/js_api", default-fea
rain_orderbook_common = { path = "lib/rain.orderbook/crates/common", default-features = false }
rain_orderbook_bindings = { path = "lib/rain.orderbook/crates/bindings", default-features = false }
rain-math-float = { path = "lib/rain.orderbook/lib/rain.interpreter/lib/rain.interpreter.interface/lib/rain.math.float/crates/float" }
async-trait = "0.1"
wasm-bindgen = "=0.2.100"

[dev-dependencies]
Expand Down
162 changes: 0 additions & 162 deletions src/routes/order.rs

This file was deleted.

43 changes: 43 additions & 0 deletions src/routes/order/cancel.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
use crate::auth::AuthenticatedKey;
use crate::error::{ApiError, ApiErrorResponse};
use crate::fairings::{GlobalRateLimit, TracingSpan};
use crate::types::order::{CancelOrderRequest, CancelOrderResponse};
use rocket::serde::json::Json;
use rocket::State;
use tracing::Instrument;

#[utoipa::path(
post,
path = "/v1/order/cancel",
tag = "Order",
security(("basicAuth" = [])),
request_body = CancelOrderRequest,
responses(
(status = 200, description = "Cancel order result", body = CancelOrderResponse),
(status = 400, description = "Bad request", body = ApiErrorResponse),
(status = 401, description = "Unauthorized", body = ApiErrorResponse),
(status = 429, description = "Rate limited", body = ApiErrorResponse),
(status = 404, description = "Order not found", body = ApiErrorResponse),
(status = 500, description = "Internal server error", body = ApiErrorResponse),
)
)]
#[post("/cancel", data = "<request>")]
pub async fn post_order_cancel(
_global: GlobalRateLimit,
_key: AuthenticatedKey,
shared_raindex: &State<crate::raindex::SharedRaindexProvider>,
span: TracingSpan,
request: Json<CancelOrderRequest>,
) -> Result<Json<CancelOrderResponse>, ApiError> {
let req = request.into_inner();
async move {
tracing::info!(body = ?req, "request received");
let raindex = shared_raindex.read().await;
raindex
.run_with_client(move |_client| async move { todo!() })
.await
.map_err(ApiError::from)?
}
.instrument(span.0)
.await
}
42 changes: 42 additions & 0 deletions src/routes/order/deploy_dca.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
use crate::auth::AuthenticatedKey;
use crate::error::{ApiError, ApiErrorResponse};
use crate::fairings::{GlobalRateLimit, TracingSpan};
use crate::types::order::{DeployDcaOrderRequest, DeployOrderResponse};
use rocket::serde::json::Json;
use rocket::State;
use tracing::Instrument;

#[utoipa::path(
post,
path = "/v1/order/dca",
tag = "Order",
security(("basicAuth" = [])),
request_body = DeployDcaOrderRequest,
responses(
(status = 200, description = "DCA order deployment result", body = DeployOrderResponse),
(status = 400, description = "Bad request", body = ApiErrorResponse),
(status = 401, description = "Unauthorized", body = ApiErrorResponse),
(status = 429, description = "Rate limited", body = ApiErrorResponse),
(status = 500, description = "Internal server error", body = ApiErrorResponse),
)
)]
#[post("/dca", data = "<request>")]
pub async fn post_order_dca(
_global: GlobalRateLimit,
_key: AuthenticatedKey,
shared_raindex: &State<crate::raindex::SharedRaindexProvider>,
span: TracingSpan,
request: Json<DeployDcaOrderRequest>,
) -> Result<Json<DeployOrderResponse>, ApiError> {
let req = request.into_inner();
async move {
tracing::info!(body = ?req, "request received");
let raindex = shared_raindex.read().await;
raindex
.run_with_client(move |_client| async move { todo!() })
.await
.map_err(ApiError::from)?
}
.instrument(span.0)
.await
}
42 changes: 42 additions & 0 deletions src/routes/order/deploy_solver.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
use crate::auth::AuthenticatedKey;
use crate::error::{ApiError, ApiErrorResponse};
use crate::fairings::{GlobalRateLimit, TracingSpan};
use crate::types::order::{DeployOrderResponse, DeploySolverOrderRequest};
use rocket::serde::json::Json;
use rocket::State;
use tracing::Instrument;

#[utoipa::path(
post,
path = "/v1/order/solver",
tag = "Order",
security(("basicAuth" = [])),
request_body = DeploySolverOrderRequest,
responses(
(status = 200, description = "Solver order deployment result", body = DeployOrderResponse),
(status = 400, description = "Bad request", body = ApiErrorResponse),
(status = 401, description = "Unauthorized", body = ApiErrorResponse),
(status = 429, description = "Rate limited", body = ApiErrorResponse),
(status = 500, description = "Internal server error", body = ApiErrorResponse),
)
)]
#[post("/solver", data = "<request>")]
pub async fn post_order_solver(
_global: GlobalRateLimit,
_key: AuthenticatedKey,
shared_raindex: &State<crate::raindex::SharedRaindexProvider>,
span: TracingSpan,
request: Json<DeploySolverOrderRequest>,
) -> Result<Json<DeployOrderResponse>, ApiError> {
let req = request.into_inner();
async move {
tracing::info!(body = ?req, "request received");
let raindex = shared_raindex.read().await;
raindex
.run_with_client(move |_client| async move { todo!() })
.await
.map_err(ApiError::from)?
}
.instrument(span.0)
.await
}
Loading