Bun Box
Installation
- Install bun & create a new project
❯ mkdir bunbox-example && cd bunbox-example
❯ bun init
# work through prompts
❯ bun install
- Install
bunbox
- Create a controller:
/controllers/hello.ts
import { Controller } from "bunbox"
import type { Context } from "bunbox"
class HelloController implements Controller {
route: string
method: string
constructor() {
this.method = "GET"
this.route = "/hello"
}
run = (c: Context) => c.text("Hello!")
}
export default HelloController
- Update your
index.ts
:
import BunBox from "bunbox"
const box = new BunBox()
box.serve()
- Run with
bun run index.ts
:
❯ curl localhost:3000/hello
Hello!