mirror of
https://github.com/immich-app/immich
synced 2025-10-17 18:19:27 +00:00
refactor(server): cls (#13814)
This commit is contained in:
parent
2efba6326d
commit
19eb3ed8b9
5 changed files with 31 additions and 21 deletions
|
|
@ -1,15 +1,12 @@
|
|||
import { ConfigModuleOptions } from '@nestjs/config';
|
||||
import { CronExpression } from '@nestjs/schedule';
|
||||
import { Request, Response } from 'express';
|
||||
import Joi, { Root } from 'joi';
|
||||
import { CLS_ID, ClsModuleOptions } from 'nestjs-cls';
|
||||
import {
|
||||
AudioCodec,
|
||||
Colorspace,
|
||||
CQMode,
|
||||
ImageFormat,
|
||||
ImmichEnvironment,
|
||||
ImmichHeader,
|
||||
LogLevel,
|
||||
ToneMapping,
|
||||
TranscodeHWAccel,
|
||||
|
|
@ -354,17 +351,3 @@ export const immichAppConfig: ConfigModuleOptions = {
|
|||
),
|
||||
}),
|
||||
};
|
||||
|
||||
export const clsConfig: ClsModuleOptions = {
|
||||
middleware: {
|
||||
mount: true,
|
||||
generateId: true,
|
||||
setup: (cls, req: Request, res: Response) => {
|
||||
const headerValues = req.headers[ImmichHeader.CID];
|
||||
const headerValue = Array.isArray(headerValues) ? headerValues[0] : headerValues;
|
||||
const cid = headerValue || cls.get(CLS_ID);
|
||||
cls.set(CLS_ID, cid);
|
||||
res.header(ImmichHeader.CID, cid);
|
||||
},
|
||||
},
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue