refactor: migrate project data

This commit is contained in:
Carlos Valente
2025-07-08 17:11:25 +02:00
committed by Carlos Valente
parent 1fc6f9b3ea
commit 6f34e1006b
38 changed files with 136 additions and 228 deletions
@@ -17,9 +17,9 @@ export function parseProjectData(data: Partial<DatabaseModel>, emitError?: Error
return {
title: data.project.title ?? dbModel.project.title,
description: data.project.description ?? dbModel.project.description,
backstageUrl: data.project.backstageUrl ?? dbModel.project.backstageUrl,
backstageInfo: data.project.backstageInfo ?? dbModel.project.backstageInfo,
projectLogo: data.project.projectLogo ?? dbModel.project.projectLogo,
url: data.project.url ?? dbModel.project.url,
info: data.project.info ?? dbModel.project.info,
logo: data.project.logo ?? dbModel.project.logo,
custom: data.project.custom ?? dbModel.project.custom,
};
}
@@ -21,10 +21,9 @@ router.post('/', projectSanitiser, async (req: Request, res: Response<ProjectDat
const newData: Partial<ProjectData> = removeUndefined({
title: req.body?.title,
description: req.body?.description,
backstageUrl: req.body?.backstageUrl,
backstageInfo: req.body?.backstageInfo,
endMessage: req.body?.endMessage,
projectLogo: req.body?.projectLogo,
url: req.body?.url,
info: req.body?.info,
logo: req.body?.logo,
custom: req.body?.custom,
});
@@ -5,10 +5,9 @@ export const projectSanitiser = [
body().notEmpty().withMessage('No object found in request'),
body('title').optional().isString().trim(),
body('description').optional().isString().trim(),
body('backstageUrl').optional().isString().trim(),
body('backstageInfo').optional().isString().trim(),
body('endMessage').optional().isString().trim(),
body('projectLogo').optional({ nullable: true }).isString().trim(), //this is not the logo itself but then name of the logo
body('url').optional().isString().trim(),
body('info').optional().isString().trim(),
body('logo').optional({ nullable: true }).isString().trim(), //this is not the logo itself but then name of the logo
body('custom').optional().isArray(),
body('custom.*.title').optional().isString().trim().notEmpty(),
body('custom.*.value').optional().isString().trim().notEmpty(),