@@ -58,7 +58,29 @@ export interface OAuthTwitchConfig {
5858 redirectURL ?: string
5959}
6060
61- export function defineOAuthTwitchEventHandler ( { config, onSuccess, onError } : OAuthConfig < OAuthTwitchConfig > ) {
61+ interface TwitchUser {
62+ id : string
63+ login : string
64+ display_name : string
65+ type : string
66+ broadcaster_type : string
67+ description : string
68+ profile_image_url : string
69+ offline_image_url : string
70+ view_count : number
71+ email ?: string
72+ created_at : string
73+ }
74+
75+ interface TwitchTokens {
76+ access_token : string
77+ expires_in : number
78+ refresh_token : string
79+ scope : string [ ]
80+ token_type : string
81+ }
82+
83+ export function defineOAuthTwitchEventHandler ( { config, onSuccess, onError } : OAuthConfig < OAuthTwitchConfig , { user : TwitchUser , tokens : TwitchTokens } > ) {
6284 return eventHandler ( async ( event : H3Event ) => {
6385 config = defu ( config , useRuntimeConfig ( event ) . oauth ?. twitch , {
6486 authorizationURL : 'https://id.twitch.tv/oauth2/authorize' ,
@@ -107,9 +129,8 @@ export function defineOAuthTwitchEventHandler({ config, onSuccess, onError }: OA
107129 }
108130
109131 const accessToken = tokens . access_token
110- // TODO: improve typing
111- // eslint-disable-next-line @typescript-eslint/no-explicit-any
112- const users : any = await $fetch ( 'https://api.twitch.tv/helix/users' , {
132+
133+ const users = await $fetch < { data : TwitchUser [ ] } > ( 'https://api.twitch.tv/helix/users' , {
113134 headers : {
114135 'Client-ID' : config . clientId ,
115136 'Authorization' : `Bearer ${ accessToken } ` ,
0 commit comments