@monque/management-express
v0.2.1
Published
Express adapter for the Monque management surface
Downloads
405
Maintainers
Readme
@monque/management-express
Express adapter for the Monque Management Surface.
@monque/management-express is a thin framework adapter. It mounts the oRPC OpenAPI HTTP
handler from @monque/management, passes Express-derived request context into Management
hooks, and serves the generated OpenAPI JSON for the mounted API. It does not define
Management routes, schemas, operation IDs, capabilities, authentication, Scalar, or
Dashboard assets.
Installation
bun add @monque/management-express @monque/management @monque/core express@monque/core, @monque/management, express, and mongodb are peer dependencies.
Usage
import { Monque } from '@monque/core';
import { createManagementExpressRouter } from '@monque/management-express';
import express from 'express';
import { MongoClient } from 'mongodb';
const app = express();
const client = new MongoClient('mongodb://localhost:27017');
await client.connect();
const monque = new Monque(client.db('monque'));
app.use(
'/monque',
requireOperator,
createManagementExpressRouter({
monque,
context: ({ req }) => ({
userId: req.get('x-user-id') ?? 'anonymous',
}),
authorize: ({ action, context }) => {
return context.userId !== 'anonymous' || action === 'read';
},
}),
);If mounted at /monque, Management API routes are served under /monque/api/v1/*.
Authentication stays in the host Express app; mount auth middleware before the router.
OpenAPI
OpenAPI JSON is served at /openapi.json relative to the mount path by default:
/monque/openapi.jsonThe document is generated by @monque/management. The Express adapter only adds
mount-specific metadata such as servers.
app.use(
'/internal/management',
createManagementExpressRouter({
monque,
openApi: {
path: '/docs/openapi.json',
serverUrl: 'https://ops.example.com/internal/management',
},
}),
);Set openApi: false if the host application should expose the document manually.
Scalar is intentionally not a dependency; API reference UI can be composed separately from
the served OpenAPI URL.
