The plugin contains geo-location functionality and geo-ip matching. Behind the scenes, it uses geoip-lite and geoip-ultralight as data sources. Since all geo-location data is loaded in-memory, the plugin will add roughly 70MB of RAM and 2-3 second delay to your application.

By default, the plugin will auto-load geoip-ultralight at boot time, and auto-load geoip-light at the time of the first IP lookup.

Installation and usage
npm i --save thorin-plugin-geo@1.x
'use strict';
// app.js entry file
const thorin = require('thorin');

thorin.addPlugin(require('thorin-plugin-geo'));   // <- add this line => {});

Default configuration
  • regionalboolean, true should we load the regional information that gives us countries and region lookup
  • autoloadboolean, false if set to true, it will auto-load geoip-light
Plugin functionality
Returns an array of code,name containing every country on Earth.
Returns information about a country given its code
Returns the name of a country by its code.
Returns an array of country phone prefixes.
Returns the continent of a country by its code.
Returns an array of code,name representing all the regions of a country.
pluginObj.getRegionName(countryCode, regionCode)
Returns the name of the given region code, from a country
pluginObj.lookup(ip, fn) : Promise
Synchronously perform a country lookup for the given IP address. If a callback function is specified, use it, otherwise return a Promise
The full information may contain:
  • code the 2-letter country code
  • name the country name
  • lat the country latitude
  • lon the country longitude
  • region a code,name entry of the region
  • city the name of the city
  • full the full geo representation (city, region, country)
Synchronously returns country-only information about the given IP.
  • code the 2-letter country code
  • iso the 3-letter country code
  • continent the 2-letter continent code
  • name the country name
Extended Thorin.Intent
intentObj.geoData(fn) : Promise
Small wrapper over pluginObj.lookup that will fetch information about the intent's client IP address. If a callback function is provided, it will use it, otherwise returns a promise.
intentObj.getCountry() : Object
Small wrapper over pluginObj.lookupCountry that will return country information about the intent's client IP address
Do you have a question or is something missing?

You can always create a new issue on GitHub or contact one of the core founders by chat.