diff --git a/.github/.gitkeep b/.github/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/src/apps/mod.rs b/src/apps/mod.rs index 52a0195..296eac7 100644 --- a/src/apps/mod.rs +++ b/src/apps/mod.rs @@ -1,10 +1,15 @@ use axum::{routing::get, Router}; +use v1::auth_router; pub mod v1; pub mod v2; pub async fn apps() -> Router { - let v1_routes = Router::new().route("/", get(|| async { "Comming Soon v1" })); - let v2_routes = Router::new().route("/", get(|| async { "Comming Soon v2" })); - Router::new().nest("/v1", v1_routes).nest("/v2", v2_routes) + let v1_routes = Router::new() + .nest("/auth", auth_router()) + .route("/", get(|| async { "Comming Soon v1" })); + + let v2_routes = Router::new().route("/", get(|| async { "Comming Soon v2" })); + + Router::new().nest("/v1", v1_routes).nest("/v2", v2_routes) } diff --git a/src/apps/v1/auth/auth_controller.rs b/src/apps/v1/auth/auth_controller.rs index e69de29..9a67d31 100644 --- a/src/apps/v1/auth/auth_controller.rs +++ b/src/apps/v1/auth/auth_controller.rs @@ -0,0 +1,6 @@ +use super::{mutation_login, AuthLoginRequestDto}; +use axum::{response::Response, Json}; + +pub async fn post_login(Json(payload): Json) -> Response { + mutation_login(payload).await +} diff --git a/src/apps/v1/auth/auth_dto.rs b/src/apps/v1/auth/auth_dto.rs index e69de29..81fbe56 100644 --- a/src/apps/v1/auth/auth_dto.rs +++ b/src/apps/v1/auth/auth_dto.rs @@ -0,0 +1,8 @@ +use serde::{Deserialize, Serialize}; +use utoipa::ToSchema; + +#[derive(Clone, Debug, Serialize, Deserialize, ToSchema)] +pub struct AuthLoginRequestDto { + pub email: String, + pub password: String, +} diff --git a/src/apps/v1/auth/auth_repository.rs b/src/apps/v1/auth/auth_repository.rs index e69de29..5b9a81c 100644 --- a/src/apps/v1/auth/auth_repository.rs +++ b/src/apps/v1/auth/auth_repository.rs @@ -0,0 +1,13 @@ +use super::auth_dto::AuthLoginRequestDto; +use crate::{success_response, ResponseSuccessDto}; +use axum::response::Response; + +pub async fn mutation_login(params: AuthLoginRequestDto) -> Response { + let response = ResponseSuccessDto { + data: AuthLoginRequestDto { + email: params.email, + password: params.password, + }, + }; + success_response(response) +} diff --git a/src/apps/v1/auth/mod.rs b/src/apps/v1/auth/mod.rs index 5566bc1..ab67c67 100644 --- a/src/apps/v1/auth/mod.rs +++ b/src/apps/v1/auth/mod.rs @@ -1,4 +1,13 @@ +use axum::{routing::post, Router}; + pub mod auth_controller; pub mod auth_dto; pub mod auth_middleware; pub mod auth_repository; + +pub use auth_dto::*; +pub use auth_repository::*; + +pub fn auth_router() -> Router { + Router::new().route("/login", post(auth_controller::post_login)) +}