mirror of
https://codeberg.org/SafeTwitch/safetwitch-backend.git
synced 2024-12-22 13:13:00 -05:00
Add search endpoint
This commit is contained in:
parent
65a6c62b38
commit
7bf75fa99e
5 changed files with 559 additions and 467 deletions
|
@ -23,8 +23,10 @@ profileRouter.get('/discover', async (req, res, next) => {
|
|||
let discoveryData;
|
||||
if (cursor) {
|
||||
discoveryData = await twitch.getDirectory(15, cursor)
|
||||
.catch(next)
|
||||
} else {
|
||||
discoveryData = await twitch.getDirectory(15)
|
||||
.catch(next)
|
||||
}
|
||||
|
||||
res.send({
|
||||
|
@ -69,4 +71,20 @@ profileRouter.get('/badges', async (req, res, next) => {
|
|||
})
|
||||
})
|
||||
|
||||
profileRouter.get('/search', async (req, res, next) => {
|
||||
const query = req.query.query
|
||||
if(!query)
|
||||
return res.status(400).send({
|
||||
status: 'error',
|
||||
message: 'No query provided'
|
||||
})
|
||||
|
||||
const result = await twitch.getSearchResult(query.toString())
|
||||
.catch(next)
|
||||
res.send({
|
||||
status: 'ok',
|
||||
data: result
|
||||
})
|
||||
})
|
||||
|
||||
export default profileRouter
|
|
@ -5,7 +5,7 @@ export interface Category {
|
|||
displayName: string
|
||||
viewers: number
|
||||
tags: Tag[]
|
||||
createdAt: Date
|
||||
cursor: string
|
||||
createdAt?: Date
|
||||
cursor?: string
|
||||
image: string
|
||||
}
|
|
@ -17,13 +17,12 @@ export interface StreamData {
|
|||
export interface StreamerData {
|
||||
username: string
|
||||
followers: number
|
||||
followersAbbv: string
|
||||
isLive: boolean
|
||||
about: string
|
||||
socials?: Social[]
|
||||
pfp: string
|
||||
stream?: StreamData | null
|
||||
isPartner: boolean
|
||||
isPartner: boolean | null
|
||||
colorHex: string
|
||||
id: number
|
||||
}
|
||||
|
|
|
@ -5,5 +5,5 @@ export const errorHandler = (err: Error, req: Request, res: Response, next: Next
|
|||
return next(err)
|
||||
}
|
||||
|
||||
res.status(500).send({ status: 'error', message: err.message})
|
||||
res.status(500).send({ status: 'error', message: err})
|
||||
}
|
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue