Skip to content

Commit b6a04a4

Browse files
author
NeuroPrep AI
committed
Add fallback data to mastery paths API - guarantees new content even if DB fails
1 parent af3e29a commit b6a04a4

1 file changed

Lines changed: 44 additions & 3 deletions

File tree

backend/routes/masteryPaths.js

Lines changed: 44 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,56 @@ import MasteryPath from '../models/MasteryPath.js';
33

44
const router = express.Router();
55

6+
// Fallback data in case MongoDB fails
7+
const FALLBACK_PATHS = [
8+
{
9+
title: "Logic & Precision",
10+
slug: "logic-precision",
11+
description: "The essential toolkit for every engineer who values accuracy over approximation. Master the core logic and critical thinking that supports every engineering discipline, from circuits to concrete. Patterns change, but logic doesn't. Develop the problem-solving intuition that cracks exams and fixes engines alike.",
12+
companyTags: ["All Industries", "R&D", "Product Design", "Field Services"],
13+
difficulty: "All Levels",
14+
salaryRange: "₹3.5-25 LPA",
15+
icon: "🎯",
16+
skills: ["Critical Thinking", "Precision Engineering", "Core Logic", "Problem-Solving Intuition"]
17+
},
18+
{
19+
title: "Complexity Decoded",
20+
slug: "complexity-decoded",
21+
description: "Learn to navigate high-level friction, entropy, and edge cases in any system you design. Tackle the toughest problems in the industry. Whether optimizing algorithms or infrastructure, learn to build what hasn't been built yet. Go beyond the surface. Gain the deep technical expertise required to innovate, patent, and pioneer new technologies.",
22+
companyTags: ["Product Companies", "R&D Labs", "Innovation Centers", "Patents"],
23+
difficulty: "Intermediate to Expert",
24+
salaryRange: "₹8-45 LPA",
25+
icon: "🧩",
26+
skills: ["System Design", "Edge Case Analysis", "Deep Tech", "Innovation"]
27+
},
28+
{
29+
title: "Total Versatility",
30+
slug: "total-versatility",
31+
description: "Prepare for a dynamic future. Equip yourself to work in R&D, operations, product design, or field services. Be the engineer who thrives anywhere. Gain the versatility to design products, manage services, and solve real-world crises. Don't just fit a job description. Prepare for a career that bridges the gap between abstract theory and tangible human impact.",
32+
companyTags: ["Any Industry", "Operations", "Product Design", "Crisis Management"],
33+
difficulty: "All Levels",
34+
salaryRange: "₹4-30 LPA",
35+
icon: "🌐",
36+
skills: ["Adaptive Engineering", "Versatility", "Impact-Driven", "Real-World Problem Solving"]
37+
}
38+
];
39+
640
// @route GET /api/mastery-paths
741
// @desc Get all mastery paths
842
router.get('/', async (req, res) => {
943
try {
1044
const paths = await MasteryPath.find({});
11-
res.json(paths);
45+
if (paths && paths.length > 0) {
46+
res.json(paths);
47+
} else {
48+
// Return fallback if DB is empty
49+
console.log('DB empty, returning fallback paths');
50+
res.json(FALLBACK_PATHS);
51+
}
1252
} catch (error) {
13-
console.error('Error fetching mastery paths:', error);
14-
res.status(500).json({ error: 'Server Error' });
53+
console.error('Error fetching mastery paths, returning fallback:', error);
54+
// Return fallback data instead of error
55+
res.json(FALLBACK_PATHS);
1556
}
1657
});
1758

0 commit comments

Comments
 (0)