Reference
NestJS
Reference for @tailrace/nestjs - TailraceModule, TailraceMiddleware, and TailraceNestOptions.
@tailrace/nestjs provides TailraceModule.forRoot and TailraceMiddleware for NestJS. Primary CI target: Nest + Express adapter.
Install
pnpm add @tailrace/core @tailrace/nestjs @nestjs/common @nestjs/core reflect-metadataPeer dependency: @nestjs/common >=10. Depends on @tailrace/core + @tailrace/http.
Exports
| Export | Description |
|---|---|
TailraceModule | forRoot(options) Nest dynamic module |
TailraceMiddleware | Nest middleware implementing openai-compat |
TailraceNestOptions | Options type |
TAILRACE_NEST_OPTIONS | Injection token for module options |
Options
| Option | Default | Notes |
|---|---|---|
tailrace | required | Tailrace instance |
mode | "openai-compatible" | Only mode in v0.1 |
agent | "default" | (req) => string (Express Request) |
workflowId | "default" | string or (req) => string |
onDecision | - | Audit callback |
forRoutes | {*path} | Paths for MiddlewareConsumer.forRoutes. Prefer v1/*path (Nest 11) |
For Nest + Fastify, register @tailrace/fastify on the underlying Fastify instance.
Block shape
422 JSON { error: { type: "policy_violation", entity, rule } }. SSE: one data: error event then close (abort-equivalent only). Maps from PolicyViolationError.