courseLoader.js Data adapter
Fetches the full course catalog. Tries the bundled static file first. Falls back to a live API if the local file is unavailable. Returns raw JSON — normalization happens in PlannerContext via normalizeCourse().
Parent
Called by
PlannerContext.jsx (once, on mount)
Primary source
public/all-courses.json (6.5 MB, bundled)Fallback source
husker.vercel.app/courses/all (live API)Exported function
fetchCourses() → Promise<RawCourse[]>
Attempts to load courses in this order:
- Fetch
{BASE_URL}all-courses.json(bundled inpublic/) - If that fails (404, network error), fetch from
https://husker.vercel.app/courses/all
normalizeCourse(raw) for each element after receiving the array.
Returns: Promise<RawCourse[]> — raw catalog entries
Why bundle + fallback?
Bundling all-courses.json ensures the app works offline and loads fast. The fallback API exists for development scenarios where the bundled file hasn't been updated yet, or for quick testing without a full build.
The BASE_URL is read from import.meta.env.BASE_URL (Vite-injected) so paths resolve correctly on both localhost (/) and GitHub Pages (/nu-map/).
Updating the course catalog
# Full update workflow
npm run scrape # fetch from catalog.northeastern.edu (~20 min for full rotation)
npm run patch # apply YAML corrections from data/patches/
npm run nupath # merge NUPath attribute data
git add public/all-courses.json
git commit -m "data: update course catalog"