MCPcopy Create free account
hub / github.com/RealDevSquad/website-backend / fetchChallenges

Function fetchChallenges

controllers/challenge.js:10–23  ·  view source on GitHub ↗
(req, res)

Source from the content-addressed store, hash-verified

8 */
9
10const fetchChallenges = async (req, res) => {
11 try {
12 const allChallenges = await challengeQuery.fetchChallenges();
13 const promiseArray = await getParticipantsofChallenges(allChallenges);
14 const challengesWithParticipants = await Promise.all(promiseArray);
15 return res.json({
16 message: challengesWithParticipants.length ? "Challenges returned successfully!" : "No Challenges found",
17 challenges: challengesWithParticipants,
18 });
19 } catch (err) {
20 logger.error(`Error while retrieving challenges ${err}`);
21 return res.boom.serverUnavailable(SOMETHING_WENT_WRONG);
22 }
23};
24
25/**
26 * Add a challenge

Callers

nothing calls this directly

Calls 1

Tested by

no test coverage detected