Bun

Ingenium ships a first-class BunAdapter for Bun.serve. The adapter wraps Bun's server with a Web Streams ↔ node:stream bridge so existing IngeniumBody parsers work unchanged.

Install

npm install ingenium ingenium-bun

Requires Bun 1.1+.

Usage

import { ingenium } from 'ingenium'
import { BunAdapter } from 'ingenium-bun'

const app = ingenium({ transport: new BunAdapter() })
await app.listen(3000)

That's the only change - app.get, app.use, ctx.body.json(), plugins, middleware, and the full built-in surface all work identically.

How it works

  • Wraps Bun.serve() as the underlying server.
  • Bridges ReadableStream (web streams) to node:stream.Readable so ctx.body.stream(), ctx.body.multipart(), and any other consumer that expects a Node stream work without changes.
  • Lazy body - request body is not materialized unless ctx.body.* is called. Handlers that don't read the body never pay the cost.

Scaffolding a Bun project

ingenium new my-bun-api --bun

The --bun template wires up the adapter and a Bun-flavored package.json. See the CLI page for all template flags.

Where to next?

  • Transports - the transport contract.
  • HTTP/2 - TLS and cleartext HTTP/2.
  • WebSocket - Bun-compatible WebSocket support.
  • CLI - ingenium new --bun scaffolder.