Remove zod, just use typebox

This commit is contained in:
Dominic Ferrando
2026-07-01 11:06:27 -04:00
parent f5fb64e467
commit e90441bbaa
6 changed files with 26 additions and 30 deletions
+1 -2
View File
@@ -23,8 +23,7 @@
"elysia": "^1.4.29",
"ml-levenberg-marquardt": "^5.0.1",
"pino": "^10.3.1",
"zipcodes-us": "^1.1.3",
"zod": "^4.4.3"
"zipcodes-us": "^1.1.3"
},
"devDependencies": {
"pino-pretty": "^13.1.3"
+6 -7
View File
@@ -20,7 +20,6 @@ import {
Webflow,
} from "@blade-and-brawn/commerce";
import zipcodesUs from "zipcodes-us";
import z from "zod";
import pino from "pino";
import { env } from "./env";
import serverTiming from "@elysia/server-timing";
@@ -133,8 +132,8 @@ export const app = new Elysia()
undefined
});
}, {
body: z.object({
password: z.coerce.string()
body: t.Object({
password: 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),
};
}, {
body: z.object({
body: t.Object({
player: PlayerSchema,
activityPerformances: z.array(ActivityPerformanceSchema)
activityPerformances: t.Array(ActivityPerformanceSchema)
}),
})
@@ -175,7 +174,7 @@ export const app = new Elysia()
.post("/:printfulProductId", async ({ params }) => {
if (!await productSyncer.sync({ printfulProductIdsFilter: [params.printfulProductId] }))
throw status(409, "Sync already in progress");
}, { params: z.object({ printfulProductId: z.coerce.number() }) }),
}, { params: t.Object({ printfulProductId: t.Numeric() }) }),
)
.get("/:printfulProductId", async ({ params }) => {
const printfulProduct = await printful.Products.get(params.printfulProductId);
@@ -188,7 +187,7 @@ export const app = new Elysia()
return { printfulProduct, webflowProduct };
}, {
params: z.object({ printfulProductId: z.coerce.number() })
params: t.Object({ printfulProductId: t.Numeric() })
})
)
+1 -1
View File
@@ -3,7 +3,7 @@
"type": "module",
"devDependencies": {
"@blade-and-brawn/api": "workspace:*",
"@sveltejs/kit": "^2.68.0",
"@sveltejs/kit": "^2.69.0",
"@sveltejs/vite-plugin-svelte": "^6.2.4",
"@types/bun": "^1.3.14",
"elysia": "^1.4.29",
+3 -6
View File
@@ -22,7 +22,6 @@
"ml-levenberg-marquardt": "^5.0.1",
"pino": "^10.3.1",
"zipcodes-us": "^1.1.3",
"zod": "^4.4.3",
},
"devDependencies": {
"pino-pretty": "^13.1.3",
@@ -42,7 +41,7 @@
},
"devDependencies": {
"@blade-and-brawn/api": "workspace:*",
"@sveltejs/kit": "^2.68.0",
"@sveltejs/kit": "^2.69.0",
"@sveltejs/vite-plugin-svelte": "^6.2.4",
"@types/bun": "^1.3.14",
"elysia": "^1.4.29",
@@ -72,7 +71,7 @@
"version": "0.0.0",
"dependencies": {
"@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/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=="],
@@ -489,8 +488,6 @@
"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=="],
"@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=="],
+1 -1
View File
@@ -5,7 +5,7 @@
"type": "module",
"dependencies": {
"@blade-and-brawn/domain": "workspace:*",
"zod": "^4.4.3"
"@sinclair/typebox": "^0.34.48"
},
"exports": {
".": "./src/index.ts"
+14 -13
View File
@@ -1,4 +1,5 @@
import { z } from "zod";
import { Type } from "@sinclair/typebox";
import type { Static } from "@sinclair/typebox";
export enum Attribute {
Strength = "Strength",
@@ -21,24 +22,24 @@ export enum Gender {
Female = "Female",
}
export const MetricsSchema = z.object({
age: z.number(),
weight: z.number(),
gender: z.enum(Gender),
export const MetricsSchema = Type.Object({
age: Type.Number(),
weight: Type.Number(),
gender: Type.Enum(Gender),
});
export const PlayerSchema = z.object({
name: z.string().optional(),
export const PlayerSchema = Type.Object({
name: Type.Optional(Type.String()),
metrics: MetricsSchema,
});
export const ActivityPerformanceSchema = z.object({
activity: z.enum(Activity),
performance: z.number(),
export const ActivityPerformanceSchema = Type.Object({
activity: Type.Enum(Activity),
performance: Type.Number(),
});
export type StandardUnit = "ms" | "cm" | "kg";
export type Metrics = z.infer<typeof MetricsSchema>;
export type Player = z.infer<typeof PlayerSchema>;
export type ActivityPerformance = z.infer<typeof ActivityPerformanceSchema>;
export type Metrics = Static<typeof MetricsSchema>;
export type Player = Static<typeof PlayerSchema>;
export type ActivityPerformance = Static<typeof ActivityPerformanceSchema>;