mirror of
https://github.com/fosrl/pangolin.git
synced 2026-02-28 07:46:36 +00:00
used zod codemod
This commit is contained in:
@@ -8,17 +8,13 @@ import { fromError } from "zod-validation-error";
|
||||
import { OpenAPITags, registry } from "@server/openApi";
|
||||
import { applyBlueprint } from "@server/lib/blueprints/applyBlueprint";
|
||||
|
||||
const applyBlueprintSchema = z
|
||||
.object({
|
||||
const applyBlueprintSchema = z.strictObject({
|
||||
blueprint: z.string()
|
||||
})
|
||||
.strict();
|
||||
});
|
||||
|
||||
const applyBlueprintParamsSchema = z
|
||||
.object({
|
||||
const applyBlueprintParamsSchema = z.strictObject({
|
||||
orgId: z.string()
|
||||
})
|
||||
.strict();
|
||||
});
|
||||
|
||||
registry.registerPath({
|
||||
method: "put",
|
||||
|
||||
@@ -12,15 +12,13 @@ import { fromError } from "zod-validation-error";
|
||||
import { OpenAPITags, registry } from "@server/openApi";
|
||||
import { BlueprintData } from "./types";
|
||||
|
||||
const getBlueprintSchema = z
|
||||
.object({
|
||||
const getBlueprintSchema = z.strictObject({
|
||||
blueprintId: z
|
||||
.string()
|
||||
.transform(stoi)
|
||||
.pipe(z.number().int().positive()),
|
||||
.pipe(z.int().positive()),
|
||||
orgId: z.string()
|
||||
})
|
||||
.strict();
|
||||
});
|
||||
|
||||
async function query(blueprintId: number, orgId: string) {
|
||||
// Get the client
|
||||
|
||||
@@ -10,28 +10,24 @@ import { fromZodError } from "zod-validation-error";
|
||||
import { OpenAPITags, registry } from "@server/openApi";
|
||||
import { BlueprintData } from "./types";
|
||||
|
||||
const listBluePrintsParamsSchema = z
|
||||
.object({
|
||||
const listBluePrintsParamsSchema = z.strictObject({
|
||||
orgId: z.string()
|
||||
})
|
||||
.strict();
|
||||
});
|
||||
|
||||
const listBluePrintsSchema = z
|
||||
.object({
|
||||
const listBluePrintsSchema = z.strictObject({
|
||||
limit: z
|
||||
.string()
|
||||
.optional()
|
||||
.default("1000")
|
||||
.transform(Number)
|
||||
.pipe(z.number().int().nonnegative()),
|
||||
.pipe(z.int().nonnegative()),
|
||||
offset: z
|
||||
.string()
|
||||
.optional()
|
||||
.default("0")
|
||||
.transform(Number)
|
||||
.pipe(z.number().int().nonnegative())
|
||||
})
|
||||
.strict();
|
||||
.pipe(z.int().nonnegative())
|
||||
});
|
||||
|
||||
async function queryBlueprints(orgId: string, limit: number, offset: number) {
|
||||
const res = await db
|
||||
|
||||
Reference in New Issue
Block a user