NestJS Setup

Set up the NestJS module, global exception capture, request-scoped metadata, and method-level decorators.

Use @errova/sdk-nestjs when you want a Nest-native integration that initializes once, registers global capture hooks, and still lets you call the core SDK APIs directly from services.

Bash
npm install @errova/sdk-nestjs

1. Import the Module in Your Root App Module

TypeScript
import "reflect-metadata"
import { Module } from "@nestjs/common"
import { NestFactory } from "@nestjs/core"
import { ErrovaNestJsModule } from "@errova/sdk-nestjs"
@Module({
imports: [
ErrovaNestJsModule.forRoot({
dsn: process.env.ERROVA_DSN ?? "",
dsnSecret: process.env.ERROVA_DSN_SECRET,
environment: process.env.NODE_ENV,
release: process.env.APP_VERSION,
}),
],
})
export class AppModule {}
async function bootstrap() {
const app = await NestFactory.create(AppModule)
app.enableShutdownHooks()
await app.listen(process.env.PORT ?? 3000)
}
void bootstrap()

2. Add Method-Level Capture Where It Helps

TypeScript
import { Injectable } from "@nestjs/common"
import { CaptureErrors } from "@errova/sdk-nestjs"
@Injectable()
export class PaymentsService {
@CaptureErrors({
tags: {
feature: "payments",
},
})
async createCharge(): Promise<void> {
throw new Error("Charge failed")
}
}

Important Notes

  • The module initializes the SDK, registers a global exception filter, adds request-scope interception, and closes the SDK during shutdown.
  • Call app.enableShutdownHooks() so the SDK can flush and close cleanly on process signals.
  • Use forRootAsync() if configuration comes from @nestjs/config or a secret provider.
  • This package is beta tier. Validate your HTTP error flow and bootstrap path before rollout.