added mailer

This commit is contained in:
2026-01-27 20:37:50 +01:00
parent a551bf6f6f
commit 62468fe67b
2 changed files with 42 additions and 1 deletions

View File

@@ -1,9 +1,26 @@
import express from "express";
const router = express.Router();
import sendMail from "./mailer.js";
router.get("/", (req, res) => {
res.json({ message: "API is working!" }).status(200);
});
router.post("/new-message", (req, res) => {
const message = req.body.message;
const title = req.body.title;
const recipient = req.body.recipient;
sendMail(message, title, recipient)
.then(() => {
res.json({ status: "Message sent successfully" }).status(200);
})
.catch((error) => {
res
.json({ status: "Error sending message", error: error.message })
.status(500);
});
});
export default router;