mirror of
https://github.com/fosrl/pangolin.git
synced 2025-08-05 10:35:18 +02:00
use strict zod objects and hide proto on targets
This commit is contained in:
parent
44b932937f
commit
ba3505a385
14 changed files with 154 additions and 162 deletions
|
@ -15,13 +15,15 @@ const createTargetParamsSchema = z.object({
|
|||
resourceId: z.string().transform(Number).pipe(z.number().int().positive()),
|
||||
});
|
||||
|
||||
const createTargetSchema = z.object({
|
||||
ip: z.string().ip(),
|
||||
method: z.string().min(1).max(10),
|
||||
port: z.number().int().min(1).max(65535),
|
||||
protocol: z.string().optional(),
|
||||
enabled: z.boolean().default(true),
|
||||
});
|
||||
const createTargetSchema = z
|
||||
.object({
|
||||
ip: z.string().ip(),
|
||||
method: z.string().min(1).max(10),
|
||||
port: z.number().int().min(1).max(65535),
|
||||
protocol: z.string().optional(),
|
||||
enabled: z.boolean().default(true),
|
||||
})
|
||||
.strict();
|
||||
|
||||
export type CreateTargetResponse = Target;
|
||||
|
||||
|
@ -104,6 +106,7 @@ export async function createTarget(
|
|||
.insert(targets)
|
||||
.values({
|
||||
resourceId,
|
||||
protocol: "tcp", // hard code for now
|
||||
...targetData,
|
||||
})
|
||||
.returning();
|
||||
|
|
|
@ -15,12 +15,12 @@ const updateTargetParamsSchema = z.object({
|
|||
|
||||
const updateTargetBodySchema = z
|
||||
.object({
|
||||
// ip: z.string().ip().optional(), // for now we cant update the ip; you will have to delete
|
||||
ip: z.string().ip().optional(), // for now we cant update the ip; you will have to delete
|
||||
method: z.string().min(1).max(10).optional(),
|
||||
port: z.number().int().min(1).max(65535).optional(),
|
||||
protocol: z.string().optional(),
|
||||
enabled: z.boolean().optional(),
|
||||
})
|
||||
.strict()
|
||||
.refine((data) => Object.keys(data).length > 0, {
|
||||
message: "At least one field must be provided for update",
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue