@renec-foundation/geo-lookup-api
TypeScript icon, indicating that this package has built-in type declarations

1.1.4 • Public • Published

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

Readme

Keywords

none

Package Sidebar

Install

npm i @renec-foundation/geo-lookup-api

Weekly Downloads

100

Version

1.1.4

License

ISC

Unpacked Size

12.9 MB

Total Files

12

Last publish

Collaborators

  • renec-foundation