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

@arraypress/hono-utils

v1.0.0

Published

Small Hono context helpers — client IP resolution with opt-in proxy trust, absolute URL building from the request's origin, and origin extraction. The glue every Workers/Hono app reinvents.

Readme

@arraypress/hono-utils

Three small Hono context helpers that every Workers/Hono app reinvents.

Install

npm install @arraypress/hono-utils

Usage

import { getClientIP, getOrigin, buildUrl } from '@arraypress/hono-utils';

app.post('/api/whatever', async (c) => {
  const ip = getClientIP(c);                          // '203.0.113.5'
  const origin = getOrigin(c);                        // 'https://store.com'
  const verifyLink = buildUrl(c, '/verify', { token });
  // ...
});

Exports

getClientIP(c): string

Resolves the client IP with opt-in proxy-header trust:

  1. CF-Connecting-IP — always trusted (Cloudflare edge sets it; origin code can't forge).
  2. X-Real-IP / X-Forwarded-For — only consulted when TRUST_PROXY_HEADERS=1 is set on c.env.

Returns '' when no trustworthy header is present. Callers decide whether to refuse the request or proceed without an IP (used by rate limiters, blocklists, audit logs).

Never trust proxy headers by default. A spoofed X-Forwarded-For would otherwise bypass every IP-based control. Set TRUST_PROXY_HEADERS=1 only when you control the proxy hop (Vercel behind their infra, nginx you operate) AND it strips client-supplied values before forwarding.

getOrigin(c): string

Returns protocol://host of the current request. No trailing slash. For composing absolute URLs to hand back to users.

buildUrl(c, path, params?): string

Absolute URL rooted at the current request's origin. Query params URL-encoded. Works across multiple domains (preview deployments, staging, custom domains) without configuration — the origin is read from the request, not from env.

buildUrl(c, '/account/verify', { token: 'abc 123' });
// → 'https://store.com/account/verify?token=abc+123'

Why these live together

All three read from c.req.url + headers; all three are used in every route that composes absolute links or enforces per-IP limits. Splitting into three packages would just mean three import lines per route for no benefit.

License

MIT