refactor(v4.0.0-alpha): beginning of a new era

This commit is contained in:
Amruth Pillai
2023-11-05 12:31:42 +01:00
parent 0ba6a444e2
commit 22933bd412
505 changed files with 81829 additions and 0 deletions
+2
View File
@@ -0,0 +1,2 @@
export * from "./update-user";
export * from "./user";
+13
View File
@@ -0,0 +1,13 @@
import { createZodDto } from "nestjs-zod/dto";
import { userSchema } from "./user";
export const updateUserSchema = userSchema.partial().pick({
name: true,
language: true,
username: true,
email: true,
picture: true,
});
export class UpdateUserDto extends createZodDto(updateUserSchema) {}
+31
View File
@@ -0,0 +1,31 @@
import type { Prisma } from "@prisma/client";
import { idSchema } from "@reactive-resume/schema";
import { createZodDto } from "nestjs-zod/dto";
import { z } from "nestjs-zod/z";
export const usernameSchema = z
.string()
.min(3)
.max(255)
.regex(/^[a-z0-9._-]+$/, {
message:
"Usernames can only contain lowercase letters, numbers, periods, hyphens, and underscores.",
});
export const userSchema = z.object({
id: idSchema,
name: z.string().min(3).max(255),
picture: z.literal("").or(z.null()).or(z.string().url()),
username: usernameSchema,
email: z.string().email(),
language: z.string().default("en"),
emailVerified: z.boolean().default(false),
twoFactorEnabled: z.boolean().default(false),
provider: z.enum(["email", "github", "google"]).default("email"),
createdAt: z.date().or(z.dateString()),
updatedAt: z.date().or(z.dateString()),
});
export class UserDto extends createZodDto(userSchema) {}
export type UserWithSecrets = Prisma.UserGetPayload<{ include: { secrets: true } }>;