Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
this.loggerService.debug('debug');
this.loggerService.info('info');
this.loggerService.silly('silly');
}
@Get('/exception/custom')
public async exceptionCustom() {
throw new UserBlockedException();
}
@Get('/exception/sentry')
public async exceptionSentry() {
throw new HttpException('Should be cached by sentry', HttpStatus.INTERNAL_SERVER_ERROR);
}
@UseInterceptors(RavenInterceptor({
filters: [
{ type: HttpException, filter: (exception: HttpException) => 500 > exception.getStatus() },
],
tags: {
tryingOut: 'ravenInterceptor',
},
level: 'warning',
}))
@Get('/exception/http')
public async exceptionHttp() {
throw new Error('some error');
// throw new BadRequestException({ message: 'this should be', with: ['an', 'array'] });
}
@Post('/upload')
@UseInterceptors(StorageInterceptor('file', STORAGE_TYPE.DISK))
AuthenticationModule, // Required for AuthMiddleware
// Init TypeOrm
TypeOrmModule.forRoot(),
// Init Router
RouterModule.forRoutes(appRoutes),
// Init Raven
RavenModule.forRoot(),
UserModule,
DemoModule,
],
providers: [
{
provide: APP_INTERCEPTOR,
useClass: RavenInterceptor({
filters: [{
type: HttpException, filter: (exception: HttpException) => 500 > exception.getStatus(),
}],
}),
},
],
})
export class ApplicationModule implements NestModule {
public configure(consumer: MiddlewareConsumer): void {
// We apply AuthMiddleware globally and then set access right with guards.
consumer.apply(AuthMiddleware)
.forRoutes('*');
}
}
import { Controller, Get, UseInterceptors } from '@nestjs/common';
import { AppService } from './app.service';
import { RavenInterceptor } from 'nest-raven';
@Controller()
@UseInterceptors(new RavenInterceptor())
export class AppController {
constructor(private readonly appService: AppService) {}
@Get()
getHello(): string {
return this.appService.getHello();
}
}