maxminded

    0.4.2 • Public • Published

    maxminded NPM version Build Status Dependency Status License

    Auto updating maxmind GeoIP lookup for free and paid maxmind accounts with optional cloudflare fallback. Leveringing the excellent node-maxmind package, maxminded manages regular data updates and provides an ultrafast geoip lookup fallback via geos-major and CloudFlare headers when there is a maxmind IP lookup miss.

    Install 🔨

    npm install maxminded
    

    Usage 🔧

    Drop in compatible with node-maxmind when using free Maxmind GeoLiteCity data.

    maxmind = require('maxminded');
    maxmind.init('GeoLiteCity.dat');             // local init data & free Wednesday updates
    location = maxmind.getLocation('66.6.44.4'); // City/Location lookup

    Free to paid geo data example 🔧

    Start with local free data, until initial paid data is loaded and then do paid data updates every Wednesday.

    maxminded = require('maxminded');
    maxminded.init({ 
        initLoad:    'GeoLiteCity.dat', // immediately initialize with local free data
        memoryCache: true,              // use memory cache for geo lookups
        license:     'S0meK3yIdHere',   // paid MAXMIND license key
        start:       true               // begin initial paid date update
    }, function(err) {                  // callback when re-initialized with paid data 
        if (err) console.log(err)
    });
     
    geo = maxminded.getLocation('66.6.44.4'); 

    Paid geo data example 🔧

    Use paid data and initialize doing updates every Wednesday and fallback to CloudFlare data until initial download and initialize completes or when maxmind.getLocation() fails to match an ip.

    This requires CloudFlare to be enabled for your domain so the cf-country header will be populated.

    maxminded = require('maxminded');
    maxminded.init({ 
        start:       true               // begin initial free date update
    }, function(err) {                 
        if (err) console.log(err)
    });
     
    geo = maxmind.getLocation('66.6.44.4', req.headers); // pass in request headers for fallback

    In this example, getLocation() will return undefined until the initial data is loaded and there is no cf-country header

    Optional parameters with defaults 💡

    maxminded.init({
        cronTime:    '00 30 03 * * 3', // update every Wednesday at 3:30am
        dest:        '/tmp/',          // where geo updates are stored
        retries:     5,                // 
    }, function(err) {                 // callback when maxmind.init() occurs
        console.log(err);
    })

    For additional parameter details see: node-maxmind and maxmind-loader and node-cron

    Note for PaaS users (like nodejitsu)

    A bonus of using maxminded is that your geo data doesn't need to be pushed to your PaaS with your code deploy. The geo ip data can be pulled directly from maxmind in compressed form when your application launches.

    maxminded.init({start: function() {
        var geo = maxminded.getLocation('66.6.44.4'); // GeoCityLite loaded w/weekly updates 
    }});

    License: MIT

    Dependencies:

    cron geos-major maxmind maxmind-reload time

    Development Dependencies:

    grunt grunt-bump grunt-license license-md mocha should

    Keywords

    none

    Install

    npm i maxminded

    DownloadsWeekly Downloads

    6

    Version

    0.4.2

    License

    MIT

    Last publish

    Collaborators

    • angleman