feat(server): correlation id via injected logger (#8823)

* feat(server): correlation id via injected logger

* feat: cid response header
This commit is contained in:
Jason Rasmussen 2024-04-15 19:39:06 -04:00 committed by GitHub
parent 95e67a7b1d
commit 2db76034b1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
16 changed files with 152 additions and 26 deletions

View file

@ -2,17 +2,20 @@ import {
CallHandler,
ExecutionContext,
HttpException,
Inject,
Injectable,
InternalServerErrorException,
NestInterceptor,
} from '@nestjs/common';
import { Observable, catchError, throwError } from 'rxjs';
import { ImmichLogger } from 'src/utils/logger';
import { ILoggerRepository } from 'src/interfaces/logger.interface';
import { isConnectionAborted, routeToErrorMessage } from 'src/utils/misc';
@Injectable()
export class ErrorInterceptor implements NestInterceptor {
private logger = new ImmichLogger(ErrorInterceptor.name);
constructor(@Inject(ILoggerRepository) private logger: ILoggerRepository) {
this.logger.setContext(ErrorInterceptor.name);
}
intercept(context: ExecutionContext, next: CallHandler<any>): Observable<any> {
return next.handle().pipe(