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

jns-cloudflare

v1.0.1

Published

Cloudflare proxy support for JNS.

Readme

jns-cloudflare

Cloudflare proxy support for @jnode/server.

Installation

npm i jns-cloudflare

Quick start

Import

const { createServer, routerConstructors: r, handlerConstructors: h } = require('@jnode/server');
const { routerConstructors: cf } = require('jns-cloudflare');

Trusting Cloudflare proxies

const server = createServer(
  // The CloudflareProxy router verifies if the request comes from Cloudflare
  cf.CloudflareProxy(
    // Match: The request is from Cloudflare. 
    // ctx.identity.address is now the real client IP.
    r.Path(h.Text('Hello real user!')),

    // Fail: The request is NOT from Cloudflare.
    // We might want to block direct access or handle it differently.
    h.Text('Direct access not allowed', { statusCode: 403 })
  )
);

server.listen(8080);

How it works?

Cloudflare acts as a reverse proxy, meaning your server sees Cloudflare's IP addresses instead of the actual visitor's IP.

jns-cloudflare solves this by:

  1. Fetching Trusted IPs: Automatically fetches the latest list of official Cloudflare IP ranges (IPv4 and IPv6) on startup.
  2. Verification: Compares the incoming request's remote address against these trusted ranges.
  3. Identity Restoration: If the IP is verified, it extracts the real visitor's IP from the CF-Connecting-IP header and updates ctx.identity.address.
  4. Geo-data Enrichment: It also populates ctx.identity.country and ctx.identity.continent based on Cloudflare's headers.

Reference

Router: CloudflareProxy(next, fail)

  • next router | handler-extended The next step to execute if the request is confirmed to be routed through Cloudflare.
  • fail router | handler-extended The step to execute if the request remote address does not match Cloudflare's IP ranges.

Identity Enrichment

When a request passes through the next path, the following properties are guaranteed/updated in ctx.identity:

  • address <string>: Updated to the value of the CF-Connecting-IP header.
  • country <string>: Two-letter country code (ISO 3166-1 alpha-2) from CF-IPCountry.
  • continent <string>: Continent code from CF-IPContinent.

Automatic Updates

The router automatically initiates an asynchronous fetch of Cloudflare's IP list upon initialization. If the network request fails, it falls back to a built-in list of known Cloudflare IP ranges to ensure the server remains functional.