0
Fork 0
mirror of https://codeberg.org/SafeTwitch/safetwitch-backend.git synced 2025-01-25 21:58:48 -05:00

Add badges endpoint

This commit is contained in:
dragongoose 2023-03-31 07:56:38 -04:00
parent 4bbea255ea
commit 685645ddac

View file

@ -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