toExpressHandler turns your Corsair instance into Express middleware. That one route serves both Hub’s server-to-server delivery and the management API.
import { createCorsair } from 'corsair';
import { github } from '@corsair-dev/github';
export const corsair = createCorsair({
plugins: [github({ authType: 'managed' })],
database: db,
kek: process.env.CORSAIR_KEK!,
hub: {
projectApiKey: process.env.CORSAIR_DEV_API_KEY!,
signingSecret: process.env.CORSAIR_DEV_SIGNING_SECRET!,
},
});
Mount the route
import express from 'express';
import { toExpressHandler } from 'corsair';
import { corsair } from './corsair';
const app = express();
// Required: Hub delivers results as JSON POSTs. The adapter reads the parsed
// body, so express.json() must run before the Corsair route.
app.use(express.json());
app.use('/api/corsair', toExpressHandler(corsair, { basePath: '/api/corsair' }));
app.listen(3000);
Mount express.json() before the Corsair route. Without it, req.body is undefined and Hub’s delivery POSTs arrive empty — connects will look like they hang.
Run and go green
Start the server and hit it once. On the first request the app self-registers its delivery URL with Hub and the dashboard header dot turns green. If it stays grey, your route isn’t reachable at /api/corsair — check the mount path and Delivery URLs.