Track and save on groceries

refactor(api): add model title helper

Closes https://tangled.org/scrumplex.net/cherries/issues/1

Signed-off-by: Sefa Eyeoglu <contact@scrumplex.net>

+3 -3
+3 -3
packages/api/src/utils.ts
··· 1 1 import z from "zod/v4"; 2 2 3 3 export class SchemaNoTitleError extends Error { 4 - constructor(schema: z.ZodType) { 5 - super(`Schema has no title metadata ${schema}`) 4 + constructor() { 5 + super(`Schema has no title metadata`); 6 6 } 7 7 } 8 8 9 9 export const schemaTitle = (schema: z.ZodType) => { 10 10 const meta = schema.meta(); 11 11 if (!meta?.title) { 12 - throw new SchemaNoTitleError(schema); 12 + throw new SchemaNoTitleError(); 13 13 } 14 14 return meta.title; 15 15 };