Skip to content

📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!

add dto

kruzhambus45480d7d2c22
diff --git a/apps/production/src/project/dto/project-password.dto.ts b/apps/production/src/project/dto/project-password.dto.ts
new file mode 100644
index 000000000..861ef7704
--- /dev/null
+++ b/apps/production/src/project/dto/project-password.dto.ts
@@ -0,0 +1,18 @@
+import { IsOptional, Matches, ValidateIf } from 'class-validator'
+
+export class ProjectPasswordDto {
+ @IsOptional()
+ @ValidateIf(o => o.password !== null)
+ @Matches(
+ /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[!@#$%^&*])[a-zA-Z\d!@#$%^&*]{8,72}$/,
+ {
+ message:
+ 'Password must contain at least 8 characters, one uppercase, one lowercase, one number and one special character (!@#$%^&*).',
+ },
+ )
+ password?: string | null
+
+ @IsOptional()
+ @ValidateIf(o => o.isPasswordProtected !== null)
+ isPasswordProtected?: boolean | null
+}
diff --git a/apps/production/src/project/dto/update-project.dto.ts b/apps/production/src/project/dto/update-project.dto.ts
new file mode 100644
index 000000000..2b3ada91f
--- /dev/null
+++ b/apps/production/src/project/dto/update-project.dto.ts
@@ -0,0 +1,16 @@
+import { IntersectionType, PickType } from '@nestjs/mapped-types'
+import { ProjectDTO } from './project.dto'
+import { ProjectPasswordDto } from './project-password.dto'
+
+export class UpdateProjectDto extends IntersectionType(
+ PickType(ProjectDTO, [
+ 'id',
+ 'name',
+ 'origins',
+ 'ipBlacklist',
+ 'active',
+ 'public',
+ 'isCaptcha',
+ ] as const),
+ ProjectPasswordDto,
+) {}
\ No newline at end of file