Deploy on Bun
Bun is BurgerAPI's primary runtime and needs Bun 1.4.4 or newer. A Bun
deployment uses the Bun adapter directly: burger.serve(port) runs a
long-lived HTTP server with the full feature set (native static route map,
WebSockets, pages).
How it works
src/index.tscreates theBurgerapp and callsburger.serve(port).burger-api buildcompiles routes ahead of time (AOT) into the production bundle.burger-api startruns the production build on your server.
Entry file
// src/index.ts
import { Burger } from "burger-api";
const app = new Burger({
apiDir: "./src/api",
});
// Read PORT so the host platform can assign one; fall back to 4000 locally.
const port = Number(process.env.PORT) || 4000;
app.serve(port, () => {
console.log(`Server running on http://localhost:${port}`);
});
The generated package.json maps the CLI commands to Bun scripts:
{
"scripts": {
"dev": "burger-api dev",
"start": "burger-api start",
"build": "burger-api build src/index.ts",
"typecheck": "bun check"
}
}
Local development
bun run dev
Production build
bun run build # AOT route scan + production bundle
bun run start # serve the production build
VPS or Docker
Build and run the production bundle, then expose the port:
FROM oven/bun
WORKDIR /app
COPY . .
RUN bun install
RUN bun run build
EXPOSE 4000
CMD ["bun", "run", "start"]
@burger-api/cli is a devDependency, so run a plain bun install (not a production-only install) before bun run build and bun run start; both scripts invoke the CLI. Alternatively, skip the CLI at runtime by starting the bundle directly with CMD ["bun", ".build/bundle/app.js"], which works from a production-only install.