1
0
mirror of https://github.com/immich-app/immich.git synced 2025-12-09 02:16:43 +02:00

feat: use ILoggerRepository (#8855)

* Migrate ImmichLogger over to injected ILoggerRepository

* chore: cleanup and tests

---------

Co-authored-by: Jason Rasmussen <jrasm91@gmail.com>
This commit is contained in:
AmAn Sharma
2024-04-17 03:00:31 +05:30
committed by GitHub
parent 877207a2e6
commit 6e6deec40c
59 changed files with 352 additions and 191 deletions

View File

@@ -1,4 +1,4 @@
import { CallHandler, ExecutionContext, Injectable, NestInterceptor } from '@nestjs/common';
import { CallHandler, ExecutionContext, Inject, Injectable, NestInterceptor } from '@nestjs/common';
import { PATH_METADATA } from '@nestjs/common/constants';
import { Reflector } from '@nestjs/core';
import { transformException } from '@nestjs/platform-express/multer/multer/multer.utils';
@@ -7,9 +7,9 @@ import multer, { StorageEngine, diskStorage } from 'multer';
import { createHash, randomUUID } from 'node:crypto';
import { Observable } from 'rxjs';
import { UploadFieldName } from 'src/dtos/asset.dto';
import { ILoggerRepository } from 'src/interfaces/logger.interface';
import { AuthRequest } from 'src/middleware/auth.guard';
import { AssetService, UploadFile } from 'src/services/asset.service';
import { ImmichLogger } from 'src/utils/logger';
export enum Route {
ASSET = 'asset',
@@ -59,8 +59,6 @@ const asRequest = (request: AuthRequest, file: Express.Multer.File) => {
@Injectable()
export class FileUploadInterceptor implements NestInterceptor {
private logger = new ImmichLogger(FileUploadInterceptor.name);
private handlers: {
userProfile: RequestHandler;
assetUpload: RequestHandler;
@@ -70,7 +68,10 @@ export class FileUploadInterceptor implements NestInterceptor {
constructor(
private reflect: Reflector,
private assetService: AssetService,
@Inject(ILoggerRepository) private logger: ILoggerRepository,
) {
this.logger.setContext(FileUploadInterceptor.name);
this.defaultStorage = diskStorage({
filename: this.filename.bind(this),
destination: this.destination.bind(this),