Skip to content

Commit b23ca8d

Browse files
committed
remove octokit err handling
1 parent c6e6b87 commit b23ca8d

3 files changed

Lines changed: 21 additions & 66 deletions

File tree

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
workingDirectory: "packages/app"
3535
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
3636
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
37-
preCommands: pnpm install && DEBUG=nitro:* pnpm build
37+
preCommands: pnpm install && pnpm build
3838
command: pages deploy dist --project-name=pkg-pr-new --branch=main
3939
env:
4040
NITRO_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

packages/app/server/plugins/config.ts

Lines changed: 0 additions & 12 deletions
This file was deleted.

packages/app/server/utils/octokit.ts

Lines changed: 20 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -6,66 +6,33 @@ import { App, Octokit } from "octokit";
66

77
let 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

3823
export 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

7138
export async function useOctokitInstallation(

0 commit comments

Comments
 (0)