mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-04-11 07:00:41 -04:00
revert(api): decouple api from curriculum
This reverts commit c077ffe4b9
via PR #40703
This commit is contained in:
13
api-server/common/utils/empty-protector.js
Normal file
13
api-server/common/utils/empty-protector.js
Normal file
@@ -0,0 +1,13 @@
|
||||
const emptyProtector = {
|
||||
blocks: [],
|
||||
challenges: []
|
||||
};
|
||||
// protect against malformed map data
|
||||
// protect(block: { challenges: [], block: [] }|Void) => block|emptyProtector
|
||||
export default function protect(block) {
|
||||
// if no block or block has no challenges or blocks
|
||||
if (!block || !(block.challenges || block.blocks)) {
|
||||
return emptyProtector;
|
||||
}
|
||||
return block;
|
||||
}
|
||||
Reference in New Issue
Block a user