diff --git a/routes/profileRoute.ts b/routes/profileRoute.ts index c2e7f20..196ed8e 100644 --- a/routes/profileRoute.ts +++ b/routes/profileRoute.ts @@ -29,7 +29,25 @@ profileRouter.get('/discover', async (req, res, next) => { profileRouter.get('/discover/:game', async (req, res, next) => { let discoveryData = await twitch.getDirectoryGame(req.params.game, 50) - res.send(discoveryData) + .catch(next) + + if(discoveryData) + res.send(discoveryData) +}) + +profileRouter.get('/badges', async (req, res, next) => { + let badges = await twitch.getTwitchBadges() + .catch(next) + + if(req.query.streamerName) { + let broadcastBadges = await twitch.getStreamerBadges(req.query.streamerName.toString()) + .catch(next) + if(broadcastBadges && badges) + badges = [...badges, ...broadcastBadges] + } + + if(badges) + res.send(badges) }) export default profileRouter \ No newline at end of file