使用 Hono 和 Bun 建置 HTTP 伺服器
Hono 是一個為邊緣環境設計的輕量級 Web 框架。
import { Hono } from "hono";
const app = new Hono();
app.get("/", c => c.text("Hono!"));
export default app;
使用 create-hono 從 Hono 的專案模板開始。提示選擇模板時請選擇 bun。
terminal
bun create hono myapp
Text
create-hono version 0.19.4
✔ Using target directory … myapp
✔ Which template do you want to use? bun
✔ Do you want to install project dependencies? Yes
✔ Which package manager do you want to use? bun
✔ Cloning the template
✔ Installing project dependencies
🎉 Copied project files
Get started with: cd myapp
terminal
cd myapp
bun install
然後啟動開發伺服器並訪問 localhost:3000。
terminal
bun run dev
請參閱 Hono 的使用 Bun 快速開始指南。