@flow-state-dev/node/app
Interfaces
ServerApp
The portable host app plus its lifecycle handles.
Properties
app
readonly app: Hono;
The Hono app. app.fetch is the Web-Fetch handler every adapter consumes
(@hono/node-server, hono/aws-lambda, Bun, Deno).
Methods
dispose()
dispose(options?): Promise<void>;
Dispose the resolved router and, when built from a FlowState, its stores.
Idempotent and safe to call before initialization settles.
Parameters
options?
drainMs?
number
How long the router waits for the requests its due
wakes started before it aborts them (the router's own default, 10 s,
when omitted). serve passes what is left of its shutdown grace.
Returns
Promise<void>
tryDedicatedRoute()
tryDedicatedRoute(req): Promise<Response | null>;
Match req against ONLY a transport adapter's dedicated routes (those
registered OUTSIDE basePath, e.g. the MCP adapter's /mcp/:kind under
dedicatedBasePath). Returns the matched Response, or null when none
match — it never touches the canonical flow-API handler. The app already
uses this in its not-found fallback; a host that registers its own broad
catch-all AFTER the app (e.g. serve()'s SPA get("*") for a staticDir)
must call it first so a dedicated route isn't shadowed by that fallback.
Blocks on init like the canonical handler, so a dedicated route (including a
GET one — OAuth/webhook callbacks) is served once ready rather than falling
through to the fallback during a store cold start. Returns null if init
failed. The SPA host should call it only AFTER its static-file fast path, so
real assets are still served without waiting on init.
Parameters
req
Request
Returns
Promise<Response | null>
ServerAppOptions
Options for createServerApp. Defaults match createFlowApiRouter.
Extended by
Properties
basePath?
basePath?: string;
API mount prefix. Default "/api/flows". Interpolated raw into a Hono route
pattern, so avoid : and * (Hono pattern syntax) in a custom value.
healthPath?
healthPath?: string;
Health endpoint path. Default "/healthz". 200 once ready, 503 before.
servesPush?
servesPush?: boolean;
Whether the host running this app serves the push socket. Default
false: the app reports push: null in GET /capabilities and answers
the push mint 404, even over a router another host serves push for, so a
client reads on its timer instead of minting for a socket this host
doesn't open. serve() sets it when it serves push.
Functions
createServerApp()
function createServerApp(app, options?): ServerApp;
Build the portable host app for app (a FlowState or a raw
FlowApiRouter).
Router resolution starts immediately: for a FlowState this kicks off store
init and the app reports 503 on /healthz and the API until it resolves (500
if it rejects); a raw router is ready at once. The API catch-all delegates to
the engine router by HTTP method, passing the Web Request straight through —
SSE response bodies stream unbuffered on whichever host runs app.fetch.
Parameters
app
FlowState<FlowStateSettings> | FlowApiRouter