0
Fork 0
mirror of https://codeberg.org/SafeTwitch/safetwitch-backend.git synced 2025-01-10 06:40:15 -05:00
safetwitch-backend/routes/profileRoute.ts
2023-03-24 07:41:33 -04:00

27 lines
No EOL
752 B
TypeScript

import { Router } from 'express'
import { TwitchAPI } from '../util/scraping/extractor/index'
const profileRouter = Router()
const twitch = new TwitchAPI()
profileRouter.get('/users/:username', async (req, res, next) => {
const username = req.params.username
let streamerData = await twitch.getStreamerInfo(username)
.catch(next)
if (streamerData)
res.send(streamerData)
})
profileRouter.get('/discover', async (req, res, next) => {
let discoveryData = await twitch.getDirectory(50)
res.send(discoveryData)
})
profileRouter.get('/discover/:game', async (req, res, next) => {
let discoveryData = await twitch.getDirectoryGame(req.params.game, 50)
res.send(discoveryData)
})
export default profileRouter