Fastify Integration
Register the REST API and dashboard as Fastify plugins.
Register the REST API and dashboard as Fastify plugins.
Peer dependency: fastify. Import from the @byteveda/flexiq/contrib/fastify
subpath.
import Fastify from "fastify";
import {
flexiqFastify,
flexiqDashboardPlugin,
} from "@byteveda/flexiq/contrib/fastify";
const app = Fastify();
// REST API
await app.register(flexiqFastify, { queue, prefix: "/tasks" });
// Dashboard SPA
await app.register(flexiqDashboardPlugin, { queue, prefix: "/admin" });
await app.listen({ port: 3000 });flexiqFastify is a FastifyPluginAsync. It exposes the same twelve routes as
the Express router — including
the /health and /readiness probes — mounted under prefix.
The same includeRoutes, excludeRoutes, and resultTimeoutMs options are
accepted, passed in the register options object alongside queue:
await app.register(flexiqFastify, {
queue,
prefix: "/tasks",
excludeRoutes: ["enqueue"], // read-only API
resultTimeoutMs: 10_000,
});flexiqDashboardPlugin accepts queue, prefix, and an optional staticDir:
await app.register(flexiqDashboardPlugin, {
queue,
prefix: "/admin",
staticDir: "/app/dashboard-assets",
});