Merge pull request #1 from IMPHNEN/feat/auth-login

feat: auth login
This commit is contained in:
Maulana Sodiqin
2025-02-08 01:09:57 +07:00
committed by GitHub
6 changed files with 44 additions and 3 deletions
View File
+6 -1
View File
@@ -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 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)
}
+6
View File
@@ -0,0 +1,6 @@
use super::{mutation_login, AuthLoginRequestDto};
use axum::{response::Response, Json};
pub async fn post_login(Json(payload): Json<AuthLoginRequestDto>) -> Response {
mutation_login(payload).await
}
+8
View File
@@ -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,
}
+13
View File
@@ -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)
}
+9
View File
@@ -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))
}