safetwitch/server/routes/profileRoute.ts

17 lines
435 B
TypeScript
Raw Normal View History

2023-03-07 01:19:05 -05:00
import { Router } from 'express'
import { TwitchAPI } from '../util/scraping/extractor/index'
2023-03-07 17:54:53 -05:00
2023-03-07 01:19:05 -05:00
const profileRouter = Router()
const twitch = new TwitchAPI()
2023-03-07 01:19:05 -05:00
2023-03-07 10:29:05 -05:00
profileRouter.get('/users/:username', async (req, res, next) => {
2023-03-07 01:19:05 -05:00
const username = req.params.username
let streamerData = await twitch.getStreamerInfo(username)
2023-03-07 10:29:05 -05:00
.catch(next)
2023-03-07 01:19:05 -05:00
2023-03-10 15:23:23 -05:00
if (streamerData)
res.send(streamerData)
2023-03-07 01:19:05 -05:00
})
export default profileRouter