Add roadmap on TODO file
[vchess.git] / routes / messages.js
1 let router = require("express").Router();
2 const sendEmail = require(__dirname.replace("/routes", "/utils/sendEmail"));
3
4 // Send a message through contact form
5 router.post("/messages", (req,res,next) => {
6 if (!req.xhr)
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"];
11 // TODO: sanitize ?
12 sendEmail(email, subject, content, err => {
13 if (!!err)
14 return res.json({errmsg:err});
15 // OK, everything fine
16 res.json({}); //ignored
17 });
18 });
19
20 module.exports = router;