Last active
January 10, 2018 12:32
-
-
Save hmpmarketing/bee9a4ecfdf6cb6dd8dd88ddb0296aca to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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