mirror of
https://github.com/AmruthPillai/Reactive-Resume.git
synced 2025-11-10 04:22:27 +10:00
Update ESLint configuration and schemas to use Zod library
- Changed ESLint configuration to target TypeScript files and added parser options for better integration. - Updated various schemas across the application to replace `nestjs-zod/z` imports with `zod` for consistency. - Refactored password validation in authentication schemas to use `z.string()` instead of `z.password()`. - Enhanced date handling in user and resume schemas by introducing a new `dateSchema` utility. - Updated `.ncurc.json` to target minor upgrades for dependencies.
This commit is contained in:
@ -12,6 +12,7 @@
|
||||
"@reactive-resume/utils": "*",
|
||||
"@reactive-resume/schema": "*",
|
||||
"nestjs-zod": "^3.0.0",
|
||||
"@swc/helpers": "~0.5.11"
|
||||
"@swc/helpers": "~0.5.11",
|
||||
"zod": "^3.24.1"
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { createZodDto } from "nestjs-zod/dto";
|
||||
import { z } from "nestjs-zod/z";
|
||||
import { z } from "zod";
|
||||
|
||||
export const forgotPasswordSchema = z.object({ email: z.string().email() });
|
||||
|
||||
|
||||
@ -1,12 +1,12 @@
|
||||
import { createZodDto } from "nestjs-zod/dto";
|
||||
import { z } from "nestjs-zod/z";
|
||||
import { z } from "zod";
|
||||
|
||||
import { usernameSchema } from "../user";
|
||||
|
||||
export const loginSchema = z
|
||||
.object({
|
||||
identifier: z.string().transform((value) => value.toLowerCase()),
|
||||
password: z.password().min(6),
|
||||
password: z.string().min(6),
|
||||
})
|
||||
.refine(
|
||||
(value) => {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { createZodDto } from "nestjs-zod/dto";
|
||||
import { z } from "nestjs-zod/z";
|
||||
import { z } from "zod";
|
||||
|
||||
export const messageSchema = z.object({ message: z.string() });
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { createZodDto } from "nestjs-zod/dto";
|
||||
import { z } from "nestjs-zod/z";
|
||||
import { z } from "zod";
|
||||
|
||||
const authProvidersSchema = z.array(z.enum(["email", "github", "google"]));
|
||||
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
import { createZodDto } from "nestjs-zod/dto";
|
||||
import { z } from "nestjs-zod/z";
|
||||
import { z } from "zod";
|
||||
|
||||
import { userSchema } from "../user";
|
||||
|
||||
export const registerSchema = userSchema
|
||||
.pick({ name: true, email: true, username: true, locale: true })
|
||||
.extend({ password: z.password().min(6) });
|
||||
.extend({ password: z.string().min(6) });
|
||||
|
||||
export class RegisterDto extends createZodDto(registerSchema) {}
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
import { createZodDto } from "nestjs-zod/dto";
|
||||
import { z } from "nestjs-zod/z";
|
||||
import { z } from "zod";
|
||||
|
||||
export const resetPasswordSchema = z.object({
|
||||
token: z.string(),
|
||||
password: z.password().min(6),
|
||||
password: z.string().min(6),
|
||||
});
|
||||
|
||||
export class ResetPasswordDto extends createZodDto(resetPasswordSchema) {}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { createZodDto } from "nestjs-zod/dto";
|
||||
import { z } from "nestjs-zod/z";
|
||||
import { z } from "zod";
|
||||
|
||||
import { userSchema } from "../user";
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { createZodDto } from "nestjs-zod/dto";
|
||||
import { z } from "nestjs-zod/z";
|
||||
import { z } from "zod";
|
||||
|
||||
export const twoFactorSchema = z.object({
|
||||
code: z
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { createZodDto } from "nestjs-zod/dto";
|
||||
import { z } from "nestjs-zod/z";
|
||||
import { z } from "zod";
|
||||
|
||||
export const updatePasswordSchema = z.object({
|
||||
password: z.string().min(6),
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { createZodDto } from "nestjs-zod/dto";
|
||||
import { z } from "nestjs-zod/z";
|
||||
import { z } from "zod";
|
||||
|
||||
export const contributorSchema = z.object({
|
||||
id: z.number(),
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { createZodDto } from "nestjs-zod/dto";
|
||||
import { z } from "nestjs-zod/z";
|
||||
import { z } from "zod";
|
||||
|
||||
export const featureSchema = z.object({
|
||||
isSignupsDisabled: z.boolean().default(false),
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { kebabCase } from "@reactive-resume/utils";
|
||||
import { createZodDto } from "nestjs-zod/dto";
|
||||
import { z } from "nestjs-zod/z";
|
||||
import { z } from "zod";
|
||||
|
||||
export const createResumeSchema = z.object({
|
||||
title: z.string().min(1),
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { idSchema } from "@reactive-resume/schema";
|
||||
import { createZodDto } from "nestjs-zod/dto";
|
||||
import { z } from "nestjs-zod/z";
|
||||
import { z } from "zod";
|
||||
|
||||
export const deleteResumeSchema = z.object({
|
||||
id: idSchema,
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import { resumeDataSchema } from "@reactive-resume/schema";
|
||||
import { kebabCase } from "@reactive-resume/utils";
|
||||
import { createZodDto } from "nestjs-zod/dto";
|
||||
import { z } from "nestjs-zod/z";
|
||||
import { z } from "zod";
|
||||
|
||||
export const importResumeSchema = z.object({
|
||||
title: z.string().optional(),
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
import { defaultResumeData, idSchema, resumeDataSchema } from "@reactive-resume/schema";
|
||||
import { dateSchema } from "@reactive-resume/utils";
|
||||
import { createZodDto } from "nestjs-zod/dto";
|
||||
import { z } from "nestjs-zod/z";
|
||||
import { z } from "zod";
|
||||
|
||||
import { userSchema } from "../user";
|
||||
|
||||
@ -13,8 +14,8 @@ export const resumeSchema = z.object({
|
||||
locked: z.boolean().default(false),
|
||||
userId: idSchema,
|
||||
user: userSchema.optional(),
|
||||
createdAt: z.date().or(z.dateString()),
|
||||
updatedAt: z.date().or(z.dateString()),
|
||||
createdAt: dateSchema,
|
||||
updatedAt: dateSchema,
|
||||
});
|
||||
|
||||
export class ResumeDto extends createZodDto(resumeSchema) {}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { createZodDto } from "nestjs-zod/dto";
|
||||
import { z } from "nestjs-zod/z";
|
||||
import { z } from "zod";
|
||||
|
||||
export const urlSchema = z.object({ url: z.string().url() });
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { idSchema } from "@reactive-resume/schema";
|
||||
import { z } from "nestjs-zod/z";
|
||||
import { z } from "zod";
|
||||
|
||||
export const secretsSchema = z.object({
|
||||
id: idSchema,
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { createZodDto } from "nestjs-zod/dto";
|
||||
import { z } from "nestjs-zod/z";
|
||||
import { z } from "zod";
|
||||
|
||||
export const statisticsSchema = z.object({
|
||||
views: z.number().int().default(0),
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
import { idSchema } from "@reactive-resume/schema";
|
||||
import { dateSchema } from "@reactive-resume/utils";
|
||||
import { createZodDto } from "nestjs-zod/dto";
|
||||
import { z } from "nestjs-zod/z";
|
||||
import { z } from "zod";
|
||||
|
||||
import { secretsSchema } from "../secrets";
|
||||
|
||||
@ -26,8 +27,8 @@ export const userSchema = z.object({
|
||||
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()),
|
||||
createdAt: dateSchema,
|
||||
updatedAt: dateSchema,
|
||||
});
|
||||
|
||||
export class UserDto extends createZodDto(userSchema) {}
|
||||
|
||||
@ -14,6 +14,7 @@
|
||||
"unique-names-generator": "^4.7.1",
|
||||
"clsx": "^2.1.1",
|
||||
"tailwind-merge": "^2.3.0",
|
||||
"@swc/helpers": "~0.5.11"
|
||||
"@swc/helpers": "~0.5.11",
|
||||
"zod": "^3.24.1"
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,4 +1,10 @@
|
||||
import dayjs from "dayjs";
|
||||
import { z } from "zod";
|
||||
|
||||
export const dateSchema = z.union([z.date(), z.string().datetime()]).transform((value) => {
|
||||
if (typeof value === "string") return dayjs(value).toDate();
|
||||
return value;
|
||||
});
|
||||
|
||||
export const sortByDate = <T>(a: T, b: T, key: keyof T, desc = true) => {
|
||||
if (!a[key] || !b[key]) return 0;
|
||||
|
||||
Reference in New Issue
Block a user