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

@vafast/ip

v0.0.4

Published

![badge](https://github.com/gaurishhs/@vafast/ip/actions/workflows/npm-publish.yml/badge.svg)

Readme

@vafast/ip

badge

Get the client ip address in Tirne. It works with Bun, Cloudflare, Fastly and other runtimes.

Please consider starring the repository to show your ❤️ and support.

Installation

Requires Bun v1.0.4 or above. Requires Tirne v1.0.9 or above.

bun a @vafast/ip

Documentation

Introduction

This middleware adds an ip property to the context object. It contains the client ip address.

Usage

import { Server, json } from "tirne";
import { ip } from "@vafast/ip";

const ipMiddleware = ip();

const routes = [
  {
    method: "GET",
    path: "/",
    handler: (request: Request, context: any) => {
      return json({ ip: context.ip });
    },
    middleware: [ipMiddleware],
  },
];

const server = new Server(routes);

export default {
  fetch: (req: Request) => server.fetch(req),
};

How does it work?

For Bun runtime, We use server.requestIP introduced in Bun v1.0.4 to get the client ip address and early return it.

It relies on headers for runtimes other than Bun. Cloudflare and other providers send back specific headers, containing the IP address. For example CF-Connecting-IP for Cloudflare and Fastly-Client-IP for Fastly.

We also add support for X-Forwarded-For header (de-facto standard header) and other various headers.

Priority list:

  1. User specified
  2. X-Forwarded-For (de-facto standard header)
  3. X-Real-IP (Apache)
  4. X-Client-IP (Nginx)
  5. CF-Connecting-IP (Cloudflare)
  6. Fastly-Client-IP (Fastly)
  7. X-Cluster-Client-IP (GCP)
  8. X-Forwarded (RFC 7239)
  9. Forwarded-For (RFC 7239)
  10. Forwarded (RFC 7239)
  11. appengine-user-ip (GCP)
  12. true-client-ip (Akamai and Cloudflare)
  13. cf-pseudo-ipv4 (Cloudflare)

You can even specify your own headers if you want to as following

import { Server, json } from "tirne";
import { ip } from "@vafast/ip";

const ipMiddleware = ip({ checkHeaders: ["X-Forwarded-For", "X-Real-IP"] });

const routes = [
  {
    method: "GET",
    path: "/",
    handler: (request: Request, context: any) => {
      return json({ ip: context.ip });
    },
    middleware: [ipMiddleware],
  },
];

or

import { Server, json } from "tirne";
import { ip } from "@vafast/ip";

const ipMiddleware = ip({ checkHeaders: "X-Forwarded-For" });

const routes = [
  {
    method: "GET",
    path: "/",
    handler: (request: Request, context: any) => {
      return json({ ip: context.ip });
    },
    middleware: [ipMiddleware],
  },
];

You can also switch to Headers only mode by setting headersOnly to true. This will only check headers and not the server.requestIP property.

import { Server, json } from "tirne";
import { ip } from "@vafast/ip";

const ipMiddleware = ip({ headersOnly: true });

const routes = [
  {
    method: "GET",
    path: "/",
    handler: (request: Request, context: any) => {
      return json({ ip: context.ip });
    },
    middleware: [ipMiddleware],
  },
];

Debugging

Please use run the command setting environment variable NODE_DEBUG to either * or @vafast/ip

License

MIT

Author

Copyright (c) 2023 Gaurish Sethia, All Rights Reserved.