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

@nifrajs/node

v3.1.0

Published

Run a nifra app on Node's http server - a Request<->stream adapter with a graceful stop().

Readme

@nifrajs/node

Run a nifra app on Node's http server - nifra's ergonomics, deployed on Node instead of Bun.

bun add @nifrajs/node   # or: npm add @nifrajs/node
import { server } from "@nifrajs/core/server"
import { serve } from "@nifrajs/node"

const app = server().get("/users/:id", (c) => ({ id: c.params.id }))

const node = await serve(app, { port: 3000 })
// node.port            → the bound port (resolved; useful with `port: 0`)
// await node.stop()    → drain in-flight, then force-close (graceful shutdown)

serve(app, { port }) bridges Node's stream-based (req, res) to/from the Web Request/Response that app.fetch speaks - that's the only Bun-specific seam, since nifra's lifecycle is already Web-standard. It also gives you a graceful stop(), the Node equivalent of Bun's app.listen().

Public URL protocol

The adapter creates a plain Node http server, so Request.url uses http:// by default. If TLS terminates in front of Node, set the public protocol explicitly:

await serve(app, { port: 3000, protocol: "https" })

Forwarded protocol headers are not trusted automatically; pass a function only when your own trusted infrastructure has validated the request:

await serve(app, {
  port: 3000,
  protocol: (req) => req.headers["x-forwarded-proto"] === "https" ? "https" : "http",
})

By default, request.url reflects the inbound Host header. Do not use that value for security decisions unless the deployment validates it. Set allowedHosts to reject unknown host authorities, or set canonicalHost behind a trusted proxy to build URLs from a fixed authority. If neither option is set, treat the host in request.url as client-controlled.

Static files

The optional static root is served before app.fetch for GET and HEAD requests. It is a public asset directory and must contain nothing private: no secrets, source maps, build metadata, or user uploads. The directory and its ancestor path must be read-only and owned by the service (or otherwise protected from untrusted local writers). Nifra resolves and confines the file before opening it and refuses symlinked final files, but Node does not expose a native per-component openat primitive; a process that can mutate the tree concurrently can still create a local TOCTOU race. Mutable or attacker-writable static trees are therefore outside the adapter's guarantee. Store user-controlled files outside the static root and serve them through an application or object-storage path with its own validation policy.

Graceful shutdown on signals

Opt in to SIGTERM/SIGINT handling so a docker stop / Ctrl-C drains in-flight requests before exit (mirrors Bun's listen({ gracefulSignals }) - off by default, since owning process signals should be a deliberate choice):

await serve(app, { port: 3000, signals: true })

What you get for free

The request timeout (server({ requestTimeoutMs })503 request_timeout) and body-size cap live inside app.fetch, not Bun's listen() - so they apply through this adapter with no extra wiring. Slow-client / slow-loris protection is Node's built-in requestTimeout (300s) and headersTimeout (60s) defaults.

Works with any { fetch(req): Promise<Response> } handler, not just nifra. ESM-only. MIT.

For AI agents

Start with LLM.md - this package's contract card (the exports you call + its footguns), one cheap read instead of the whole corpus. For the wider framework: the repo's AGENTS.md is the copy-paste quick reference, and llms-full.txt is the full machine-readable corpus. Run nifra check as the done-gate, or nifra mcp to give the agent live project tools.