refactor(server): guards, decorators, and utils (#3060)

This commit is contained in:
Jason Rasmussen
2023-07-01 14:27:34 -04:00
committed by GitHub
parent f55b3add80
commit d69fa3ceae
54 changed files with 243 additions and 255 deletions

View File

@@ -15,12 +15,29 @@ import {
} from '@nestjs/swagger';
import { writeFileSync } from 'fs';
import path from 'path';
import { Metadata } from './decorators/authenticated.decorator';
import { applyDecorators, UsePipes, ValidationPipe } from '@nestjs/common';
import { Metadata } from './app.guard';
export function UseValidation() {
return applyDecorators(
UsePipes(
new ValidationPipe({
transform: true,
whitelist: true,
}),
),
);
}
export const asStreamableFile = ({ stream, type, length }: ImmichReadStream) => {
return new StreamableFile(stream, { type, length });
};
export function patchFormData(latin1: string) {
return Buffer.from(latin1, 'latin1').toString('utf8');
}
function sortKeys<T extends object>(obj: T): T {
if (!obj) {
return obj;