Implementar modulo de Auth
This commit is contained in:
36
backend/src/modules/auth/auth.controller.ts
Normal file
36
backend/src/modules/auth/auth.controller.ts
Normal file
@ -0,0 +1,36 @@
|
||||
import { Request, Response } from "express";
|
||||
|
||||
import { AuthService } from "./auth.service";
|
||||
|
||||
const authService = new AuthService();
|
||||
|
||||
export class AuthController {
|
||||
|
||||
async login (
|
||||
req:Request,
|
||||
res:Response
|
||||
){
|
||||
try {
|
||||
|
||||
const {
|
||||
userName,
|
||||
password
|
||||
} = req.body;
|
||||
|
||||
const result =
|
||||
await authService.login(
|
||||
userName,
|
||||
password
|
||||
);
|
||||
|
||||
res.json(result);
|
||||
|
||||
} catch(error:any){
|
||||
|
||||
res.status(401).json({
|
||||
message:error.message
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user