generated from fahricansecer/boilerplate-be
This commit is contained in:
50
src/modules/mail/mail.controller.ts
Normal file
50
src/modules/mail/mail.controller.ts
Normal file
@@ -0,0 +1,50 @@
|
||||
import { Controller, Post, Body, Get } from '@nestjs/common';
|
||||
import { ApiTags, ApiOperation } from '@nestjs/swagger';
|
||||
import { MailService, ContactMailData } from './mail.service';
|
||||
import { Public } from '../../common/decorators';
|
||||
import { IsEmail, IsNotEmpty, IsString } from 'class-validator';
|
||||
|
||||
class SendContactDto {
|
||||
@IsNotEmpty()
|
||||
@IsString()
|
||||
name: string;
|
||||
|
||||
@IsEmail()
|
||||
email: string;
|
||||
|
||||
@IsNotEmpty()
|
||||
@IsString()
|
||||
type: string;
|
||||
|
||||
@IsNotEmpty()
|
||||
@IsString()
|
||||
details: string;
|
||||
|
||||
@IsNotEmpty()
|
||||
@IsString()
|
||||
captchaId: string;
|
||||
|
||||
@IsNotEmpty()
|
||||
@IsString()
|
||||
captchaAnswer: string;
|
||||
}
|
||||
|
||||
@ApiTags('Mail')
|
||||
@Controller('mail')
|
||||
export class MailController {
|
||||
constructor(private readonly mailService: MailService) { }
|
||||
|
||||
@Public()
|
||||
@Post('send')
|
||||
@ApiOperation({ summary: 'Send contact form message' })
|
||||
async sendContact(@Body() dto: SendContactDto) {
|
||||
return this.mailService.sendContactMail(dto);
|
||||
}
|
||||
|
||||
@Public()
|
||||
@Get('captcha')
|
||||
@ApiOperation({ summary: 'Get a new math captcha' })
|
||||
async getCaptcha() {
|
||||
return this.mailService.generateCaptcha();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user