Fix: about feature

This commit is contained in:
2026-04-23 01:17:51 +07:00
parent 2094ada80f
commit 9c266f71f3
14 changed files with 504 additions and 419 deletions
+2 -10
View File
@@ -10,12 +10,8 @@ async function validateAboutData(data) {
}
// Tuỳ schema bạn chỉnh lại cho chuẩn hơn
if (!data.title || !data.sections) {
throw new Error('Missing required fields: title or sections');
}
if (!Array.isArray(data.sections)) {
throw new Error('sections must be an array');
if (!data.hero || !data.leadership) {
throw new Error('Missing required fields: hero or leadership');
}
}
@@ -24,11 +20,9 @@ async function migrateAboutData() {
await connectDB();
console.log('Đã kết nối MongoDB...');
// Xóa dữ liệu cũ
await About.deleteMany({});
console.log('Đã xóa dữ liệu About cũ');
// Đọc file JSON
const aboutData = JSON.parse(
await fs.readFile(
path.join(__dirname, '../data/about.json'),
@@ -38,13 +32,11 @@ async function migrateAboutData() {
// Validate
await validateAboutData(aboutData);
// Transform (optional)
const finalData = {
...aboutData,
updatedAt: new Date()
};
// Insert
await About.create(finalData);