Applications
A BurgerAPI application is an instance of the Burger class. You configure it once and start it with serve.
import { Burger } from "burger-api";
const burger = new Burger({
apiDir: "./src/api",
});
burger.serve(4000);
OpenAPI metadata such as the title and version lives in src/openapi.config.ts. The new Burger({ title, version }) options still work as a fallback:
src/openapi.config.ts
import type { OpenAPIConfig } from "burger-api";
export default {
title: "My API",
version: "1.0.0",
} satisfies OpenAPIConfig;
The application brings together:
- Routes discovered from the file system (see Routing).
- Hooks that run at named stages of the request lifecycle (see Hook System).
- Plugins that extend the application, registered in
src/plugins.ts. - Providers that inject shared services into
ctx.services, declared insrc/providers.ts. - Validation schemas that guard requests (see Validation).
- OpenAPI documentation generated automatically from your routes (see OpenAPI & Swagger).
Where things live
Scaffolded projects split configuration across convention files:
| Concern | Where |
|---|---|
| Runtime options | new Burger({...}) in src/index.ts |
| OpenAPI metadata | src/openapi.config.ts |
| Global hooks | src/hooks.ts |
| Plugins | src/plugins.ts |
| Providers | src/providers.ts |
| Build-time settings | burger.build.ts (CLI only) |
Runtime options such as apiDir, apiPrefix, and validation are described in Server Options and Configuration. OpenAPI metadata is described in OpenAPI & Swagger.