Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

posteon

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

posteon - npm Package Compare versions

Comparing version 0.1.1 to 0.1.2

lib/render/old.js

21

lib/index.js

@@ -128,18 +128,11 @@ 'use strict';

//render body
self.render.render(options, function (err) {
if(err) {
//add to queue
self.queue.add(message, function (err, message) {
if (err) {
return callback(err);
}
//add to queue
self.queue.add(message, function (err, message) {
if (err) {
return callback(err);
}
callback(null, {
messageId: message._id,
status: 'queued',
createdAt: message.createdAt
});
callback(null, {
messageId: message._id,
status: 'queued',
createdAt: message.createdAt
});

@@ -146,0 +139,0 @@ });

var events = require('events');
var _ = require('lodash');

@@ -8,21 +9,108 @@ var eventsName = {

module.exports = function (mailer, options) {
if (!options) {
options = {};
function Dispatcher (mailer, options) {
this.mailer = mailer;
this.options = {};
this.eventEmitter = new events.EventEmitter();
if (options) {
this.init(options);
}
var eventEmitter = new events.EventEmitter();
return {
newMessage: function (message) {
//console.log(eventsName.newMessage + '_' + message.provider.name, message);
eventEmitter.emit(eventsName.newMessage + '_' + message.provider.name, message);
},
}
registerAdapter: function (providerName, adapter) {
if (options.sendWrapper) {
eventEmitter.on(eventsName.newMessage + '_' + providerName, options.sendWrapper(adapter));
} else {
eventEmitter.on(eventsName.newMessage + '_' + providerName, adapter.send);
}
},
};
/**
* Sets dispatcher options
*
* # Example:
*
* dispatcher.set('debug', true)
*
* @param {String} key
* @param {String|Function} value
* @api public
*/
Dispatcher.prototype.set = function(key, value) {
if (arguments.length == 1) {
return this.options[key];
}
this.options[key] = value;
return this;
};
/**
* Gets dispatcher options
*
* # Example:
*
* dispatcher.get('test') // returns the 'test' value
*
* @param {String} key
* @api public
*/
Dispatcher.prototype.get = Dispatcher.prototype.set;
/**
* Init Dispatcher
*
* # Example:
*
* dispatcher.init()
*
* dispatcher.init({..})
*
* @param {Object} options
* @method init
* @api public
*/
Dispatcher.prototype.init = function (options) {
this.options = _.merge(options, this.options);
};
/**
* Rigister an adapter
*
* # Example:
*
* dispatcher.registerAdapter('test', adapter)
*
* @param {String} providerName
* @param {Object} adapter
* @api public
*/
Dispatcher.prototype.registerAdapter = function (providerName, adapter) {
if (this.options.sendWrapper) {
this.eventEmitter.on(eventsName.newMessage + '_' + providerName, this.options.sendWrapper(adapter));
} else {
this.eventEmitter.on(eventsName.newMessage + '_' + providerName, adapter.send);
}
if(this.options.debug) {
console.log(new Date() + ' - Registered ' + providerName + 'adapter' + (this.mailer.options.sendWrapper ? 'with wrapper' : ''));
}
};
/**
* Trigger new message event to right adapter
*
* # Example:
*
* dispatcher.newMessage(message)
*
* @param {Object} message
* @api public
*/
Dispatcher.prototype.newMessage = function (message) {
if(this.options.debug) {
console.log(eventsName.newMessage + '_' + message.provider.name, message);
}
this.eventEmitter.emit(eventsName.newMessage + '_' + message.provider.name, message);
};
module.exports = function (mailer, options) {
return new Dispatcher(mailer, options);
};

@@ -251,4 +251,7 @@ 'use strict';

Queue.prototype.Model = require('./model');
module.exports = function (mailer) {
return new Queue(mailer);
};

@@ -5,3 +5,3 @@ module.exports = {

uri: 'mongodb://localhost/mailer-dev',
debug: true,
debug: false,
options: {},

@@ -8,0 +8,0 @@ },

@@ -9,3 +9,4 @@ var should = require('should');

describe('Send', function() {
this.timeout(10000);
this.timeout(5000);
it('send', function(done) {

@@ -12,0 +13,0 @@ var fakeProviderInstance = fakeProvider();

{
"name": "posteon",
"description": " ",
"version": "0.1.1",
"version": "0.1.2",
"keywords": [

@@ -33,3 +33,3 @@ "mailer",

},
"main": "./index.js",
"main": "./lib/index.js",
"scripts": {

@@ -36,0 +36,0 @@ "test": "mocha ./lib/**/*.test.js ./test/**/*.test.js"

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc