mirror of
https://github.com/swissmakers/swiss-datashare.git
synced 2026-04-19 13:33:13 +02:00
feat: remove appwrite and add nextjs backend
This commit is contained in:
18
backend/src/share/dto/createShare.dto.ts
Normal file
18
backend/src/share/dto/createShare.dto.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import { Type } from "class-transformer";
|
||||
import { IsString, Matches, ValidateNested } from "class-validator";
|
||||
import { ShareSecurityDTO } from "./shareSecurity.dto";
|
||||
|
||||
export class CreateShareDTO {
|
||||
@IsString()
|
||||
@Matches("^[a-zA-Z0-9_-]*$", undefined, {
|
||||
message: "ID only can contain letters, numbers, underscores and hyphens",
|
||||
})
|
||||
id: string;
|
||||
|
||||
@IsString()
|
||||
expiration: string;
|
||||
|
||||
@ValidateNested()
|
||||
@Type(() => ShareSecurityDTO)
|
||||
security: ShareSecurityDTO;
|
||||
}
|
||||
20
backend/src/share/dto/myShare.dto.ts
Normal file
20
backend/src/share/dto/myShare.dto.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import { Expose, plainToClass } from "class-transformer";
|
||||
import { ShareDTO } from "./share.dto";
|
||||
|
||||
export class MyShareDTO extends ShareDTO {
|
||||
@Expose()
|
||||
views: number;
|
||||
|
||||
@Expose()
|
||||
createdAt: Date;
|
||||
|
||||
from(partial: Partial<MyShareDTO>) {
|
||||
return plainToClass(MyShareDTO, partial, { excludeExtraneousValues: true });
|
||||
}
|
||||
|
||||
fromList(partial: Partial<MyShareDTO>[]) {
|
||||
return partial.map((part) =>
|
||||
plainToClass(MyShareDTO, part, { excludeExtraneousValues: true })
|
||||
);
|
||||
}
|
||||
}
|
||||
29
backend/src/share/dto/share.dto.ts
Normal file
29
backend/src/share/dto/share.dto.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import { Expose, plainToClass, Type } from "class-transformer";
|
||||
import { AuthDTO } from "src/auth/dto/auth.dto";
|
||||
import { FileDTO } from "src/file/dto/file.dto";
|
||||
|
||||
export class ShareDTO {
|
||||
@Expose()
|
||||
id: string;
|
||||
|
||||
@Expose()
|
||||
expiration: Date;
|
||||
|
||||
@Expose()
|
||||
@Type(() => FileDTO)
|
||||
files: FileDTO[];
|
||||
|
||||
@Expose()
|
||||
@Type(() => AuthDTO)
|
||||
creator: AuthDTO;
|
||||
|
||||
from(partial: Partial<ShareDTO>) {
|
||||
return plainToClass(ShareDTO, partial, { excludeExtraneousValues: true });
|
||||
}
|
||||
|
||||
fromList(partial: Partial<ShareDTO>[]) {
|
||||
return partial.map((part) =>
|
||||
plainToClass(ShareDTO, part, { excludeExtraneousValues: true })
|
||||
);
|
||||
}
|
||||
}
|
||||
15
backend/src/share/dto/shareMetaData.dto.ts
Normal file
15
backend/src/share/dto/shareMetaData.dto.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import { Expose, plainToClass } from "class-transformer";
|
||||
|
||||
export class ShareMetaDataDTO {
|
||||
@Expose()
|
||||
id: string;
|
||||
|
||||
@Expose()
|
||||
isZipReady: boolean;
|
||||
|
||||
from(partial: Partial<ShareMetaDataDTO>) {
|
||||
return plainToClass(ShareMetaDataDTO, partial, {
|
||||
excludeExtraneousValues: true,
|
||||
});
|
||||
}
|
||||
}
|
||||
6
backend/src/share/dto/sharePassword.dto.ts
Normal file
6
backend/src/share/dto/sharePassword.dto.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
import { IsNotEmpty } from "class-validator";
|
||||
|
||||
export class SharePasswordDto {
|
||||
@IsNotEmpty()
|
||||
password: string;
|
||||
}
|
||||
12
backend/src/share/dto/shareSecurity.dto.ts
Normal file
12
backend/src/share/dto/shareSecurity.dto.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
import { IsNumber, IsOptional, IsString, Length } from "class-validator";
|
||||
|
||||
export class ShareSecurityDTO {
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
@Length(3, 30)
|
||||
password: string;
|
||||
|
||||
@IsNumber()
|
||||
@IsOptional()
|
||||
maxViews: number;
|
||||
}
|
||||
Reference in New Issue
Block a user