add: harden thumbnail generation and validate image assets
All checks were successful
Deploy on push / deploy (push) Has been skipped

This commit is contained in:
2026-03-22 20:04:26 -07:00
parent 3439fc834f
commit 21c3a0c4b2
5 changed files with 461 additions and 13 deletions

View File

@@ -47,6 +47,8 @@ function validateMeals(meals) {
throw new Error("data/meals.json must contain an array");
}
const ids = new Set();
for (const [index, meal] of meals.entries()) {
if (!meal || typeof meal !== "object") {
throw new Error(`Meal at index ${index} must be an object`);
@@ -62,6 +64,12 @@ function validateMeals(meals) {
throw new Error(`Meal ${index} has a non-string "position" value`);
}
if (ids.has(meal.id)) {
throw new Error(`Duplicate meal id "${meal.id}" found in data/meals.json`);
}
ids.add(meal.id);
validateThumbnail(meal, index);
}
}