1.1.4 • Published 2 months ago

@renec-foundation/geo-lookup-api v1.1.4

Weekly downloads
-
License
ISC
Repository
-
Last release
2 months ago

geo-lookup-api

  • Can be used as a middleware / api route for popular frameworks like Next.JS, etc.

Example in Next.JS

Create a file in /pages/api directory, for e.g /pages/api/geo.js

const { handler } = require("@renec-foundation/geo-lookup-api");

const api = async (req, res) => await handler(req, res);

export default api;

request host/api/geo

{ "lang": "vi", "info": { "ip": "42.114.185.210" } }

Utility method:

const { getCountry } = require("@renec-foundation/geo-lookup-api");

getCountry("ip_string");

Run test:

yarn test

Or you can test with a remote database

❯ GEO_DB_URL=https://git.io/GeoLite2-Country.mmdb yarn test
https://github.com/P3TERX/GeoLite.mmdb?tab=readme-ov-file
1.1.4

2 months ago

1.1.3

2 months ago

1.1.1

4 months ago

1.1.2

4 months ago

1.1.0

12 months ago

1.0.4

12 months ago

1.0.3

12 months ago

1.0.2

12 months ago

1.0.1

12 months ago

1.0.0

12 months ago