.put(
'/:id',
zValidator('json', ProjectSchema.pick({ name: true, description: true }).partial()),
zValidator('param', z.object({ id: z.string() })),
async (c) => {
const user = c.get('user');
const data = c.req.valid('json');
const { id } = c.req.valid('param');
if (!user) return c.body(null, 401);
const response = await prisma.project.update({
data,
where: {
userId: user.id,
id,
},
});
return c.json(response);
}
)
.put(
'/:id',
zValidator('json', ProjectSchema.pick({ name: true, description: true }).partial()),
zValidator('param', z.object({ id: z.string() })),
async (c) => {
const user = c.get('user');
const data = c.req.valid('json');
const { id } = c.req.valid('param');
if (!user) return c.body(null, 401);
const response = await prisma.project.update({
data,
where: {
userId: user.id,
id,
},
});
return c.json(response);
}
)