Frameworks
Express
Wire Restaq into an Express route.
Express support ships with restaq — no separate package, just import from the restaq/express subpath. toExpressHandler turns your Relay instance into a route handler.
Setup
import express from 'express';
import { toExpressHandler } from 'restaq/express';
import { restaq } from './relay';
const app = express();
app.post('/api/webhook/:provider', toExpressHandler(restaq));
app.listen(3000);This one route serves every plugin you register, at /api/webhook/<provider> (e.g. /api/webhook/stripe).
Raw body requirement
Provider signatures are verified against the exact raw request body. Mount this route before any JSON body-parsing middleware, or scope raw parsing to it directly:
app.post(
'/api/webhook/:provider',
express.raw({ type: 'application/json' }),
toExpressHandler(restaq),
);Custom param name
If your route uses a different parameter name, pass it explicitly:
app.post('/webhooks/:source', toExpressHandler(restaq, { paramName: 'source' }));