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

@dunx/http

v3.1.0

Published

Bun.serve adapter for the dunx framework: controllers, middleware and WebSocket gateways

Readme

@dunx/http

Bun.serve adapter for dunx. Class-based controllers and WebSocket gateways, standard decorators, and no JavaScript router - Bun's native routes does path params and per-method dispatch in Zig.

Bun.serve takes routes and websocket in one call, so both live here: one listen(), one server, one port. No express, no ws, no socket.io.

Install

bun add @dunx/http @dunx/core

Usage

import { inject, Module } from '@dunx/core';
import { Controller, Get, HttpFactory, Post, type Input } from '@dunx/http';
import { z } from 'zod'; // or Valibot, or ArkType, or none at all

const createUser = { body: z.object({ name: z.string() }) } as const;
const oneUser = { params: z.object({ id: z.coerce.number() }) } as const;

@Controller('users')
export class UsersController {
  readonly #users = inject(UsersService);

  @Get('/')
  list() {
    return this.#users.findAll(); // plain values become Response.json()
  }

  @Get('/:id', oneUser)
  one(input: Input<typeof oneUser>) {
    return this.#users.find(input.params.id); // a number, already validated
  }

  @Post('/', createUser)
  create(input: Input<typeof createUser>) {
    return this.#users.create(input.body.name); // 201, no Response.json()
  }
}

@Module({ controllers: [UsersController], providers: [UsersService] })
export class UsersModule {}

const app = await HttpFactory.create(AppModule);
app.enableShutdownHooks();
await app.listen(3000);

What is here

The guide is canonical for every row; this table is the index.

| Area | What it covers | Guide | | ----------------------- | ----------------------------------------------------------- | ----------------------------------------------------------------- | | Controllers and routing | Verb decorators, path params, prefixes, status codes | Controllers | | Typed input | body, query, params over Standard Schema | Validation | | Middleware and guards | One extension point, @UseGuards, @Roles, @Public | Middleware and guards | | WebSocket gateways | @Gateway, handlers, PubSub, multi-node relay | WebSockets | | Request logging | One structured entry per request, on by default | Logging | | Health and draining | /health/live, /health/ready, readiness during a rollout | Health checks | | Throttling | @Throttle, @SkipThrottle, memory and Redis counters | Middleware and guards | | Static files | Bun.file behind a mount, with a cache policy | Deployment | | Compression | zstd and gzip on Bun's own compressors | Deployment |

Subpaths

| Subpath | Contains | | ---------------------- | ----------------------------------------------------------------- | | @dunx/http | Everything above | | @dunx/http/client | The outbound half: HttpService, retry with backoff, HttpModule | | @dunx/http/internal | The framework's own plumbing. No stability promise |

@dunx/http/internal holds route-table construction, the middleware fold, the relay codec and the discovery readers - what @dunx/dashboard, @dunx/mcp and @dunx/openapi call and an app does not. It is the only place they are exported from, and it may change in any release.

Notes

  • Routes are discovered at boot by walking each controller's prototype chain, so an abstract base controller's @Get methods are inherited by every subclass.
  • A duplicate method and path throws at boot naming both handlers. Bun would otherwise silently keep one.
  • Handlers may return a Response, any JSON-serialisable value, or undefined for a 204.
  • Schemas, parsers and the status resolve at boot into the same closure the middleware chain folds into, so a request reads no metadata and does no lookup.

License

MIT