Skip to content

Instantly share code, notes, and snippets.

@hmpmarketing
Last active January 10, 2018 12:32
Show Gist options
  • Select an option

  • Save hmpmarketing/bee9a4ecfdf6cb6dd8dd88ddb0296aca to your computer and use it in GitHub Desktop.

Select an option

Save hmpmarketing/bee9a4ecfdf6cb6dd8dd88ddb0296aca to your computer and use it in GitHub Desktop.
var maxmind = require('maxmind');
const Promise = require('bluebird');
const geoip = {};
Promise.promisifyAll(maxmind);
geoip.userGeoInfo = function () {
//Async db calls
return Promise.all([
maxmind.openAsync('./maxmind/GeoIP2-City.mmdb'),
maxmind.openAsync('./maxmind/GeoIP2-ISP.mmdb'),
]).then(function([cityLookup, ispLookup]) {
const city = cityLookup.get('66.6.44.4');
const isp = ispLookup.get('66.6.44.4');
const o = {};
//console.log(city.city.geoname_id)
o.geoname_id=city.city.geoname_id;
o.isp=isp.isp;
//How to return o?;
});
}
module.exports=geoip
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment