bunway
Version:
Express-style routing toolkit built natively for Bun.
51 lines (34 loc) • 1.47 kB
Markdown
**Run everything. The Bun way.** bunWay is an open-source experiment to recreate the ergonomics of Express on top of Bun’s native runtime. If you moved to Bun for its speed and modern APIs but miss the familiar middleware/route flow, this toolkit is for you.
- Built entirely on Bun’s `Request`/`Response` objects.
- Familiar `(ctx, next)` middleware signature and `bunway()` factory.
- Ships batteries included: `json`, `urlencoded`, `text`, `cors`, and `errorHandler` middleware.
- TypeScript-first with generated `.d.ts` files and TypeDoc reference.
Give Bun developers the nostalgic Express flow without leaving the Bun runtime. No Node polyfills, no surprises—just Bun-native speed with a welcoming API.
```ts
import { bunway, cors, json, errorHandler, HttpError } from "bunway";
const app = bunway();
app.use(cors({ origin: true }));
app.use(json());
app.use(errorHandler({ logger: console.error }));
app.get("/", (ctx) => ctx.res.text("Hello from bunway"));
app.get("/users/:id", (ctx) => {
const id = ctx.req.param("id");
if (!id) throw new HttpError(404, "User not found");
return ctx.res.json({ id });
});
app.listen({ port: 7070 });
```
Install via:
```bash
bun add bunway
```
- Documentation: <https://bunwaylabs.github.io/bunway/>
- GitHub: <https://github.com/bunwaylabs/bunway>
- npm package: <https://www.npmjs.com/package/bunway>
MIT © bunway contributors