hmpo-countries-lib

7.0.0 • Public • Published

hmpo-countries-lib

Country data API cache and wrapper library

Usage

const CountriesLib = require('hmpo-countries-lib');

let redisFactory = {
    getClient() {
        return redisInstance;
    }
}

let countriesLib = new CountriesLib({
    store: redisFactory,
    key: 'store-key-prefix',
    storeInterval: 10000, // 10 seconds
    countryUrl: 'http://example.com/api/countries',
    countryInterval: 3000000 // 5 minutes
});

// start polling
countriesLib.start();
let allCountries = countriesLib.getAllCountries();
let residentCountries = countriesLib.getResidentCountries();
let overseasCountries = countriesLib.getOverseasCountries();
let overseasResidenceCountries = countriesLib.getOverseasResidenceCountries();
let overseasBirthCountries = countriesLib.getOverseasBirthCountries();
let birthCountries = countriesLib.getBirthCountries();
let countryData = countriesLib.getCountryDataById('GB');
let countryData = countriesLib.getCountryDataBySlug('united-kingdom');
let countryData = countriesLib.getCountryByDisplayName('United Kingdom');
// stop polling
countriesLib.stop();

Dependencies (3)

Dev Dependencies (9)

Package Sidebar

Install

npm i hmpo-countries-lib

Weekly Downloads

6

Version

7.0.0

License

MIT

Unpacked Size

35.6 kB

Total Files

10

Last publish

Collaborators

  • georgeeker
  • msjhall
  • samchatfield
  • rewaz.ismail