Skip to main content

Bun

Bun's Bun.serve() accepts a standard fetch handler directly.

1. Install

bun add @daiso-tech/core hono

2. Create the handler

// src/index.ts
import {
HttpRouter,
HttpRes,
defaultHttpRouterAdapter,
} from "@daiso-tech/core/http-router";

const router = new HttpRouter({ router: defaultHttpRouterAdapter });

router.endpoint({
url: "/hello",
method: "GET",
handler: async () => HttpRes.text("Hello Bun!"),
});

export default {
port: 3000,
fetch: (request: Request) => router.fetch(request),
};

File structure

.
├── src
│ └── index.ts
├── package.json
└── tsconfig.json

3. Develop

bun run --hot src/index.ts

4. Deploy

bun run src/index.ts

Reference: Bun HTTP Server, Hono on Bun