wip
This commit is contained in:
2107
Cargo.lock
generated
Normal file
2107
Cargo.lock
generated
Normal file
File diff suppressed because it is too large
Load Diff
10
Cargo.toml
10
Cargo.toml
@@ -4,3 +4,13 @@ version = "0.1.0"
|
|||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
axum = "0.7"
|
||||||
|
tokio = { version = "1", features = ["full"] }
|
||||||
|
tower = "0.5"
|
||||||
|
utoipa = { version = "5.2.0", features = ["axum_extras"] }
|
||||||
|
utoipa-swagger-ui = { version = "8.0.3", features = ["axum"] }
|
||||||
|
utoipa-axum = "0.1.2"
|
||||||
|
serde = "1"
|
||||||
|
serde_json = "1"
|
||||||
|
anyhow = "1.0.92"
|
||||||
|
sqlx = "0.8.2"
|
||||||
|
|||||||
50
src/main.rs
50
src/main.rs
@@ -1,3 +1,49 @@
|
|||||||
fn main() {
|
use std::net::Ipv4Addr;
|
||||||
println!("Hello, world!");
|
use tokio::net::TcpListener;
|
||||||
|
use utoipa::OpenApi;
|
||||||
|
use utoipa_axum::{router::OpenApiRouter, routes};
|
||||||
|
use utoipa_swagger_ui::SwaggerUi;
|
||||||
|
|
||||||
|
mod v1;
|
||||||
|
|
||||||
|
#[derive(OpenApi)]
|
||||||
|
#[openapi(
|
||||||
|
tags(
|
||||||
|
// (name = CUSTOMER_TAG, description = "Customer API endpoints"),
|
||||||
|
// (name = ORDER_TAG, description = "Order API endpoints")
|
||||||
|
)
|
||||||
|
)]
|
||||||
|
struct ApiDoc;
|
||||||
|
|
||||||
|
/// Get health of the API.
|
||||||
|
#[utoipa::path(
|
||||||
|
method(get, head),
|
||||||
|
path = "/.well-known/health-check",
|
||||||
|
responses(
|
||||||
|
(status = OK, description = "Success", body = str, content_type = "text/plain")
|
||||||
|
)
|
||||||
|
)]
|
||||||
|
async fn health_check() -> &'static str {
|
||||||
|
"ok"
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tokio::main]
|
||||||
|
async fn main() -> anyhow::Result<()> {
|
||||||
|
let (router, api) = OpenApiRouter::with_openapi(ApiDoc::openapi())
|
||||||
|
.routes(routes!(health_check))
|
||||||
|
// .nest("/api/customer", customer::router())
|
||||||
|
// .nest("/api/order", order::router())
|
||||||
|
// .routes(routes!(
|
||||||
|
// inner::secret_handlers::get_secret,
|
||||||
|
// inner::secret_handlers::post_secret
|
||||||
|
// ))
|
||||||
|
.split_for_parts();
|
||||||
|
|
||||||
|
let router = router.merge(SwaggerUi::new("/swagger-ui").url("/apidoc/openapi.json", api));
|
||||||
|
|
||||||
|
println!("Listening on http://localhost:8080");
|
||||||
|
let listener = TcpListener::bind((Ipv4Addr::LOCALHOST, 8080)).await?;
|
||||||
|
axum::serve(listener, router).await?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
3
src/v1/auth/mod.rs
Normal file
3
src/v1/auth/mod.rs
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
pub(super) use super::*;
|
||||||
|
|
||||||
|
pub mod signup;
|
||||||
7
src/v1/auth/signup.rs
Normal file
7
src/v1/auth/signup.rs
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
use super::*;
|
||||||
|
|
||||||
|
// /// Get customer
|
||||||
|
// ///
|
||||||
|
// /// Just return a static Customer object
|
||||||
|
// #[utoipa::path(get, path = "", responses((status = OK, body = Customer)), tag = super::CUSTOMER_TAG)]
|
||||||
|
// pub async fn signup() -> Json<Customer> {}
|
||||||
7
src/v1/mod.rs
Normal file
7
src/v1/mod.rs
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
pub(super) use axum::Json;
|
||||||
|
pub(super) use serde::Serialize;
|
||||||
|
pub(super) use utoipa::ToSchema;
|
||||||
|
pub(super) use utoipa_axum::router::OpenApiRouter;
|
||||||
|
pub(super) use utoipa_axum::routes;
|
||||||
|
|
||||||
|
pub mod auth;
|
||||||
Reference in New Issue
Block a user