-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
af03df3
commit 501c687
Showing
3 changed files
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import axios from "axios"; | ||
import { type Resolvers } from "."; | ||
import { getClientToken } from "~/auth"; | ||
|
||
const watchtimeResolver: Resolvers["Query"] = { | ||
getTwitchUser: async (_, query) => { | ||
const queryString = `${isNaN(Number(query.user)) ? "login" : "id"}=${query.user}`; | ||
|
||
const res = await axios.get( | ||
"https://api.twitch.tv/helix/users?" + queryString, | ||
{ | ||
headers: { | ||
Authorization: `Bearer ${await getClientToken()}`, | ||
"Client-Id": process.env.TWITCH_CLIENT_ID, | ||
}, | ||
} | ||
), | ||
userData = res.data.data as { | ||
id: string; | ||
login: string; | ||
display_name: string; | ||
type: string; | ||
broadcaster_type: string; | ||
description: string; | ||
profile_image_url: string; | ||
view_count: number; | ||
created_at: string; | ||
}[]; | ||
return userData; | ||
}, | ||
}; | ||
export default watchtimeResolver; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters