native-geoip-middleware

Native app middleware for GeoIP

Usage no npm install needed!

<script type="module">
  import nativeGeoipMiddleware from 'https://cdn.skypack.dev/native-geoip-middleware';
</script>

README

GeoIP Middleware

Basic middleware for Node.js applications, featuring the native implementation of GeoIP.

Installation

$ npm install native-geoip-middleware --save

It will also install the GeoIP-Lite library, which may take a long time.

Usage

The example uses Express as the example.

var express = require('express'),
    app = express(),
    geoIP = require('native-geoip-middleware');

app.use(geoIP);

app.get('/', function(req, res) {
    res.status(200).send('Hello, user from ' + req.geo.city);
    // "Hello, user from San Francisco"
});

req.geo

Basically, it looks exactly like this.