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
| Option | Default | What it does |
|---|---|---|
port, host | 3000, 127.0.0.1 | Where to listen. port: 0 picks a free port. |
databaseUrl | DATABASE_URL | Postgres. Required in production. Left out in development, a Postgres container is started (needs @testcontainers/postgresql and Docker). |
databaseSchema | public | The one schema featurekit owns. Several installs can share a database. |
nodeEnv | NODE_ENV | development, test or production. |
autoMigrate | on outside production | Run migrations in start(). In production, migrate as a deploy step instead. |
devServices | on outside production | Start Postgres when no address is given. |
flags | A flags file: { project, environment, flags }, applied on start. New flags are created; existing ones are left alone. | |
flagsReset | FEATUREKIT_FLAGS_RESET=1 | Re-apply the file over existing flags, overwriting dashboard changes. |
secureModeSecret | SECURE_MODE_SECRET | Signs client contexts. Comma-separate to rotate. |
corsAllowedOrigins | [] | Origins allowed to call the client tier. Never *. |
logLevel | info | |
app | { dir, port?, host?, environmentKey? }: serve a browser app in development, with /sdk.js and /api/config. | |
label | Container name prefix, so two checkouts can run side by side. | |
devStateFile | Where development records the addresses it picked. false to turn off. | |
clientKeysExist | Makes SECURE_MODE_SECRET required at start in production. | |
env | Any configuration variable by name, like { RATE_LIMIT_ADMIN_PER_MIN: "600" }. |
Methods and properties
| Member | What 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, address | Where it's listening. Throws before start() resolves. |
appUrl | Where the development app host serves, or null. |
config | The resolved configuration. |
app | The assembled system: router, database, snapshot service, metrics. |