brick.ts

@brickkit/cli

The brick command's building blocks: the dev and production servers, contract generation, and the OpenAPI pages.

llms.txt

@brickkit/cli exports 12 names: 4 functions, 4 interfaces, 3 types, 1 variable.

import { buildApplication, defineConfig, generateClientContract } from "@brickkit/cli";

Functions

FunctionDescription
buildApplicationBundle an exported BrickApp with its compiled IR and its original configuration.
generateClientContractGenerate browser metadata and transport types from the app's selected services.
startDevServerWhat brick dev runs: start the application, restart it when its files change, and serve the dashboard beside it.
startWorkerWhat brick worker runs: load the app, deliver its events and run its schedules from this process, without serving HTTP.

buildApplication

function buildApplication(
  options: BuildApplicationOptions,
): Promise<{ outdir: string; entry: string; ir: any; dashboard: string | undefined; workflows: string | undefined; }>

Bundle an exported BrickApp with its compiled IR and its original configuration.

Parameters

NameTypeDescription
optionsBuildApplicationOptions

Returns Promise<{ outdir: string; entry: string; ir: any; dashboard: string \| undefined; workflows: string \| undefined; }>

Source: packages/cli/src/build.ts:51

generateClientContract

function generateClientContract(app: BrickApp): string

Generate browser metadata and transport types from the app's selected services.

Parameters

NameTypeDescription
appBrickApp

Returns string

Source: packages/cli/src/client-contract.ts:16

startDevServer

function startDevServer(options: DevServerOptions = {}): Promise<any>

What brick dev runs: start the application, restart it when its files change, and serve the dashboard beside it. With an entry, the app runs in a worker process that restarts on every change to the entry or the files it imports, and reports its requests to the dashboard; without one, a server with the registered services starts in this process.

Parameters

NameTypeDescription
options?DevServerOptions default {}entry, port (else PORT, else 4000), prefix, clientOutput to regenerate the typed client's contract on each start, frontend to launch a frontend command once, and dashboard (port and historyDays, or false).

Returns Promise<any> — The application, when started in this process.

Throws

  • When frontend is given without clientOutput, or the dashboard would use the app's port.

Source: packages/cli/src/runner.ts:145

startWorker

function startWorker(options: { entry: string }): Promise<unknown>

What brick worker runs: load the app, deliver its events and run its schedules from this process, without serving HTTP. Run it beside API processes that only record events (events: { dispatch: false }), or alone for an app with no routes. Workflow listeners run here too: the world starts and the steps of every run in it execute in this process.

Parameters

NameTypeDescription
options{ entry: string }entry: the app file, which must default-export a brick() app.

Returns Promise<unknown> — The app.

Throws

  • When the entry is missing, has no events, or only records events.

Source: packages/cli/src/runner.ts:96

Interfaces

BuildApplicationOptions

interface BuildApplicationOptions

Properties

NameTypeDescription
entrystringA module whose default export is a BrickApp, without starting a server.
outdir?string
port?number
aot?booleanPrecompile Elysia's HTTP handlers at build time (default true).
dashboard?DashboardExtensionOptionsThe dashboard's extension, built into <outdir>/dashboard with those of the app's plugins for the production dashboard to serve; its theme is checked here too.

Source: packages/cli/src/build.ts:17

DashboardExtensionOptions

interface DashboardExtensionOptions

What dashboard accepts wherever the dashboard starts or is built.

Properties

NameTypeDescription
extension?stringA module whose default export is defineDashboard({ ... }), or the dashboard folder brick build wrote it to.
theme?DashboardTheme

Source: packages/cli/src/dashboard-extension.ts:33

DashboardTheme

interface DashboardTheme

Token values for the dashboard's light and dark themes, its radius and fonts.

Properties

NameTypeDescription
light?Record<string, string>Colour tokens in light mode, by name: { primary: "oklch(0.55 0.2 260)" }.
dark?Record<string, string>Colour tokens in dark mode.
radius?stringThe base corner radius, such as "0.5rem".
fonts?{ sans?: string; mono?: string }CSS font stacks. The page must be able to load the font.

Source: packages/cli/src/dashboard-extension.ts:21

DevServerOptions

interface DevServerOptions

Properties

NameTypeDescription
port?number
entry?string
prefix?stringDeprecated. Only used without an entry; an exported app sets its own prefix in brick({ prefix }).
clientOutput?stringGenerate a browser contract before starting the backend and frontend.
frontend?stringFrontend command, launched once after the first successful generation.
dashboard?| ({ port?: number; historyDays?: number } & DashboardExtensionOptions) | falseLocal dashboard with live requests, traces, errors, and reloads. Needs an entry. port is where it listens and historyDays how long finished requests are kept on disk; zero keeps live data only. extension and theme customise it (see DashboardExtensionOptions).
manifest?{ services: string; generated: string }Keep <generated>/services.gen.ts importing every definition file under services: written before the app starts and again when files change.

Source: packages/cli/src/runner.ts:27

Types

BrickConfig

type BrickConfig = Static<typeof BrickConfigSchema>;

Source: packages/cli/src/config.ts:141

LintPreset

type LintPreset = (typeof PRESET_NAMES)[number];

Source: packages/cli/src/config.ts:21

LintSeverity

type LintSeverity = (typeof SEVERITIES)[number];

Source: packages/cli/src/config.ts:22

Variables

defineConfig

const defineConfig: typeof defineProjectConfig

Deprecated. Import it from @brickkit/cli/config, which loads less. This one keeps everything index reaches loadable under Node.

Source: packages/cli/src/index.ts:14