15 lines
385 B
TypeScript
15 lines
385 B
TypeScript
import { resolver } from "blitz"
|
|
import db from "db"
|
|
import { z } from "zod"
|
|
|
|
const DeleteItem = z.object({
|
|
id: z.number(),
|
|
})
|
|
|
|
export default resolver.pipe(resolver.zod(DeleteItem), resolver.authorize(), async ({ id }) => {
|
|
// TODO: in multi-tenant app, you must add validation to ensure correct tenant
|
|
const item = await db.item.deleteMany({ where: { id } })
|
|
|
|
return item
|
|
})
|