41 lines
1.1 KiB
JavaScript
41 lines
1.1 KiB
JavaScript
/**
|
|
* @swagger
|
|
* /api/email/notify:
|
|
* get:
|
|
* tags:
|
|
* - Email
|
|
* description: Send email via gov notify
|
|
* responses:
|
|
* 200:
|
|
* description: Success
|
|
*/
|
|
|
|
import { consoleLogger } from "../../../actions";
|
|
|
|
export default async function ApiProxy(req, res) {
|
|
var data = req.body;
|
|
|
|
var NotifyClient = require("notifications-node-client").NotifyClient;
|
|
|
|
const notifyClient = new NotifyClient(process.env.NOTIFY_API_KEY);
|
|
//const emailReplyToId = process.env.EMAIL_REPLY_TO_ID;
|
|
|
|
console.log("///////////////\n Sending email \ns//////////////");
|
|
|
|
notifyClient
|
|
.sendEmail(data.templateId, data.emailAddress, {
|
|
personalisation: data.personalisation,
|
|
reference: data.reference,
|
|
// emailReplyToId: emailReplyToId,
|
|
})
|
|
.then((response) => {
|
|
//console.log("thisis the response", response);
|
|
return res.status(200).json(data);
|
|
})
|
|
.catch((err) => {
|
|
consoleLogger(err);
|
|
return res.status(400).json(err);
|
|
});
|
|
//return res.status(200).json(data);
|
|
}
|