forked from CIDWA/cedetec_api_nest
23 lines
724 B
TypeScript
23 lines
724 B
TypeScript
import { Controller, Post, Get, Body } from '@nestjs/common';
|
|
import { AlmacenamientoService } from './almacenamiento.service';
|
|
|
|
@Controller('almacenamiento')
|
|
export class AlmacenamientoController {
|
|
constructor(private readonly almacenamientoService: AlmacenamientoService) {}
|
|
|
|
@Post()
|
|
async create(@Body() body: { correo: string; agree: boolean }) {
|
|
if (!body.agree) {
|
|
return { message: 'User did not agree', data: body };
|
|
}
|
|
const saved = await this.almacenamientoService.create(body.correo);
|
|
return { message: 'Data saved', data: saved };
|
|
}
|
|
|
|
@Get()
|
|
async findAll() {
|
|
const data = await this.almacenamientoService.findAll();
|
|
return { message: 'GET endpoint reached', data };
|
|
}
|
|
}
|