Star
API reference

FeaturekitServer

The control plane, the dashboard and this whole API are one class you construct in your own Node process. In development it starts Postgres and migrates for you; in production both turn off.

import { FeaturekitServer } from "featurekit-server";

const server = new FeaturekitServer({ port: 3000, flags: flagsFile });
await server.start();
console.log(server.url);

Options

OptionDefaultWhat it does
port, host3000, 127.0.0.1Where to listen. port: 0 picks a free port.
databaseUrlDATABASE_URLPostgres. Required in production. Left out in development, a Postgres container is started (needs @testcontainers/postgresql and Docker).
databaseSchemapublicThe one schema featurekit owns. Several installs can share a database.
nodeEnvNODE_ENVdevelopment, test or production.
autoMigrateon outside productionRun migrations in start(). In production, migrate as a deploy step instead.
devServiceson outside productionStart Postgres when no address is given.
flagsA flags file: { project, environment, flags }, applied on start. New flags are created; existing ones are left alone.
flagsResetFEATUREKIT_FLAGS_RESET=1Re-apply the file over existing flags, overwriting dashboard changes.
secureModeSecretSECURE_MODE_SECRETSigns client contexts. Comma-separate to rotate.
corsAllowedOrigins[]Origins allowed to call the client tier. Never *.
logLevelinfo
app{ dir, port?, host?, environmentKey? }: serve a browser app in development, with /sdk.js and /api/config.
labelContainer name prefix, so two checkouts can run side by side.
devStateFileWhere development records the addresses it picked. false to turn off.
clientKeysExistMakes SECURE_MODE_SECRET required at start in production.
envAny configuration variable by name, like { RATE_LIMIT_ADMIN_PER_MIN: "600" }.

Methods and properties

MemberWhat it is
start()Starts and resolves with { host, port, url }. Calling it twice returns the same address.
stop()Drains and shuts down: readiness fails first, streams get a jittered reconnect, then sockets close.
url, addressWhere it's listening. Throws before start() resolves.
appUrlWhere the development app host serves, or null.
configThe resolved configuration.
appThe assembled system: router, database, snapshot service, metrics.