Files
freeCodeCamp/api-server/src/server/utils/get-curriculum.js
2023-09-07 23:06:01 +05:30

22 lines
825 B
JavaScript

import { flatten } from 'lodash';
// TODO: keeping curriculum in memory is handy if we want to field requests that
// need to 'query' the curriculum, but if we force the client to handle
// redirectToCurrentChallenge and, instead, only report the current challenge id
// via the user object, then we should *not* store this so it can be garbage
// collected.
// eslint-disable-next-line import/no-unresolved
import curriculum from '../../../../shared/config/curriculum.json';
export function getChallenges() {
return Object.keys(curriculum)
.map(key => curriculum[key].blocks)
.reduce((challengeArray, superBlock) => {
const challengesForBlock = Object.keys(superBlock).map(
key => superBlock[key].challenges
);
return [...challengeArray, ...flatten(challengesForBlock)];
}, []);
}