import { Body, Controller, Get, HttpCode, HttpStatus, Post, Request, } from '@nestjs/common'; import { AuthenticationService } from './authentication.service.js'; import { Public } from './authentication.decorator.js'; import { SignInDto } from './dto/sign-in.dto.js'; import { SignUpDto } from './dto/sign-up.dto.js'; import { Roles } from './authorization/roles.decorator.js'; import { Role } from '../../common/enums/role.enum.js'; @Controller('authentication') export class AuthenticationController { constructor(private AuthenticationService: AuthenticationService) {} @Public() @HttpCode(HttpStatus.OK) @Post('login') signIn(@Body() signInDto: SignInDto) { return this.AuthenticationService.signIn(signInDto.username, signInDto.password); } @Public() @HttpCode(HttpStatus.OK) @Post('signup') signUp(@Body() signUpDto: SignUpDto) { return this.AuthenticationService.signUp(signUpDto); } @Get('profile') getProfile(@Request() req) { const userId = req.user.sub; return this.AuthenticationService.getProfile(userId); } }