Remove zod, just use typebox
This commit is contained in:
@@ -23,8 +23,7 @@
|
|||||||
"elysia": "^1.4.29",
|
"elysia": "^1.4.29",
|
||||||
"ml-levenberg-marquardt": "^5.0.1",
|
"ml-levenberg-marquardt": "^5.0.1",
|
||||||
"pino": "^10.3.1",
|
"pino": "^10.3.1",
|
||||||
"zipcodes-us": "^1.1.3",
|
"zipcodes-us": "^1.1.3"
|
||||||
"zod": "^4.4.3"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"pino-pretty": "^13.1.3"
|
"pino-pretty": "^13.1.3"
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ import {
|
|||||||
Webflow,
|
Webflow,
|
||||||
} from "@blade-and-brawn/commerce";
|
} from "@blade-and-brawn/commerce";
|
||||||
import zipcodesUs from "zipcodes-us";
|
import zipcodesUs from "zipcodes-us";
|
||||||
import z from "zod";
|
|
||||||
import pino from "pino";
|
import pino from "pino";
|
||||||
import { env } from "./env";
|
import { env } from "./env";
|
||||||
import serverTiming from "@elysia/server-timing";
|
import serverTiming from "@elysia/server-timing";
|
||||||
@@ -133,8 +132,8 @@ export const app = new Elysia()
|
|||||||
undefined
|
undefined
|
||||||
});
|
});
|
||||||
}, {
|
}, {
|
||||||
body: z.object({
|
body: t.Object({
|
||||||
password: z.coerce.string()
|
password: t.String()
|
||||||
}),
|
}),
|
||||||
cookie: t.Cookie({ auth: t.Optional(t.String()) })
|
cookie: t.Cookie({ auth: t.Optional(t.String()) })
|
||||||
})
|
})
|
||||||
@@ -145,9 +144,9 @@ export const app = new Elysia()
|
|||||||
levels: levelCalculator.calculate(body.player, body.activityPerformances),
|
levels: levelCalculator.calculate(body.player, body.activityPerformances),
|
||||||
};
|
};
|
||||||
}, {
|
}, {
|
||||||
body: z.object({
|
body: t.Object({
|
||||||
player: PlayerSchema,
|
player: PlayerSchema,
|
||||||
activityPerformances: z.array(ActivityPerformanceSchema)
|
activityPerformances: t.Array(ActivityPerformanceSchema)
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -175,7 +174,7 @@ export const app = new Elysia()
|
|||||||
.post("/:printfulProductId", async ({ params }) => {
|
.post("/:printfulProductId", async ({ params }) => {
|
||||||
if (!await productSyncer.sync({ printfulProductIdsFilter: [params.printfulProductId] }))
|
if (!await productSyncer.sync({ printfulProductIdsFilter: [params.printfulProductId] }))
|
||||||
throw status(409, "Sync already in progress");
|
throw status(409, "Sync already in progress");
|
||||||
}, { params: z.object({ printfulProductId: z.coerce.number() }) }),
|
}, { params: t.Object({ printfulProductId: t.Numeric() }) }),
|
||||||
)
|
)
|
||||||
.get("/:printfulProductId", async ({ params }) => {
|
.get("/:printfulProductId", async ({ params }) => {
|
||||||
const printfulProduct = await printful.Products.get(params.printfulProductId);
|
const printfulProduct = await printful.Products.get(params.printfulProductId);
|
||||||
@@ -188,7 +187,7 @@ export const app = new Elysia()
|
|||||||
|
|
||||||
return { printfulProduct, webflowProduct };
|
return { printfulProduct, webflowProduct };
|
||||||
}, {
|
}, {
|
||||||
params: z.object({ printfulProductId: z.coerce.number() })
|
params: t.Object({ printfulProductId: t.Numeric() })
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
"type": "module",
|
"type": "module",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@blade-and-brawn/api": "workspace:*",
|
"@blade-and-brawn/api": "workspace:*",
|
||||||
"@sveltejs/kit": "^2.68.0",
|
"@sveltejs/kit": "^2.69.0",
|
||||||
"@sveltejs/vite-plugin-svelte": "^6.2.4",
|
"@sveltejs/vite-plugin-svelte": "^6.2.4",
|
||||||
"@types/bun": "^1.3.14",
|
"@types/bun": "^1.3.14",
|
||||||
"elysia": "^1.4.29",
|
"elysia": "^1.4.29",
|
||||||
|
|||||||
@@ -22,7 +22,6 @@
|
|||||||
"ml-levenberg-marquardt": "^5.0.1",
|
"ml-levenberg-marquardt": "^5.0.1",
|
||||||
"pino": "^10.3.1",
|
"pino": "^10.3.1",
|
||||||
"zipcodes-us": "^1.1.3",
|
"zipcodes-us": "^1.1.3",
|
||||||
"zod": "^4.4.3",
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"pino-pretty": "^13.1.3",
|
"pino-pretty": "^13.1.3",
|
||||||
@@ -42,7 +41,7 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@blade-and-brawn/api": "workspace:*",
|
"@blade-and-brawn/api": "workspace:*",
|
||||||
"@sveltejs/kit": "^2.68.0",
|
"@sveltejs/kit": "^2.69.0",
|
||||||
"@sveltejs/vite-plugin-svelte": "^6.2.4",
|
"@sveltejs/vite-plugin-svelte": "^6.2.4",
|
||||||
"@types/bun": "^1.3.14",
|
"@types/bun": "^1.3.14",
|
||||||
"elysia": "^1.4.29",
|
"elysia": "^1.4.29",
|
||||||
@@ -72,7 +71,7 @@
|
|||||||
"version": "0.0.0",
|
"version": "0.0.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@blade-and-brawn/domain": "workspace:*",
|
"@blade-and-brawn/domain": "workspace:*",
|
||||||
"zod": "^4.4.3",
|
"@sinclair/typebox": "^0.34.48",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -219,7 +218,7 @@
|
|||||||
|
|
||||||
"@sveltejs/acorn-typescript": ["@sveltejs/acorn-typescript@1.0.10", "", { "peerDependencies": { "acorn": "^8.9.0" } }, "sha512-4WfKk68eTih+MiJD4fSbxN7E8kVBmTMPWHUPYjvl2N0rMs53YLTT8/YjKU5Dtnz5LqDjl7LEw4U7lXR2W3J5WA=="],
|
"@sveltejs/acorn-typescript": ["@sveltejs/acorn-typescript@1.0.10", "", { "peerDependencies": { "acorn": "^8.9.0" } }, "sha512-4WfKk68eTih+MiJD4fSbxN7E8kVBmTMPWHUPYjvl2N0rMs53YLTT8/YjKU5Dtnz5LqDjl7LEw4U7lXR2W3J5WA=="],
|
||||||
|
|
||||||
"@sveltejs/kit": ["@sveltejs/kit@2.68.0", "", { "dependencies": { "@standard-schema/spec": "^1.0.0", "@sveltejs/acorn-typescript": "^1.0.9", "@types/cookie": "^0.6.0", "acorn": "^8.16.0", "cookie": "^0.6.0", "devalue": "^5.8.1", "esm-env": "^1.2.2", "kleur": "^4.1.5", "magic-string": "^0.30.5", "mrmime": "^2.0.0", "set-cookie-parser": "^3.0.0", "sirv": "^3.0.0" }, "peerDependencies": { "@opentelemetry/api": "^1.0.0", "@sveltejs/vite-plugin-svelte": "^3.0.0 || ^4.0.0-next.1 || ^5.0.0 || ^6.0.0-next.0 || ^7.0.0", "svelte": "^4.0.0 || ^5.0.0-next.0", "typescript": "^5.3.3 || ^6.0.0", "vite": "^5.0.3 || ^6.0.0 || ^7.0.0-beta.0 || ^8.0.0" }, "optionalPeers": ["@opentelemetry/api", "typescript"], "bin": { "svelte-kit": "svelte-kit.js" } }, "sha512-PdKiWsqinAoubVsSiRgVFkg3MHzGhQPnwQ8VxnGQKpZYijpapZ3UHHBje0GeByt2TvfjHPw+kxV+dNK2RIZg9g=="],
|
"@sveltejs/kit": ["@sveltejs/kit@2.69.0", "", { "dependencies": { "@standard-schema/spec": "^1.0.0", "@sveltejs/acorn-typescript": "^1.0.9", "@types/cookie": "^0.6.0", "acorn": "^8.16.0", "cookie": "^0.6.0", "devalue": "^5.8.1", "esm-env": "^1.2.2", "kleur": "^4.1.5", "magic-string": "^0.30.5", "mrmime": "^2.0.0", "set-cookie-parser": "^3.0.0", "sirv": "^3.0.0" }, "peerDependencies": { "@opentelemetry/api": "^1.0.0", "@sveltejs/vite-plugin-svelte": "^3.0.0 || ^4.0.0-next.1 || ^5.0.0 || ^6.0.0-next.0 || ^7.0.0", "svelte": "^4.0.0 || ^5.0.0-next.0", "typescript": "^5.3.3 || ^6.0.0", "vite": "^5.0.3 || ^6.0.0 || ^7.0.0-beta.0 || ^8.0.0" }, "optionalPeers": ["@opentelemetry/api", "typescript"], "bin": { "svelte-kit": "svelte-kit.js" } }, "sha512-RD4ntr/QiXsU5V0ADEoZ+R2lyPlwZbENJ6ss0YtgQXqWn3+U9PnU/EeitysgpVbDV8d9XTmFqdTMKOTOe3yb0A=="],
|
||||||
|
|
||||||
"@sveltejs/load-config": ["@sveltejs/load-config@0.2.0", "", {}, "sha512-1LgZ/qUqSoq+QorD83lk2hka79Px0wXNW2q5V1nZlxGhQgw1jrsIbVz5YiCeucVLo4XvFLjXukUaQjIiqowkcg=="],
|
"@sveltejs/load-config": ["@sveltejs/load-config@0.2.0", "", {}, "sha512-1LgZ/qUqSoq+QorD83lk2hka79Px0wXNW2q5V1nZlxGhQgw1jrsIbVz5YiCeucVLo4XvFLjXukUaQjIiqowkcg=="],
|
||||||
|
|
||||||
@@ -489,8 +488,6 @@
|
|||||||
|
|
||||||
"zipcodes-us": ["zipcodes-us@1.1.3", "", {}, "sha512-gOz8WAO6iWBU4aUc0lljpa+TKZckRKmgoHKcc1jWnn4eTbdc9XO5cXEaGccYn7GAjykueO0Wn+N7zdmzG0Uf5w=="],
|
"zipcodes-us": ["zipcodes-us@1.1.3", "", {}, "sha512-gOz8WAO6iWBU4aUc0lljpa+TKZckRKmgoHKcc1jWnn4eTbdc9XO5cXEaGccYn7GAjykueO0Wn+N7zdmzG0Uf5w=="],
|
||||||
|
|
||||||
"zod": ["zod@4.4.3", "", {}, "sha512-ytENFjIJFl2UwYglde2jchW2Hwm4GJFLDiSXWdTrJQBIN9Fcyp7n4DhxJEiWNAJMV1/BqWfW/kkg71UDcHJyTQ=="],
|
|
||||||
|
|
||||||
"@sveltejs/kit/cookie": ["cookie@0.6.0", "", {}, "sha512-U71cyTamuh1CRNCfpGY6to28lxvNwPG4Guz/EVjgf3Jmzv0vlDp1atT9eS5dDjMYHucpHbWns6Lwf3BKz6svdw=="],
|
"@sveltejs/kit/cookie": ["cookie@0.6.0", "", {}, "sha512-U71cyTamuh1CRNCfpGY6to28lxvNwPG4Guz/EVjgf3Jmzv0vlDp1atT9eS5dDjMYHucpHbWns6Lwf3BKz6svdw=="],
|
||||||
|
|
||||||
"@tailwindcss/oxide-wasm32-wasi/@emnapi/core": ["@emnapi/core@1.11.1", "", { "dependencies": { "@emnapi/wasi-threads": "1.2.2", "tslib": "^2.4.0" }, "bundled": true }, "sha512-RSvbQmHzdKzNsLYa/wHrbc3KN4sYLKAdPZxqiM2HATqv/SBk2/ENSHpvXGaLOMcsAyz0poEGqkmmKYG3OWiJEQ=="],
|
"@tailwindcss/oxide-wasm32-wasi/@emnapi/core": ["@emnapi/core@1.11.1", "", { "dependencies": { "@emnapi/wasi-threads": "1.2.2", "tslib": "^2.4.0" }, "bundled": true }, "sha512-RSvbQmHzdKzNsLYa/wHrbc3KN4sYLKAdPZxqiM2HATqv/SBk2/ENSHpvXGaLOMcsAyz0poEGqkmmKYG3OWiJEQ=="],
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
"type": "module",
|
"type": "module",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@blade-and-brawn/domain": "workspace:*",
|
"@blade-and-brawn/domain": "workspace:*",
|
||||||
"zod": "^4.4.3"
|
"@sinclair/typebox": "^0.34.48"
|
||||||
},
|
},
|
||||||
"exports": {
|
"exports": {
|
||||||
".": "./src/index.ts"
|
".": "./src/index.ts"
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { z } from "zod";
|
import { Type } from "@sinclair/typebox";
|
||||||
|
import type { Static } from "@sinclair/typebox";
|
||||||
|
|
||||||
export enum Attribute {
|
export enum Attribute {
|
||||||
Strength = "Strength",
|
Strength = "Strength",
|
||||||
@@ -21,24 +22,24 @@ export enum Gender {
|
|||||||
Female = "Female",
|
Female = "Female",
|
||||||
}
|
}
|
||||||
|
|
||||||
export const MetricsSchema = z.object({
|
export const MetricsSchema = Type.Object({
|
||||||
age: z.number(),
|
age: Type.Number(),
|
||||||
weight: z.number(),
|
weight: Type.Number(),
|
||||||
gender: z.enum(Gender),
|
gender: Type.Enum(Gender),
|
||||||
});
|
});
|
||||||
|
|
||||||
export const PlayerSchema = z.object({
|
export const PlayerSchema = Type.Object({
|
||||||
name: z.string().optional(),
|
name: Type.Optional(Type.String()),
|
||||||
metrics: MetricsSchema,
|
metrics: MetricsSchema,
|
||||||
});
|
});
|
||||||
|
|
||||||
export const ActivityPerformanceSchema = z.object({
|
export const ActivityPerformanceSchema = Type.Object({
|
||||||
activity: z.enum(Activity),
|
activity: Type.Enum(Activity),
|
||||||
performance: z.number(),
|
performance: Type.Number(),
|
||||||
});
|
});
|
||||||
|
|
||||||
export type StandardUnit = "ms" | "cm" | "kg";
|
export type StandardUnit = "ms" | "cm" | "kg";
|
||||||
|
|
||||||
export type Metrics = z.infer<typeof MetricsSchema>;
|
export type Metrics = Static<typeof MetricsSchema>;
|
||||||
export type Player = z.infer<typeof PlayerSchema>;
|
export type Player = Static<typeof PlayerSchema>;
|
||||||
export type ActivityPerformance = z.infer<typeof ActivityPerformanceSchema>;
|
export type ActivityPerformance = Static<typeof ActivityPerformanceSchema>;
|
||||||
|
|||||||
Reference in New Issue
Block a user