@incdevco/framework
Version:
node.js lambda framework
53 lines (29 loc) • 895 B
JavaScript
var AWS = require('aws-sdk');
function SES(config) {
'use strict';
config = config || {};
this.console = config.console || console;
this.ses = config.ses || new AWS.SES();
this.debug = config.debug || false;
}
SES.prototype.sendEmail = function (params) {
'use strict';
var self = this;
this.log('ses.sendEmail', JSON.stringify(params, null, 2));
return this.ses.sendEmail(params).promise()
.then(function (result) {
self.log('result', JSON.stringify(result, null, 2));
return result;
}, function (exception) {
self.log('exception', exception.message, JSON.stringify(exception.stack, null, 2));
throw exception;
});
};
SES.prototype.log = function () {
'use strict';
if (this.debug) {
this.console.log.apply(this.console, arguments);
}
return true;
};
module.exports = SES;