Files
HarunCAN_Studio_BE/src/modules/mail/mail.controller.ts
Harun CAN e0d41d0386
Some checks failed
Backend Deploy 🚀 / build-and-deploy (push) Has been cancelled
main
2026-03-17 13:16:12 +03:00

51 lines
1.1 KiB
TypeScript

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();
}
}