import { Body, Param, Controller, Get, HttpCode, HttpStatus, Post, Put, Request, UseGuards, Delete } from '@nestjs/common'; import { AuthGuard } from './auth.guard'; import { AuthService } from './auth.service'; import { registerDto } from './Dto/registerDto.dto'; @Controller('auth') export class AuthController { constructor(private authService: AuthService) {} @HttpCode(HttpStatus.OK) @Post('login') signIn(@Body() data: registerDto) { return this.authService.signIn(data); } @UseGuards(AuthGuard) @Get('profile') getProfile(@Request() req) { return req.user; } @Post("register") postRegister(@Body() data: registerDto){ return this.authService.register(data) } @Post('Alta') async create(@Body() createUserDto: Record) { return this.authService.create(createUserDto.username,createUserDto.password); } @Put('Modificacion/:id') async update(@Param('id') id: number, @Body() updateUserDto: Record) { return this.authService.update(id, updateUserDto); } @Delete('Borrado/:id') async remove(@Param('id') id: number) { await this.authService.remove(id); return { message: 'User successfully deleted' }; } }