@worker-manager/fastify
v2.5.0
Published
A Fastify.js server adapter for the Worker Manager dashboard.
Maintainers
Readme
@worker-manager/fastify
Fastify.js server adapter for Worker Manager.

Usage examples
Authentication
@worker-manager/auth protects the board
with Basic auth, a Keycloak (OIDC) login, static tokens with a login form, or your own check. Wrap the board plugin so the hook is scoped to the
board's routes only:
import { createAuthMiddleware, createFastifyAuthPlugin } from '@worker-manager/auth';
const auth = createAuthMiddleware(
{ strategy: 'basic', users: [{ username: 'admin', password: process.env.BOARD_PASSWORD }] },
// or { strategy: 'keycloak', url, realm, clientId, clientSecret, requiredRoles, cookie: { secret } }
// or { strategy: 'token', tokens: [process.env.BOARD_TOKEN], cookie: { secret } }
// or { strategy: 'custom', authenticate: (req) => user | null }
{ basePath: '/ui' }
);
serverAdapter.setBasePath('/ui');
app.register(createFastifyAuthPlugin(serverAdapter.registerPlugin(), auth), { prefix: '/ui' });Every board route (page, API, assets) then needs credentials, and GET /ui/auth/me returns the
signed-in user.
Testing with Jest
@fastify/static 10.1.4 and later depend on content-disposition@3, which is ESM only, so a
CommonJS Jest suite fails with Must use import to load ES Module when it loads this adapter. This
package accepts @fastify/static ^9.0.0 || ^10.0.0: an app that already depends on
@fastify/static@9 gets that one copy, which loads fine. Otherwise see the
troubleshooting recipe
for a two-line Jest transform.
For more info visit the main README
