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

service-geoip

Package Overview
Dependencies
Maintainers
2
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

service-geoip - npm Package Compare versions

Comparing version 1.3.3 to 1.3.4

15

lib/geoip-client.js

@@ -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
}
};

2

package.json
{
"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){

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