Skip to content

Instantly share code, notes, and snippets.

View mantosz's full-sized avatar

Luqman Marzuki mantosz

View GitHub Profile
@mantosz
mantosz / app.controller.ts
Created November 29, 2019 05:18
Test Sentry interceptor by throwing error
import { Controller, Get, UseInterceptors, InternalServerErrorException } from '@nestjs/common';
import { AppService } from './app.service';
import { SentryInterceptor } from './sentry.interceptor';
@UseInterceptors(SentryInterceptor)
@Controller()
export class AppController {
constructor(private readonly appService: AppService) {}
@Get()
@mantosz
mantosz / app.controller.ts
Created November 29, 2019 05:06
Sentry interceptor in controller file
import { Controller, Get, UseInterceptors } from '@nestjs/common';
import { AppService } from './app.service';
import { SentryInterceptor } from './sentry.interceptor';
@UseInterceptors(SentryInterceptor)
@Controller()
export class AppController {
constructor(private readonly appService: AppService) {}
@Get()
@mantosz
mantosz / sentry.interceptor.ts
Created November 29, 2019 04:56
NestJS interceptor file for Sentry logging
import {
ExecutionContext,
Injectable,
NestInterceptor,
CallHandler,
} from '@nestjs/common';
import { Observable } from 'rxjs';
import { tap } from 'rxjs/operators';
import * as Sentry from '@sentry/minimal';
@mantosz
mantosz / main.ts
Last active May 13, 2022 04:18
Sentry init in NestJS
import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
import * as Sentry from '@sentry/node';
async function bootstrap() {
const app = await NestFactory.create(AppModule);
Sentry.init({
dsn: 'https://4e98de50242247eebc5512b55bc558a3@sentry.io/1837145',
});
await app.listen(3000);