Skip to content
Flare 0.1.x is pre-release. Expect breaking changes before 1.0 — see the changelog.

Glossary

TermMeaning
AdapterRuntime binding passed to new FlareHost(adapter). Use node on Node.js, cf on Cloudflare Workers, or buildCf(flareJson) when the adapter must receive a bundled config object. See Install.
ArcA transport surface on FlareHost (today: host.http). Arcs own routing, middleware shape, and request-scoped state. Services and config are shared across arcs.
build()Synchronous composition finalization: load config, run validators, compile HTTP pipelines, return a runtime app (.run(), .export(), or .test()). Not a bundler step. Safe to call more than once; later calls return the cached app.
Compile (HTTP)Final step of host.build() after validators pass: wires routes and middleware into per-route pipelines. Missing state providers or duplicate provides throw plain Error. See Failure modes.
ContractPer-route or per-controller descriptor (route, query, body, response) coerced and validated before your handler runs. ctx.extract(descriptor) returns typed route, query, and body fields. See Contracts.
flareContract()Factory for grouping shared descriptor entries. It returns a contract token you can attach to a controller (via static contract) and then reference per-method (for example ApiContract.getUser) with ctx.extract. See Contracts.
HostFlareHost: the composition root. Register config, services, and arcs on it, then call build().
PipelinePer-route middleware chain compiled at build(): global and group hooks run around the handler in a fixed order. See Middleware for group exclusion and short-circuit rules.
providesMiddleware declaration: state tokens this middleware writes via ctx.state.set in a before() hook. Satisfies downstream routes, controllers, or middleware that list the token in state. Only before() hooks satisfy downstream state declarations.
ScopedPer-request service lifetime (host.scoped). The host registers scoped factories at build() (or at app.test() in test mode). Instances are created on the first inject() in a request and disposed when the request ends.
SingletonPer-process service (host.singleton). Node only: calling host.singleton() on the Cloudflare adapter throws because Workers have no long-lived process. Use host.scoped() on Workers instead. Instantiated at build() (or at app.test() in test mode). onStart() runs when the app starts (.run() on Node, .export() on Workers, or at the start of app.test() in tests); onStop() at shutdown. Cannot depend on scoped services (CAPTIVE_DEPENDENCY at build()).
stateDeclaration on routes, controllers, or middleware: state tokens read via ctx.state.require() / ctx.state.get(). Not host.state, which is the host lifecycle enum (starting / ready / draining / stopped). HTTP compile fails if no earlier middleware provides the token from a before() hook. See State for build-time provisioning rules.
static depsExplicit DI declaration on services, controllers, and middleware. Required (may be []). Omitting it throws at host.scoped(), host.singleton(), or when registering HTTP classes. Tokens listed in deps but never registered fail at build() (UNDECLARED_DEPENDENCY, CONTROLLER_UNREGISTERED_DEP, MIDDLEWARE_UNREGISTERED_DEP). Calling inject() with a token not in deps throws at the call site.
TokenTyped handle: ServiceToken (service class, declared in static deps), StateToken (flareState(), declared in static state or provides), ConfigToken (flareConfig(), declared in static config). See Config for config tokens.

See Arc model, Composition, and Dependency injection.