server/api/cakes.post.ts
Validated API
Example
Validate input and create a database row.
export const config = {
filter: {
name: z.string().min(1).max(80),
price: z.int().min(1),
},
sample: {
name: "Strawberry Cake",
price: 24,
},
};
export default async (data: Input<typeof config.filter>) => {
return db.cake.create({ data });
};