used zod codemod

This commit is contained in:
Lokowitz
2025-11-16 14:18:17 +00:00
parent 000904eb31
commit 7db99a7dd5
191 changed files with 764 additions and 1232 deletions

View File

@@ -25,14 +25,11 @@ import { createCertificate } from "#dynamic/routers/certificates/createCertifica
import { getUniqueResourceName } from "@server/db/names";
import { validateAndConstructDomain } from "@server/lib/domainUtils";
const createResourceParamsSchema = z
.object({
const createResourceParamsSchema = z.strictObject({
orgId: z.string()
})
.strict();
});
const createHttpResourceSchema = z
.object({
const createHttpResourceSchema = z.strictObject({
name: z.string().min(1).max(255),
subdomain: z.string().nullable().optional(),
http: z.boolean(),
@@ -40,7 +37,6 @@ const createHttpResourceSchema = z
domainId: z.string(),
stickySession: z.boolean().optional(),
})
.strict()
.refine(
(data) => {
if (data.subdomain) {
@@ -48,18 +44,18 @@ const createHttpResourceSchema = z
}
return true;
},
{ message: "Invalid subdomain" }
{
error: "Invalid subdomain"
}
);
const createRawResourceSchema = z
.object({
const createRawResourceSchema = z.strictObject({
name: z.string().min(1).max(255),
http: z.boolean(),
protocol: z.enum(["tcp", "udp"]),
proxyPort: z.number().int().min(1).max(65535)
proxyPort: z.int().min(1).max(65535)
// enableProxy: z.boolean().default(true) // always true now
})
.strict()
.refine(
(data) => {
if (!config.getRawConfig().flags?.allow_raw_resources) {
@@ -70,7 +66,7 @@ const createRawResourceSchema = z
return true;
},
{
message: "Raw resources are not allowed"
error: "Raw resources are not allowed"
}
);