mirror of
https://github.com/oven-sh/bun
synced 2026-02-10 02:48:50 +00:00
* WIP * WIP * WIP * WIP * Improve typechecking in type files * Fix typechecking * Update * Update submodule * CI for typechecking * Add ci * Update commands * Format after build * Dont use bunx * Rename job * Use nodemodules prettier * Update workflow * Use symlink * Debug * Debug * Clean up and rename jobs
21 lines
560 B
TypeScript
21 lines
560 B
TypeScript
// A simple way to connect FileSystemRouter to Bun#serve
|
|
// run with `bun run index.tsx`
|
|
|
|
import { renderToReadableStream } from "react-dom/server";
|
|
import { FileSystemRouter } from "bun";
|
|
|
|
export default {
|
|
port: 3000,
|
|
async fetch(request: Request) {
|
|
const router = new FileSystemRouter({
|
|
dir: process.cwd() + "/pages",
|
|
style: "nextjs",
|
|
});
|
|
|
|
const route = router.match(request);
|
|
|
|
const { default: Root } = await import(route.filePath!);
|
|
return new Response(await renderToReadableStream(<Root {...route.params} />));
|
|
},
|
|
};
|