npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@enonic-types/lib-geoip

v3.0.1

Published

Type definitions for the Enonic XP GeoIP library

Readme

Types for GeoIP library

Type definitions for the Enonic XP GeoIP library.

Install

npm i --save-dev @enonic-types/lib-geoip

Versions track the library itself, so install the same version as the com.enonic.lib:lib-geoip dependency in your build.gradle.

Setup

Add lib-geoip to compilerOptions.paths in the tsconfig.json file used for your application's server-side TypeScript code:

{
  "compilerOptions": {
    "paths": {
      "/lib/geoip": ["./node_modules/@enonic-types/lib-geoip"]
    }
  }
}

Use

import {getLocationData, cityName, countryName, countryISO, geoPoint} from '/lib/geoip';

export function get(request) {
    const locationData = getLocationData(request.remoteAddress);

    return {
        body: {
            city: cityName(locationData),
            country: countryName(locationData, 'de'),
            countryCode: countryISO(locationData),
            geoPoint: geoPoint(locationData),
        },
        contentType: 'application/json',
    };
}

All imports from /lib/geoip should now be typed.

The MaxMind GeoLite2 City database must be present at $XP_HOME/config/GeoLite2-City.mmdb for lookups to return data.

API

getLocationData(ip?: string | null): LocationData | null

Gets location information for an IP address from the GeoLite2 City database. Falls back to the remote address of the current request when ip is omitted or null. Returns null if the database is missing or the lookup fails.

cityName(locationData: LocationData | null, language?: string): string | null

Gets the name of the city in the given language (default "en"). Falls back to English when the requested language is not present.

countryName(locationData: LocationData | null, language?: string): string | null

Gets the name of the country in the given language (default "en"). Falls back to English when the requested language is not present.

countryISO(locationData: LocationData | null): string | null

Gets the ISO code of the country, e.g. "US".

geoPoint(locationData: LocationData | null): string | null

Gets the latitude and longitude as a single string, e.g. "37.6534,-122.4231".

test(trace?: boolean): string

Runs a benchmark with millions of random IP addresses. Results are only written to the server log. When trace is true, JSON is logged for one in every 100,000 addresses. The test takes several minutes and puts a heavy load on the server.

LocationData

| Property | Type | Description | |----------------------|---------------------|--------------------------------------------------| | continent | ContinentInfo | Continent code, names and geoname_id. | | country | CountryInfo | Country iso_code, names and geoname_id. | | registered_country | CountryInfo | Country where the IP address is registered. | | city | CityInfo | City names and geoname_id. | | location | LocationInfo | latitude, longitude, time_zone, metro_code and accuracy_radius. | | postal | PostalInfo | Postal code. | | subdivisions | SubdivisionInfo[] | Regions such as states, with iso_code, names and geoname_id. |

All properties are optional, as data may not be available for every IP address. names is a LocationNames object keyed by language code, e.g. {en: 'California', de: 'Kalifornien'}.

Documentation

GeoIP library