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

ip-intel

v1.0.3

Published

Express middleware to extract real client IP and optional geo-location, supporting proxies and CDNs.

Readme

ip-intel

Express middleware to extract the real client IP address (supporting proxies and CDNs) and optionally enrich with geo-location data. Attaches info to req.clientInfo.

Features

  • Accurate client IP extraction (supports x-forwarded-for, x-real-ip, cf-connecting-ip, etc.)
  • Configurable trusted proxies and header priority
  • Optional geo-location enrichment (default: ip-api.com)
  • Lightweight, privacy-conscious, and configurable

Usage

Install the package:

npm install ip-intel

Add the middleware to your Express app:

import express from "express";
import ipIntel from "ip-intel";

const app = express();
// Enable geo-location enrichment (optional)
app.use(ipIntel({ geo: true }));

app.get("/", (req, res) => {
	// req.clientInfo will be available here
	res.json(req.clientInfo);
});

app.listen(3000);

What does this library do?

  • Extracts the real client IP address from incoming requests, even when behind proxies or CDNs.
  • Optionally enriches the request with geo-location data (country, region, city, latitude, longitude) using a pluggable provider (default: ip-api.com).
  • Attaches the result to req.clientInfo for use in your routes, logging, analytics, or security logic.

Example output

When running on localhost

If you test this middleware on your local machine (e.g., using localhost or 127.0.0.1), the output will look like this:

{
	"ip": "::1"
}

or (if using IPv4):

{
	"ip": "127.0.0.1"
}

Note: Geo-location data will not be available for local/private IP addresses.

When running on a public server

When deployed to a public server or accessed via a public IP (or using a tunneling service like ngrok), the output will include geo-location info:

{
	"ip": "123.45.67.89",
	"geo": {
		"country": "US",
		"region": "California",
		"city": "San Francisco",
		"lat": 37.7749,
		"lon": -122.4194
	}
}

If geo-location is disabled or unavailable, the output will be:

{
	"ip": "123.45.67.89"
}

Configuration

  • geo: Enable geo-location lookup (default: false)
  • geoProvider: Custom geo provider function (optional)
  • trustedProxies: Array of trusted proxy IPs or CIDRs
  • headerPriority: Array of header names to check for IP

Configuration Examples

You can customize the middleware using these options:

Enable geo-location (default provider)

app.use(ipIntel({ geo: true }));

Use a custom geo provider

app.use(
	ipIntel({
		geo: true,
		geoProvider: async ip => {
			// Example: always return a fixed location
			return { country: "ID", region: "Bali", city: "Denpasar", lat: -8.65, lon: 115.2167 };
		},
	})
);

Set trusted proxies

app.use(
	ipIntel({
		trustedProxies: ["127.0.0.1", "::1", "10.0.0.0/8"],
	})
);

Customize header priority

app.use(
	ipIntel({
		headerPriority: ["x-real-ip", "x-forwarded-for", "cf-connecting-ip"],
	})
);

Combine options

app.use(
	ipIntel({
		geo: true,
		trustedProxies: ["127.0.0.1"],
		headerPriority: ["x-forwarded-for", "x-real-ip"],
	})
);

License

MIT