Integrations
NestJS
Use Silgi as a NestJS controller — Express or Fastify under the hood.
Register Silgi as a NestJS controller. Works with both Express and Fastify adapters.
Setup
// rpc.controller.ts
import { , , , } from '@nestjs/common'
import { } from 'silgi/nestjs'
import { } from './rpc'
const = (, {
: () => ({ : getDB(), : .user }),
})
@('rpc')
export class {
@('*')
async (@() : Request, @() : Response) {
return (, )
}
}Procedures are accessible at:
POST /rpc/users/list
POST /rpc/users/createContext from NestJS
The context factory receives the Express/Fastify request. Access guards, pipes, and other NestJS features through the request:
silgiNestHandler(appRouter, {
: () => ({
: .user, // from NestJS AuthGuard
: .ip,
: .headers,
}),
})NestJS's own dependency injection, guards, and interceptors run before the Silgi handler. You can use @UseGuards(),
@UseInterceptors(), etc. alongside Silgi.
What's next?
- Express — if you don't need NestJS's DI
- Integrations — other available integrations