mirror of
https://codeberg.org/SafeTwitch/safetwitch-backend.git
synced 2025-01-27 14:48:57 -05:00
Add badges endpoint
This commit is contained in:
parent
4bbea255ea
commit
685645ddac
1 changed files with 19 additions and 1 deletions
|
@ -29,7 +29,25 @@ profileRouter.get('/discover', async (req, res, next) => {
|
||||||
|
|
||||||
profileRouter.get('/discover/:game', async (req, res, next) => {
|
profileRouter.get('/discover/:game', async (req, res, next) => {
|
||||||
let discoveryData = await twitch.getDirectoryGame(req.params.game, 50)
|
let discoveryData = await twitch.getDirectoryGame(req.params.game, 50)
|
||||||
|
.catch(next)
|
||||||
|
|
||||||
|
if(discoveryData)
|
||||||
res.send(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
|
export default profileRouter
|
Loading…
Add table
Reference in a new issue