@dunx/dashboard
v3.2.1
Published
An opt-in operations page for a running dunx app: routes, the provider graph, gateways, config and runtime health, with bull-board mounted for the queues
Maintainers
Readme
@dunx/dashboard
One page over a running dunx app: the routes it serves, the container it built, the gateways it upgrades, Redis, the config keys and the process itself, with bull-board mounted for the queues.
Every panel reads data dunx already computes, so the page is cheap.
Install
bun add @dunx/dashboard
# for the queues page
bun add @bull-board/api @bull-board/ui @bull-board/bunUsage
import { DashboardMiddleware, DashboardModule } from '@dunx/dashboard';
import { JobPublisher } from '@dunx/infra/queue';
import { RedisConnection } from '@dunx/infra/redis';
@Module({
imports: [
DashboardModule.forRootAsync({
imports: [JobsModule, CacheModule],
inject: [JobPublisher, RedisConnection],
useFactory: (queues: JobPublisher, redis: RedisConnection) => ({
path: '/api/_dunx',
queues,
redis,
authorize: (req) => isOperator(req),
}),
}),
],
})
export class OpsModule {}
const app = await HttpFactory.create(AppModule);
app.use(DashboardMiddleware); // first, ahead of any session guardThe panels
Seven panels, each with a JSON sibling under {path}/api/*, so curl is a real
way to read this on a box with no browser. The queues page is bull-board's.
| Panel | Shows |
| --------- | ------------------------------------------------------------ |
| Routes | Every route, its guards and metadata, linked to /docs |
| Providers | The container graph, by module |
| Gateways | Every WebSocket gateway and its events |
| Redis | Connection state and INFO |
| Config | Keys always, values only where reveal says so |
| Runtime | The process, its memory and its probes |
| Stats | Per-route request timings and per-operation query timings |
Three things that are decisions
authorizehas no default. Leaving it out serves the page to anyone who can reach the port. Omitting it logs a warning naming the mount at boot.- A rejected request gets 404, not 403. Register the middleware ahead of
any session guard: a guard running first answers 401 and tells a prober the
mount exists.
authorizetakes the rawRequestso it can be self-sufficient. - Config values are redacted by default.
revealis an opt-in allow-list; a deny-list of the usual suspects leaks the first key nobody thought of.
Notes
QueueSourceandRedisProberestate structurally whatJobPublisherandRedisConnectionalready are, soqueues: publisheris the whole wiring. It depends on neither@dunx/infranorbullmq.- The board is built on the first request for the queues page, never at boot, so an app that never opens it holds no broker socket.
commands: falsemaps onto bull-board's ownreadOnlyMode.
License
MIT
