Guest User

Untitled

a guest
Jan 19th, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. var maxmind = require('maxmind');
  2. const Promise = require('bluebird');
  3.  
  4. const geoip = {};
  5.  
  6. Promise.promisifyAll(maxmind);
  7.  
  8. geoip.userGeoInfo = function () {
  9.  
  10. //Async db calls
  11. return Promise.all([
  12. maxmind.openAsync('./maxmind/GeoIP2-City.mmdb'),
  13. maxmind.openAsync('./maxmind/GeoIP2-ISP.mmdb'),
  14.  
  15. ]).then(function([cityLookup, ispLookup]) {
  16.  
  17. const city = cityLookup.get('66.6.44.4');
  18. const isp = ispLookup.get('66.6.44.4');
  19. const o = {};
  20. //console.log(city.city.geoname_id)
  21. o.geoname_id=city.city.geoname_id;
  22. o.isp=isp.isp;
  23.  
  24. //How to return o?;
  25.  
  26. });
  27.  
  28. }
  29.  
  30.  
  31. module.exports=geoip
Add Comment
Please, Sign In to add comment