Skip to content
Snippets Groups Projects

Issue #23/CREATE-contact-email

Merged jsk22 requested to merge issue/53-CREATE-contact-email into develop
4 files
+ 102
1
Compare changes
  • Side-by-side
  • Inline
Files
4
+ 26
0
import { ContactService } from "@/services/contact.service";
import { zValidator } from "@hono/zod-validator";
import { Hono } from "hono";
import Container from "typedi";
import { z } from "zod";
const contactService = Container.get(ContactService)
export const contactRoute = new Hono()
.post('/contact',
zValidator('json', z.object({
name: z.string().min(1, 'Name is required'),
email: z.string().email(),
message: z.string().min(10, 'Message should be at least 10 characters long'),
}))
, async (c) => {
try {
const { name, email, message } = await c.req.json();
await contactService.sendContactEmail(email, message, name)
return c.json({ status: 'success', name, email, message });
} catch (error) {
console.error('Error sending contact email:', error);
return c.json({ error: 'Invalid request data' }, 400);
}
});
\ No newline at end of file
Loading