rokot-notification
Version:
Rokot - [Rocketmakers](http://www.rocketmakers.com/) TypeScript NodeJs Platform
33 lines (32 loc) • 1.19 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const plugin_1 = require("../plugin");
var sgTransport = require('nodemailer-sendgrid-transport');
class NodemailerSendgridTransporter extends plugin_1.NodemailerTransporterBase {
constructor(logger, nodemailerConfig) {
super();
this.logger = logger;
this.nodemailerConfig = nodemailerConfig;
}
validate() {
this.logger.trace(`Validating Nodemailer Sendgrid Transporter config`);
if (!this.nodemailerConfig || !this.nodemailerConfig.password) {
const msg = "Email credential cannot be null/undefined or contain empty username and/or password";
this.logger.error("-- " + msg);
throw new Error(msg);
}
this.logger.info("-- Passed");
}
createNodemailerTransport() {
const auth = {
api_key: this.nodemailerConfig.password
};
if (this.nodemailerConfig.username) {
auth.api_user = this.nodemailerConfig.username;
}
return sgTransport({
auth
});
}
}
exports.NodemailerSendgridTransporter = NodemailerSendgridTransporter;