Files
pdi_api/src/auth/auth.controller.ts
T

30 lines
654 B
TypeScript
Raw Normal View History

2024-09-11 22:35:57 -06:00
import {
BadRequestException,
Body,
Controller,
2024-09-11 22:47:22 -06:00
Header,
2024-09-11 22:35:57 -06:00
HttpCode,
HttpStatus,
Logger,
Post,
} from '@nestjs/common';
import { AuthService } from './auth.service';
import { LoginDTO } from '../dtos/loginDTO';
2024-09-10 17:51:20 -06:00
@Controller('auth')
2024-09-11 22:35:57 -06:00
export class AuthController {
constructor(private readonly authService: AuthService) {}
@HttpCode(HttpStatus.OK)
@Post('login')
2024-09-11 22:47:22 -06:00
@Header('content-type', 'application/json')
2024-09-11 22:35:57 -06:00
login(@Body() loginDto: LoginDTO): Promise<any> {
Logger.log('/auth/loin/', 'requested');
if (loginDto) {
return this.authService.signIn(loginDto);
} else {
throw new BadRequestException();
}
}
}