31 lines
1016 B
TypeScript
31 lines
1016 B
TypeScript
|
|
import { Body, Controller, Get, Post, UseGuards } from '@nestjs/common';
|
||
|
|
import { AuthGuard } from '@nestjs/passport';
|
||
|
|
import { ApiBearerAuth, ApiOperation, ApiTags } from '@nestjs/swagger';
|
||
|
|
import { Serealize } from '../interceptors/serialize.interceptor';
|
||
|
|
import { ModeloService } from './modelo.service';
|
||
|
|
import { ModeloOutputDto } from './dto/output/modelo.dto';
|
||
|
|
import { CreateModeloDto } from './dto/input/create.dto';
|
||
|
|
|
||
|
|
@Controller('modelo')
|
||
|
|
@ApiTags('modelo')
|
||
|
|
export class ModeloController {
|
||
|
|
constructor(private modeloService: ModeloService) {}
|
||
|
|
|
||
|
|
@Serealize(ModeloOutputDto)
|
||
|
|
@Get()
|
||
|
|
@UseGuards(AuthGuard('jwt'))
|
||
|
|
@ApiOperation({ description: 'Endpoint que retorna todos los modelos.' })
|
||
|
|
@ApiBearerAuth('jwt')
|
||
|
|
get() {
|
||
|
|
return this.modeloService.findAll();
|
||
|
|
}
|
||
|
|
|
||
|
|
@Post()
|
||
|
|
@UseGuards(AuthGuard('jwt'))
|
||
|
|
@ApiOperation({ description: 'Endpoint que crea un nuevo modelo.' })
|
||
|
|
@ApiBearerAuth('jwt')
|
||
|
|
create(@Body() body: CreateModeloDto) {
|
||
|
|
return this.modeloService.create(body.modelo);
|
||
|
|
}
|
||
|
|
}
|