service-geoip
Advanced tools
Comparing version 1.3.3 to 1.3.4
@@ -1,2 +0,3 @@ | ||
var uuid = require('node-uuid'), | ||
var defaultConfig = require('../config.json'), | ||
uuid = require('node-uuid'), | ||
amqp = require('amqplib'), | ||
@@ -18,5 +19,14 @@ when = require('when'), | ||
function updateWithDefaultConfig(_config) { | ||
for (var key in defaultConfig) { | ||
if (defaultConfig.hasOwnProperty(key) && _config[key] === undefined) { | ||
_config[key] = defaultConfig[key]; | ||
} | ||
} | ||
} | ||
module.exports = function(_config) { | ||
var reqQueue = []; | ||
config = _config; | ||
updateWithDefaultConfig(config); | ||
@@ -68,4 +78,5 @@ function connect() { | ||
return answerQueue[corrId].promise; | ||
} | ||
}, | ||
config: config | ||
} | ||
}; |
{ | ||
"name": "service-geoip", | ||
"version": "1.3.3", | ||
"version": "1.3.4", | ||
"description": "A RabbitMQ microservice wrapping the node-geoip package (geoip-lite on npm).", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -7,2 +7,6 @@ var lib = require('../index'), | ||
describe('Module required', function() { | ||
beforeEach(function(){ | ||
lib = require('../index'); | ||
}); | ||
it('should not be undefined', function(){ | ||
@@ -16,3 +20,3 @@ expect(lib).not.toBe(undefined); | ||
it('should return an object when called', function() { | ||
it('should return an object when called (with config)', function() { | ||
lib = lib(config); | ||
@@ -23,5 +27,33 @@ expect(typeof lib).not.toBe(undefined); | ||
}); | ||
it('should return an object when called (without config)', function() { | ||
lib = lib(config); | ||
expect(typeof lib).not.toBe(undefined); | ||
expect(typeof lib).toBe('object'); | ||
expect(typeof lib.send).toBe('function'); | ||
}); | ||
it('should return an object when called (with partial config)', function() { | ||
lib = lib( {amqp: 'amqp://localhost'} ); | ||
expect(typeof lib).not.toBe(undefined); | ||
expect(typeof lib).toBe('object'); | ||
expect(typeof lib.send).toBe('function'); | ||
}); | ||
it('should fill config with missing properties', function() { | ||
lib = lib( {amqp: 'amqp://anotherIP'} ); | ||
expect(typeof lib).not.toBe(undefined); | ||
expect(typeof lib).toBe('object'); | ||
expect(typeof lib.send).toBe('function'); | ||
expect(lib.config.port).not.toBe(undefined); | ||
expect(lib.config.port).toBe(config.port); | ||
expect(lib.config.amqp).toBe('amqp://anotherIP'); | ||
}); | ||
}); | ||
describe('AMQP client', function(){ | ||
beforeAll(function(){ | ||
lib = require('../index')(config); | ||
}); | ||
it('should be able to send a message', function(done){ | ||
@@ -35,2 +67,6 @@ setTimeout(function(){ | ||
describe('Geoip service', function() { | ||
beforeAll(function(){ | ||
lib = require('../index')(config); | ||
}); | ||
it('should receive geo object when an IP is sent', function(done){ | ||
@@ -37,0 +73,0 @@ lib.send('89.89.219.244').then(function(obj){ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
28808
250
2