1 let router
= require("express").Router();
2 const sendEmail
= require(__dirname
.replace("/routes", "/utils/sendEmail"));
4 // Send a message through contact form
5 router
.post("/messages", (req
,res
,next
) => {
7 return res
.json({errmsg: "Unauthorized access"});
8 const email
= req
.body
["email"];
9 const subject
= req
.body
["subject"];
10 const content
= req
.body
["content"];
12 sendEmail(email
, subject
, content
, err
=> {
14 return res
.json({errmsg:err
});
15 // OK, everything fine
16 res
.json({}); //ignored
20 module
.exports
= router
;