ingenium-bun
v0.0.5
Published
Bun.serve transport adapter for Ingenium.
Maintainers
Readme
ingenium-bun
A Bun.serve() transport adapter for Ingenium. Lets you
run a Ingenium app on the Bun runtime instead of node:http, with the
same handler surface and the same per-request IngeniumContext.
Install
bun add ingenium ingenium-bunUse
import { ingenium } from 'ingenium'
import { BunAdapter } from 'ingenium-bun'
const app = ingenium({ transport: new BunAdapter() })
app.get('/', () => ({ hello: 'world' }))
app.get('/users/:id', (ctx) => ({ id: ctx.params.id }))
await app.listen(3000)Run with:
bun run server.tsHow it works
On each request, the adapter:
- Acquires a pooled
IngeniumContextfrom the framework. - Populates it from the WinterCG
Request(method, url, path, rawQuery, headers, and a lazy body bridge — the body is only consumed if your handler callsctx.body.*). - Awaits
app.handle(ctx). - Builds a
Responsefrom the context's status, headers, and body kind. Streamed bodies are converted fromnode:streamReadableback to a WinterCGReadableStreamviaReadable.toWeb.
Known limitations
- Handlers that rely on Node-only stream APIs (e.g.
.unshift, raw socket access,IncomingMessagequirks) may behave differently under Bun. req.bodyis exposed as a NodeReadablefor compatibility with the rest of Ingenium, but the underlying source is a WinterCG stream — performance characteristics differ slightly from thenode:httptransport.- Trailers and HTTP/2 push are not supported (Bun limitation).
