task(F2-backend): global block favorites - is_favorite column, adapter mapping, PATCH validation
This commit is contained in:
@@ -134,11 +134,14 @@ export function registerGlobalBlockRoutes(fastify: FastifyInstance, db: Database
|
||||
const { id } = request.params as { id: string };
|
||||
const idErr = validateIdParam(id, 'id');
|
||||
if (idErr) return reply.code(400).send({ error: idErr });
|
||||
const body = request.body as { name?: string; folder_id?: string | null; block_data?: string; svg_data?: string };
|
||||
const body = request.body as { name?: string; folder_id?: string | null; block_data?: string; svg_data?: string; is_favorite?: boolean };
|
||||
if (body.name !== undefined) {
|
||||
const nameErr = validateName(body.name, 'name');
|
||||
if (nameErr) return reply.code(400).send({ error: nameErr });
|
||||
}
|
||||
if (body.is_favorite !== undefined && typeof body.is_favorite !== 'boolean') {
|
||||
return reply.code(400).send({ error: 'is_favorite must be a boolean' });
|
||||
}
|
||||
if (body.folder_id !== undefined && body.folder_id !== null) {
|
||||
const fidErr = validateIdParam(body.folder_id, 'folder_id');
|
||||
if (fidErr) return reply.code(400).send({ error: fidErr });
|
||||
|
||||
Reference in New Issue
Block a user