(req, res)
| 8 | */ |
| 9 | |
| 10 | const 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 |
nothing calls this directly
no test coverage detected