Skip to main content

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 in src/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:

ConcernWhere
Runtime optionsnew Burger({...}) in src/index.ts
OpenAPI metadatasrc/openapi.config.ts
Global hookssrc/hooks.ts
Pluginssrc/plugins.ts
Providerssrc/providers.ts
Build-time settingsburger.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.