NestJS
Wire Restaq into a NestJS controller.
NestJS support ships with restaq — no separate package, just import from the restaq/nestjs subpath. toNestJsHandler adapts your Relay instance to a controller method that takes @Req() and @Res().
Setup
import { Controller, Post, Req, Res } from '@nestjs/common';
import { toNestJsHandler, type NestJsRelayRequest, type NestJsRelayResponse } from 'restaq/nestjs';
import { restaq } from './relay';
@Controller('api/webhook')
export class RelayController {
private readonly handler = toNestJsHandler(restaq);
@Post(':provider')
post(@Req() req: NestJsRelayRequest, @Res() res: NestJsRelayResponse) {
return this.handler(req, res);
}
}This one controller serves every plugin you register, at /api/webhook/<provider> (e.g. /api/webhook/stripe).
NestJsRelayRequest and NestJsRelayResponse are the Node request/response shapes toNestJsHandler expects — the Fetch API's global Request/Response types won't fit here.
Raw body requirement
Provider signatures are verified against the exact raw request body. In Express-backed Nest apps, mount this route before JSON body parsing, or scope raw body access to it directly.
Custom param name
If your route uses a different parameter name, pass it explicitly:
private readonly handler = toNestJsHandler(restaq, { paramName: 'source' });