cd93b9fe5e23dc34475108610b9abdec7fa936a7
1 // Router for contact form sending
3 let router
= require("express").Router();
4 const mailer
= require(__dirname
.replace("/routes", "/utils/mailer"));
5 const params
= require(__dirname
.replace("/routes", "/config/parameters"));
7 // Send a message through contact form
8 router
.post("/messages", (req
,res
,next
) => {
10 return res
.json({errmsg: "Unauthorized access"});
11 const from = req
.body
["email"];
12 const subject
= req
.body
["subject"];
13 const body
= req
.body
["content"];
16 mailer(from, params
.mail
.contact
, subject
, body
, err
=> {
18 return res
.json({errmsg:err
});
19 // OK, everything fine
20 res
.json({}); //ignored
24 module
.exports
= router
;