94 lines
2.6 KiB
TypeScript
94 lines
2.6 KiB
TypeScript
/*import { checkTabContext, checkUser } from "@/contexts/auth/infraestructure";
|
|
import {
|
|
buildLoginController,
|
|
buildLogoutController,
|
|
buildRefreshTokenController,
|
|
buildRegisterController,
|
|
} from "@/contexts/auth/presentation/controllers";
|
|
import {
|
|
LoginUserSchema,
|
|
RefreshTokenSchema,
|
|
RegisterUserSchema,
|
|
} from "@/contexts/auth/presentation/dto";
|
|
import { validateAndParseBody } from "@/core/common/presentation";
|
|
import { NextFunction, Request, Response, Router } from "express";
|
|
|
|
export const authRouter = (appRouter: Router) => {
|
|
const routes: Router = Router({ mergeParams: true });
|
|
*/
|
|
/**
|
|
* @api {post} /api/auth/register Register a new user
|
|
* @apiName RegisterUser
|
|
* @apiGroup Authentication
|
|
* @apiVersion 1.0.0
|
|
*
|
|
* @apiBody {String} username User's unique username.
|
|
* @apiBody {String} email User's email address.
|
|
* @apiBody {String} password User's password (minimum 8 characters).
|
|
*
|
|
* @apiSuccess (201) {String} userId The unique ID of the created user.
|
|
*
|
|
* @apiError (400) {String} message Error message.
|
|
*/
|
|
/* routes.post("/register", validateAndParseBody(RegisterUserSchema), (req, res, next) => {
|
|
buildRegisterController().execute(req, res, next);
|
|
}); */
|
|
|
|
/**
|
|
* @api {post} /api/auth/login Authenticate a user
|
|
* @apiName LoginUser
|
|
* @apiGroup Authentication
|
|
* @apiVersion 1.0.0
|
|
*
|
|
* @apiHeader {String} Tab ID (x-tab-id)
|
|
* @apiBody {String} email User's email address.
|
|
* @apiBody {String} password User's password.
|
|
*
|
|
* @apiSuccess (200) {String} token JWT authentication token.
|
|
* @apiSuccess (200) {String} userId The unique ID of the authenticated user.
|
|
*
|
|
* @apiError (401) {String} message Invalid email or password.
|
|
*/
|
|
/* routes.post(
|
|
"/login",
|
|
validateAndParseBody(LoginUserSchema),
|
|
checkTabContext,
|
|
(req: Request, res: Response, next: NextFunction) => {
|
|
buildLoginController().execute(req, res, next);
|
|
}
|
|
); */
|
|
|
|
/**
|
|
* @api {post} /api/auth/logout Logout user
|
|
* @apiName LogoutUser
|
|
* @apiGroup Authentication
|
|
* @apiVersion 1.0.0
|
|
*
|
|
* @apiHeader {String} Tab ID (x-tab-id)
|
|
* @apiHeader {String} Authorization Bearer token.
|
|
*
|
|
* @apiSuccess (200) {String} message Success message.
|
|
*/
|
|
/*
|
|
routes.post(
|
|
"/logout",
|
|
checkTabContext,
|
|
checkUser,
|
|
(req: Request, res: Response, next: NextFunction) => {
|
|
buildLogoutController().execute(req, res, next);
|
|
}
|
|
);
|
|
|
|
routes.post(
|
|
"/refresh",
|
|
validateAndParseBody(RefreshTokenSchema),
|
|
checkTabContext,
|
|
(req: Request, res: Response, next: NextFunction) => {
|
|
buildRefreshTokenController().execute(req, res, next);
|
|
}
|
|
);
|
|
|
|
appRouter.use("/auth", routes);
|
|
};
|
|
*/
|