A simple HTTP router for Bun.serve.
$ bun install [email protected]:esyfyi/bun-router.gitimport { Router } from "bun-router";
const router = new Router();
router.add({
name: "hello-world",
method: "GET",
path: "/hello-world",
action(request) {
return new Response("Hello world!");
},
});
Bun.serve({
port: 3000,
fetch(request) {
return router.route(request);
}
});To install dependencies:
bun installTo run the unit tests:
bun run testThis project was created using bun init in bun v1.0.3. Bun is a fast all-in-one JavaScript runtime.