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

@chubbyts/chubbyts-undici-server-node

v1.3.0

Published

Use @chubbyts/chubbyts-undici-server on node.js

Readme

chubbyts-undici-server-node

CI Coverage Status Mutation testing badge npm-version

bugs code_smells coverage duplicated_lines_density ncloc sqale_rating alert_status reliability_rating security_rating sqale_index vulnerabilities

Description

Use @chubbyts/chubbyts-undici-server on node.js.

Requirements

Installation

Through NPM as @chubbyts/chubbyts-undici-server-node.

npm i @chubbyts/chubbyts-undici-server-node@^1.3.0

Usage

import { STATUS_CODES } from 'node:http';
import type { Server } from 'node:http';
import { createServer } from 'node:http';
import type { Handler, ServerRequest } from '@chubbyts/chubbyts-undici-server/dist/server';
import { Response } from '@chubbyts/chubbyts-undici-server/dist/server';
import {
  createNodeRequestToUndiciRequestFactory,
  createUndiciResponseToNodeResponseEmitter,
} from '@chubbyts/chubbyts-undici-server-node/dist/node';

const serverHost = process.env.SERVER_HOST as string;
const serverPort = parseInt(process.env.SERVER_PORT as string);

const shutdownServer = (server: Server) => {
  server.close((err) => {
    if (err) {
      console.warn(`Shutdown server with error: ${err}`);
      process.exit(1);
    }

    console.log('Shutdown server');
    process.exit(0);
  });
};

// second argument (optional): the request body must be fully received within 30s
const nodeRequestToUndiciRequestFactory = createNodeRequestToUndiciRequestFactory('https://example.com', 30_000);

// for example @chubbyts/chubbyts-framework app (which implements Handler)
const handler: Handler = async (serverRequest: ServerRequest<{name: string}>): Promise<Response> => {
  return new Response(`Hello, ${serverRequest.attributes.name}`, {
    status: 200,
    statusText: STATUS_CODES[200],
    headers: {'content-type': 'text/plain'}
  });
};

// argument (optional): the response must be fully sent within 60s
const undiciResponseToNodeResponseEmitter = createUndiciResponseToNodeResponseEmitter(60_000);

const server = createServer(async (req, res) => {
  try {
    const serverRequest = nodeRequestToUndiciRequestFactory(req);
    const response = await handler(serverRequest);
    undiciResponseToNodeResponseEmitter(response, res);
  } catch (error) {
    console.error(`Failed to handle request: ${error}`);

    // once headers are sent the response cannot be turned into a 500 anymore:
    // destroying the socket is the only way to signal the failure to the client
    if (res.headersSent) {
      res.destroy(error instanceof Error ? error : new Error(String(error)));

      return;
    }

    res.writeHead(500, { 'content-type': 'text/plain' }).end('Internal Server Error');
  }
});

server.listen(serverPort, serverHost, () => {
  console.log(`Listening to ${serverHost}:${serverPort}`);
});

process.on('SIGINT', () => shutdownServer(server));
process.on('SIGTERM', () => shutdownServer(server));

Timeouts

Slow clients (slowloris) can otherwise tie up sockets indefinitely:

  • createNodeRequestToUndiciRequestFactory(baseUrl, requestBodyTimeoutMs): if the request body has not been fully received within the given time, the request gets destroyed and the error surfaces to the handler through the request body stream.
  • createUndiciResponseToNodeResponseEmitter(responseSendTimeoutMs): if the response has not been fully sent within the given time (slow reading client or stalling response body stream), the response gets destroyed.

Both timeouts are optional and disabled by default. They only cover the body phases handled by this adapter, so make sure the node server level timeouts are configured as well: server.headersTimeout (slow header senders), server.requestTimeout and server.keepAliveTimeout.

Copyright

2026 Dominik Zogg