@@ -6,66 +6,33 @@ import { App, Octokit } from "octokit";
66
77let graphQlWithAuth : typeof graphql
88
9- export function useGithubGraphQL ( event ?: H3Event ) {
9+ export function useGithubGraphQL ( ) {
1010 if ( ! graphQlWithAuth ) {
11- try {
12- const config = useRuntimeConfig ( event ) ;
13- const githubToken = config ?. githubToken ;
14-
15- if ( ! githubToken ) {
16- console . warn ( "GitHub token is not available in runtime config" ) ;
17- // Provide a fallback that will work but return empty results
18- graphQlWithAuth = graphql . defaults ( { } ) ;
19- return { graphql : graphQlWithAuth } ;
20- }
21-
22- graphQlWithAuth = graphql . defaults ( {
23- headers : {
24- authorization : `token ${ githubToken } ` ,
25- } ,
26- } ) ;
27- } catch ( error ) {
28- console . error ( "Error initializing GitHub GraphQL client:" , error ) ;
29- // Provide a fallback that will work but return empty results
30- graphQlWithAuth = graphql . defaults ( { } ) ;
31- }
11+ const { githubToken } = useRuntimeConfig ( )
12+ graphQlWithAuth = graphql . defaults ( {
13+ headers : {
14+ authorization : `token ${ githubToken } ` ,
15+ } ,
16+ } )
3217 }
3318 return {
3419 graphql : graphQlWithAuth ,
35- } ;
20+ }
3621}
3722
3823export function useOctokitApp ( event : H3Event ) : AppType {
39- try {
40- const config = useRuntimeConfig ( event ) ;
41- const { appId, privateKey, webhookSecret, ghBaseUrl } = config ;
42-
43- if ( ! appId || ! privateKey || ! webhookSecret ) {
44- console . warn ( "Missing required GitHub App credentials in runtime config" ) ;
45- // Return a minimal mock App that won't throw errors during initialization
46- return {
47- octokit : { request : async ( ) => ( { data : { id : 0 } } ) } ,
48- getInstallationOctokit : async ( ) => ( { } )
49- } as any ;
50- }
51-
52- return new App ( {
53- appId,
54- privateKey,
55- webhooks : { secret : webhookSecret } ,
56- Octokit : Octokit . defaults ( {
57- baseUrl : ghBaseUrl ,
58- paginateRest
59- } ) ,
60- } ) as unknown as AppType ;
61- } catch ( error ) {
62- console . error ( "Error initializing GitHub App:" , error ) ;
63- // Return a minimal mock App that won't throw errors
64- return {
65- octokit : { request : async ( ) => ( { data : { id : 0 } } ) } ,
66- getInstallationOctokit : async ( ) => ( { } )
67- } as any ;
68- }
24+ const { appId, privateKey, webhookSecret, ghBaseUrl } =
25+ useRuntimeConfig ( event ) ;
26+
27+ return new App ( {
28+ appId,
29+ privateKey,
30+ webhooks : { secret : webhookSecret } ,
31+ Octokit : Octokit . defaults ( {
32+ baseUrl : ghBaseUrl ,
33+ paginateRest
34+ } ) ,
35+ } ) as unknown as AppType ;
6936}
7037
7138export async function useOctokitInstallation (
0 commit comments