feat: improve ux and security
This commit is contained in:
@@ -7,12 +7,16 @@ const paramsSchema = z.object({
|
||||
id: z.string().transform(Number),
|
||||
});
|
||||
|
||||
const bodySchema = z.object({
|
||||
name: z.string().min(1).optional(),
|
||||
path: z.string().min(1).optional(),
|
||||
url: z.url().optional(),
|
||||
disabled: z.boolean().optional(),
|
||||
});
|
||||
const bodySchema = z
|
||||
.object({
|
||||
name: z.string().min(1).optional(),
|
||||
path: z.string().min(1).startsWith("/").optional(),
|
||||
url: z.url().optional(),
|
||||
disabled: z.boolean().optional(),
|
||||
})
|
||||
.refine((data) => Object.values(data).some((v) => v !== undefined), {
|
||||
message: "At least one field must be provided",
|
||||
});
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
const params = await getValidatedRouterParams(event, paramsSchema.parse);
|
||||
|
||||
Reference in New Issue
Block a user