Files
pingvin-share/backend/src/share/dto/share.dto.ts
Elias Schneider b717663b5c feat: add name property to share (#462)
* add name property to share

* refactor: run formatter

* tests: adapt system tests

* tests: adapt second system test
2024-05-03 17:12:26 +02:00

42 lines
796 B
TypeScript

import { Expose, plainToClass, Type } from "class-transformer";
import { FileDTO } from "src/file/dto/file.dto";
import { PublicUserDTO } from "src/user/dto/publicUser.dto";
export class ShareDTO {
@Expose()
id: string;
@Expose()
name?: string;
@Expose()
expiration: Date;
@Expose()
@Type(() => FileDTO)
files: FileDTO[];
@Expose()
@Type(() => PublicUserDTO)
creator: PublicUserDTO;
@Expose()
description: string;
@Expose()
hasPassword: boolean;
@Expose()
size: number;
from(partial: Partial<ShareDTO>) {
return plainToClass(ShareDTO, partial, { excludeExtraneousValues: true });
}
fromList(partial: Partial<ShareDTO>[]) {
return partial.map((part) =>
plainToClass(ShareDTO, part, { excludeExtraneousValues: true }),
);
}
}