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

@nextrush/adapter-node

v3.0.6

Published

Node.js HTTP adapter for NextRush

Readme

@nextrush/adapter-node

Node.js HTTP adapter for NextRush. Connects your application to Node.js's built-in http.createServer.

Installation

pnpm add @nextrush/adapter-node @nextrush/core

Quick Start

import { createApp } from '@nextrush/core';
import { serve } from '@nextrush/adapter-node';

const app = createApp();

app.use(async (ctx) => {
  ctx.json({ message: 'Hello from Node.js!' });
});

const server = await serve(app, {
  port: 3000,
  onListen: ({ port }) => console.log(`Listening on port ${port}`),
});

API Reference

serve(app, options?)

Start an HTTP server with full configuration.

function serve(app: Application, options?: ServeOptions): Promise<ServerInstance>;

Parameters:

| Parameter | Type | Description | | --------- | -------------- | ------------------------------- | | app | Application | NextRush application instance | | options | ServeOptions | Server configuration (optional) |

Returns: Promise<ServerInstance>

ServeOptions:

| Option | Type | Default | Description | | ------------------ | ------------------------------------------------ | ------------ | ----------------------------------------------- | | port | number | 3000 | Port to listen on | | host | string | '0.0.0.0' | Host to bind to | | timeout | number | 30000 | Request timeout in milliseconds | | keepAliveTimeout | number | 5000 | Keep-alive timeout in milliseconds | | shutdownTimeout | number | 30000 | Graceful shutdown timeout in milliseconds | | onListen | (info: { port: number; host: string }) => void | — | Callback when server starts listening | | onError | (error: Error) => void | — | Custom error handler for uncaught server errors | | logger | Logger | app.logger | Logger for adapter diagnostics |

ServerInstance:

| Property | Type | Description | | ----------- | -------------------------------------- | --------------------------------------------------- | | server | Server | Node.js http.Server instance | | port | number | Actual listening port | | host | string | Bound host address | | address() | () => { port: number; host: string } | Get address info | | close() | () => Promise<void> | Graceful shutdown — drains connections, then closes |

listen(app, port?)

Shorthand that starts the server and logs a startup message.

function listen(app: Application, port?: number): Promise<ServerInstance>;
import { listen } from '@nextrush/adapter-node';

await listen(app, 3000);
// Output: 🚀 NextRush listening on http://localhost:3000

createHandler(app, options?)

Create a raw (req, res) handler for use with custom servers (HTTPS, HTTP/2, test harnesses).

function createHandler(
  app: Application,
  options?: { logger?: Logger }
): (req: IncomingMessage, res: ServerResponse) => void;
import { createHandler } from '@nextrush/adapter-node';
import { createServer } from 'node:https';
import { readFileSync } from 'node:fs';

const handler = createHandler(app);

const server = createServer(
  {
    key: readFileSync('private-key.pem'),
    cert: readFileSync('certificate.pem'),
  },
  handler
);

server.listen(443);

Graceful Shutdown

ServerInstance.close() stops accepting new connections, waits for in-flight requests to drain (up to shutdownTimeout), then calls app.close() for plugin cleanup.

const server = await serve(app, { port: 3000 });

process.on('SIGTERM', async () => {
  await server.close();
  process.exit(0);
});

Behind a Reverse Proxy

import { createApp } from '@nextrush/core';
import { serve } from '@nextrush/adapter-node';

const app = createApp({ proxy: true });

app.use(async (ctx) => {
  // ctx.ip reads X-Forwarded-For when proxy is trusted
  ctx.json({ ip: ctx.ip });
});

await serve(app, { port: 3000 });

Exports

import {
  // Server
  serve,
  listen,
  createHandler,
  type ServeOptions,
  type ServerInstance,

  // Context
  NodeContext,
  createNodeContext,
  type NodeContextOptions,

  // Body source
  NodeBodySource,
  createNodeBodySource,
  createEmptyBodySource,

  // Errors (re-exported)
  HttpError,
  BodyConsumedError,
  BodyTooLargeError,

  // Utilities
  getContentLength,
  getContentType,
  parseQueryString,

  // Type re-exports
  type Application,
  type BodySource,
  type Context,
  type HttpMethod,
  type Middleware,
  type Runtime,
} from '@nextrush/adapter-node';

License

MIT © NextRush Contributors