48 lines
1.1 KiB
TypeScript
48 lines
1.1 KiB
TypeScript
import {
|
|
Controller,
|
|
Get,
|
|
Param,
|
|
Post,
|
|
Body,
|
|
UsePipes,
|
|
ValidationPipe,
|
|
Patch,
|
|
} from '@nestjs/common';
|
|
import { UsuariosService } from './usuarios.service';
|
|
import { UsuariosResponseDto } from './dto/usuarios.response';
|
|
import { CreateUsuarioDto } from './dto/create-usuario-dto';
|
|
|
|
@Controller('usuarios')
|
|
export class UsuariosController {
|
|
constructor(private readonly usuariosService: UsuariosService) {}
|
|
|
|
@Get()
|
|
async list(): Promise<UsuariosResponseDto[]> {
|
|
return this.usuariosService.list();
|
|
}
|
|
|
|
@Get(':uuid')
|
|
async get(@Param('uuid') uuid: string): Promise<UsuariosResponseDto> {
|
|
return this.usuariosService.get(uuid);
|
|
}
|
|
|
|
@Post()
|
|
@UsePipes(
|
|
new ValidationPipe({
|
|
whitelist: true,
|
|
forbidNonWhitelisted: true,
|
|
transform: true,
|
|
}),
|
|
)
|
|
async create(@Body() body: CreateUsuarioDto): Promise<UsuariosResponseDto> {
|
|
return this.usuariosService.create(body);
|
|
}
|
|
|
|
@Patch(':uuid/email-verificado')
|
|
async emailVerificado(
|
|
@Param('uuid') uuid: string,
|
|
): Promise<UsuariosResponseDto> {
|
|
return this.usuariosService.emailVerificado(uuid);
|
|
}
|
|
}
|