Skip to content

API Reference

createDashboardHandler(synkro, options?)

Creates an HTTP request handler that serves the dashboard UI and its backing API routes.

Signature

function createDashboardHandler(
synkro: Synkro,
options?: DashboardOptions,
): (req: IncomingMessage, res: ServerResponse) => void;

Parameters

ParameterTypeDescription
synkroSynkroA running Synkro instance (from @synkro/core).
options.basePathstringURL prefix the handler is mounted at. Defaults to "/".

Return value

A standard Node.js request handler (IncomingMessage, ServerResponse) => void compatible with Express, Fastify (via req.raw / reply.raw), and the built-in http module.


Served routes

The handler responds to the following GET routes. All paths are relative to basePath.

RouteContent-TypeDescription
GET /text/htmlSelf-contained dashboard HTML page.
GET /api/introspectionapplication/jsonJSON metadata for all registered events and workflows.
GET /api/events/:typeapplication/jsonPer-event metrics (received, completed, failed counts).

Any other path returns 404 Not Found. Non-GET methods return 405 Method Not Allowed.


DashboardOptions

type DashboardOptions = {
basePath?: string;
};
PropertyTypeDefaultDescription
basePathstring"/"The URL prefix where the handler is mounted. Used to strip the prefix before matching internal routes.

getDashboardHtml()

Returns the raw HTML string for the dashboard. Useful if you need to serve the page through a custom mechanism instead of using createDashboardHandler.

function getDashboardHtml(): string;