Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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
Add Comment
Please, Sign In to add comment