Project 'web-et-numerique/llle_project/ecolyo' was moved to 'web-et-numerique/factory/llle_project/ecolyo'. Please update any links and bookmarks that may still have the old path.
Newer
Older
import { Controller, Post, Body, Res } from '@nestjs/common';
import { ContactForm } from './email';
import { EmailService } from './email.service';
import { ApiBadRequestResponse, ApiOkResponse } from '@nestjs/swagger';
@Controller('email')
export class EmailController {
constructor(
private emailService: EmailService,
) {}
@ApiOkResponse({ description: 'OK'})
@ApiBadRequestResponse({ description: 'Missing fields'})
create(@Body() contactForm: ContactForm, @Res() res) {
const created = this.emailService.send(contactForm);
if (created === true) {
res.status(200).send();
} else {
res.status(400).send({error: 'Couldn\'t send the email'});
}