UNPKG

@incdevco/framework

Version:
53 lines (29 loc) 901 B
var AWS = require('aws-sdk'); function SNS(config) { 'use strict'; config = config || {}; this.console = config.console || console; this.sns = config.sns || new AWS.SNS(); this.debug = config.debug || false; } SNS.prototype.createTopic = function (params) { 'use strict'; var self = this; this.log('sns.createTopic', JSON.stringify(params, null, 2)); return this.sns.createTopic(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; }); }; SNS.prototype.log = function () { 'use strict'; if (this.debug) { this.console.log.apply(this.console, arguments); } return true; }; module.exports = SNS;