mirror of
https://github.com/fosrl/pangolin.git
synced 2026-02-20 11:56:38 +00:00
used zod codemod
This commit is contained in:
@@ -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"
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user