ncc-prototype-email-alerts-sub
Version:
Northumberland Council Front End Email Alerts Subscription Prototype
31 lines (26 loc) • 1.08 kB
text/typescript
import { NextFunction, Request, Response } from "express";
import { postController } from "../../types/controller";
import * as notifyClient from "../../node_modules/@nccdigitaldev/ncc-notify-client";
import logger from "../../libs/logger";
export const emailsubscriptionController: postController = async (req: Request, res: Response, next: NextFunction) => {
try {
console.log('email sub controller');
//notify cliet to send email
notifyClient.createClient("scaffoldtestnotifyapi-351388ca-23a3-4742-aacb-dd7a744940b4-5624fb0e-4cba-499d-8ecc-04d31003d2ba", logger)
const response = await notifyClient.sendEmailNotification(
"027170b8-a0dd-4390-bd6a-caea6b92e947",
"ankur.bhide@opencastsoftware.com",
{
personalisation: {},
reference: "refproto",
},
"reference"
);
if(response != null) {
next();
}
//call axios POST
} catch (error) {
console.error(JSON.stringify(error));
}
}