mirror of
https://github.com/immich-app/immich
synced 2025-11-14 17:36:12 +00:00
refactor(server): logger (#9472)
This commit is contained in:
parent
b1ca5455b5
commit
46868b3336
7 changed files with 46 additions and 43 deletions
|
|
@ -4,6 +4,7 @@ import {
|
|||
Get,
|
||||
HttpCode,
|
||||
HttpStatus,
|
||||
Inject,
|
||||
Next,
|
||||
Param,
|
||||
ParseFilePipe,
|
||||
|
|
@ -30,6 +31,7 @@ import {
|
|||
ServeFileDto,
|
||||
} from 'src/dtos/asset-v1.dto';
|
||||
import { AuthDto, ImmichHeader } from 'src/dtos/auth.dto';
|
||||
import { ILoggerRepository } from 'src/interfaces/logger.interface';
|
||||
import { AssetUploadInterceptor } from 'src/middleware/asset-upload.interceptor';
|
||||
import { Auth, Authenticated, FileResponse } from 'src/middleware/auth.guard';
|
||||
import { FileUploadInterceptor, ImmichFile, Route, mapToUploadFile } from 'src/middleware/file-upload.interceptor';
|
||||
|
|
@ -46,7 +48,10 @@ interface UploadFiles {
|
|||
@ApiTags('Asset')
|
||||
@Controller(Route.ASSET)
|
||||
export class AssetControllerV1 {
|
||||
constructor(private service: AssetServiceV1) {}
|
||||
constructor(
|
||||
private service: AssetServiceV1,
|
||||
@Inject(ILoggerRepository) private logger: ILoggerRepository,
|
||||
) {}
|
||||
|
||||
@Post('upload')
|
||||
@UseInterceptors(AssetUploadInterceptor, FileUploadInterceptor)
|
||||
|
|
@ -95,7 +100,7 @@ export class AssetControllerV1 {
|
|||
@Param() { id }: UUIDParamDto,
|
||||
@Query() dto: ServeFileDto,
|
||||
) {
|
||||
await sendFile(res, next, () => this.service.serveFile(auth, id, dto));
|
||||
await sendFile(res, next, () => this.service.serveFile(auth, id, dto), this.logger);
|
||||
}
|
||||
|
||||
@Get('/thumbnail/:id')
|
||||
|
|
@ -108,7 +113,7 @@ export class AssetControllerV1 {
|
|||
@Param() { id }: UUIDParamDto,
|
||||
@Query() dto: GetAssetThumbnailDto,
|
||||
) {
|
||||
await sendFile(res, next, () => this.service.serveThumbnail(auth, id, dto));
|
||||
await sendFile(res, next, () => this.service.serveThumbnail(auth, id, dto), this.logger);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1,9 +1,10 @@
|
|||
import { Body, Controller, HttpCode, HttpStatus, Next, Param, Post, Res, StreamableFile } from '@nestjs/common';
|
||||
import { Body, Controller, HttpCode, HttpStatus, Inject, Next, Param, Post, Res, StreamableFile } from '@nestjs/common';
|
||||
import { ApiTags } from '@nestjs/swagger';
|
||||
import { NextFunction, Response } from 'express';
|
||||
import { AssetIdsDto } from 'src/dtos/asset.dto';
|
||||
import { AuthDto } from 'src/dtos/auth.dto';
|
||||
import { DownloadInfoDto, DownloadResponseDto } from 'src/dtos/download.dto';
|
||||
import { ILoggerRepository } from 'src/interfaces/logger.interface';
|
||||
import { Auth, Authenticated, FileResponse } from 'src/middleware/auth.guard';
|
||||
import { DownloadService } from 'src/services/download.service';
|
||||
import { asStreamableFile, sendFile } from 'src/utils/file';
|
||||
|
|
@ -12,7 +13,10 @@ import { UUIDParamDto } from 'src/validation';
|
|||
@ApiTags('Download')
|
||||
@Controller('download')
|
||||
export class DownloadController {
|
||||
constructor(private service: DownloadService) {}
|
||||
constructor(
|
||||
private service: DownloadService,
|
||||
@Inject(ILoggerRepository) private logger: ILoggerRepository,
|
||||
) {}
|
||||
|
||||
@Post('info')
|
||||
@Authenticated({ sharedLink: true })
|
||||
|
|
@ -38,6 +42,6 @@ export class DownloadController {
|
|||
@Auth() auth: AuthDto,
|
||||
@Param() { id }: UUIDParamDto,
|
||||
) {
|
||||
await sendFile(res, next, () => this.service.downloadFile(auth, id));
|
||||
await sendFile(res, next, () => this.service.downloadFile(auth, id), this.logger);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { Body, Controller, Get, Next, Param, Post, Put, Query, Res } from '@nestjs/common';
|
||||
import { Body, Controller, Get, Inject, Next, Param, Post, Put, Query, Res } from '@nestjs/common';
|
||||
import { ApiTags } from '@nestjs/swagger';
|
||||
import { NextFunction, Response } from 'express';
|
||||
import { BulkIdResponseDto } from 'src/dtos/asset-ids.response.dto';
|
||||
|
|
@ -15,6 +15,7 @@ import {
|
|||
PersonStatisticsResponseDto,
|
||||
PersonUpdateDto,
|
||||
} from 'src/dtos/person.dto';
|
||||
import { ILoggerRepository } from 'src/interfaces/logger.interface';
|
||||
import { Auth, Authenticated, FileResponse } from 'src/middleware/auth.guard';
|
||||
import { PersonService } from 'src/services/person.service';
|
||||
import { sendFile } from 'src/utils/file';
|
||||
|
|
@ -23,7 +24,10 @@ import { UUIDParamDto } from 'src/validation';
|
|||
@ApiTags('Person')
|
||||
@Controller('person')
|
||||
export class PersonController {
|
||||
constructor(private service: PersonService) {}
|
||||
constructor(
|
||||
private service: PersonService,
|
||||
@Inject(ILoggerRepository) private logger: ILoggerRepository,
|
||||
) {}
|
||||
|
||||
@Get()
|
||||
@Authenticated()
|
||||
|
|
@ -74,7 +78,7 @@ export class PersonController {
|
|||
@Auth() auth: AuthDto,
|
||||
@Param() { id }: UUIDParamDto,
|
||||
) {
|
||||
await sendFile(res, next, () => this.service.getThumbnail(auth, id));
|
||||
await sendFile(res, next, () => this.service.getThumbnail(auth, id), this.logger);
|
||||
}
|
||||
|
||||
@Get(':id/assets')
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import {
|
|||
Get,
|
||||
HttpCode,
|
||||
HttpStatus,
|
||||
Inject,
|
||||
Next,
|
||||
Param,
|
||||
Post,
|
||||
|
|
@ -19,6 +20,7 @@ import { NextFunction, Response } from 'express';
|
|||
import { AuthDto } from 'src/dtos/auth.dto';
|
||||
import { CreateProfileImageDto, CreateProfileImageResponseDto } from 'src/dtos/user-profile.dto';
|
||||
import { CreateUserDto, DeleteUserDto, UpdateUserDto, UserResponseDto } from 'src/dtos/user.dto';
|
||||
import { ILoggerRepository } from 'src/interfaces/logger.interface';
|
||||
import { Auth, Authenticated, FileResponse } from 'src/middleware/auth.guard';
|
||||
import { FileUploadInterceptor, Route } from 'src/middleware/file-upload.interceptor';
|
||||
import { UserService } from 'src/services/user.service';
|
||||
|
|
@ -28,7 +30,10 @@ import { UUIDParamDto } from 'src/validation';
|
|||
@ApiTags('User')
|
||||
@Controller(Route.USER)
|
||||
export class UserController {
|
||||
constructor(private service: UserService) {}
|
||||
constructor(
|
||||
private service: UserService,
|
||||
@Inject(ILoggerRepository) private logger: ILoggerRepository,
|
||||
) {}
|
||||
|
||||
@Get()
|
||||
@Authenticated()
|
||||
|
|
@ -100,6 +105,6 @@ export class UserController {
|
|||
@FileResponse()
|
||||
@Authenticated()
|
||||
async getProfileImage(@Res() res: Response, @Next() next: NextFunction, @Param() { id }: UUIDParamDto) {
|
||||
await sendFile(res, next, () => this.service.getProfileImage(id));
|
||||
await sendFile(res, next, () => this.service.getProfileImage(id), this.logger);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue