Runtimes
Bun
Run on Bun. Start with serve(), or pass the app to Bun.serve yourself
import { } from "@senrijs/senri";
import { } from "@senrijs/senri/serve";
const = ();
.("/", () => "Hello, Bun!");
await (); // http://localhost:3927bun --watch src/index.ts # restarts when you edit a file (the template's bun run dev)For a new app, the template is the quickest way.
bun create senri my-app --template bunWhat serve() does
serve() from @senrijs/senri/serve starts the app with Bun.serve on Bun. It also:
- Decides the port (the
portoption → thePORTenvironment variable →3927) - Prints the URL and the routes when it starts
- On SIGTERM / SIGINT, waits for in-flight requests before stopping
- Sets no body size limit (it does not use the 128 MiB default of
Bun.serve, to match the other runtimes) - Wires up the events of WebSocket routes (
upgradeWebSocket())
Pass the app to Bun.serve yourself
When you call Bun.serve yourself, pass app.fetch.
.({ : 3927, : . });With WebSocket routes, also pass websocket from @senrijs/senri/websocket.
import { } from "@senrijs/senri/websocket";
.({ : ., });Then the things in "What serve() does" are up to you. For example, bodies are cut at the Bun.serve default of 128 MiB.
Run in production
Start with NODE_ENV=production. Even if devtools() is still there, it gives no development output.
NODE_ENV=production bun src/index.ts