8000 GitHub - StouderIO/adonis-geolite2 at v2.1.1
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

StouderIO/adonis-geolite2

Repository files navigation

@stouder-io/adonis-geolite2

Maxmind's GeoLite2 integration for Adonis

npm

Legal Warning

This package uses geolite2-redist and thus, you MUST comply with it specifics conditions. For more informations please check their npm page.

Installati 875A on

This package is available in the npm registry.

npm i @stouder-io/adonis-geolite2

Next, configure the package by running the following command.

node ace configure @stouder-io/adonis-geolite2

Usage

The geolite2 is automatically attached to HTTP requests, allowing you to use it to retries informations about the geolocation of requesting IPs.

Route.get('/', async ({ geolite2 }: HttpContextContract) => {
    const country = geolite2.country()
    const city = geolite2.city()
    const asn = geolite2.asn()

    return { country, city, asn }
})

If no parameter is provided to the functions, it uses request.ip(). Alternatively you can pass the IP you want to lookup.

Route.get('/', async ({ geolite2 }: HttpContextContract) => {
    const country = geolite2.country('8.8.8.8')
    const city = geolite2.city('8.8.8.8')
    const asn = geolite2.asn('8.8.8.8')

    return { country, city, asn }
})

Packages

No packages published

Contributors 2

  •  
  •  
0