Skip to content

Commit 5a33720

Browse files
committed
fix: move other instances to parallel
1 parent 96a2e61 commit 5a33720

File tree

3 files changed

+11
-132
lines changed

3 files changed

+11
-132
lines changed

package.json

-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
"nuxt": "latest",
2727
"nuxt-time": "1.0.3",
2828
"nuxt-webhook-validators": "0.1.4",
29-
"octokit": "^4.0.2",
3029
"ohash": "^1.1.4",
3130
"openai": "^4.76.0",
3231
"rgb-to-hsl": "^0.0.3",

pnpm-lock.yaml

-124
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

server/routes/github/webhook.post.ts

+11-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type { Installation, InstallationLite, WebhookEvent } from '@octokit/webhooks-types'
22
import type { H3Event } from 'h3'
3-
import { App } from 'octokit'
3+
import { createAppAuth } from '@octokit/auth-app'
4+
import { Octokit } from '@octokit/rest'
45

56
import { indexIssue, removeIssue, storagePrefixForRepo } from '../../utils/embeddings'
67

@@ -15,7 +16,7 @@ export default defineEventHandler(async (event) => {
1516
const promises: Promise<unknown>[] = []
1617
if ('action' in body && 'installation' in body && !('client_payload' in body)) {
1718
if (body.action === 'created' && 'repositories' in body) {
18-
await addRepos(event, body.installation, body.repositories || [])
19+
promises.push(addRepos(event, body.installation, body.repositories || []))
1920
}
2021
if (body.action === 'deleted' && 'repositories' in body) {
2122
for (const repo of body.repositories || []) {
@@ -33,7 +34,7 @@ export default defineEventHandler(async (event) => {
3334
}
3435
}
3536
if (body.action === 'publicized' && body.installation) {
36-
await addRepos(event, body.installation, [body.repository])
37+
promises.push(addRepos(event, body.installation, [body.repository]))
3738
}
3839
if (body.action === 'privatized') {
3940
promises.push(deleteRepo(event, body.repository))
@@ -71,11 +72,14 @@ export type InstallationRepo = {
7172

7273
async function addRepos(event: H3Event, installation: Installation | InstallationLite, repos: InstallationRepo[]) {
7374
const config = useRuntimeConfig(event)
74-
const app = new App({
75-
appId: config.github.appId,
76-
privateKey: config.github.privateKey,
75+
const octokit = new Octokit({
76+
authStrategy: createAppAuth,
77+
auth: {
78+
appId: config.github.appId,
79+
privateKey: config.github.privateKey,
80+
installationId: installation.id,
81+
},
7782
})
78-
const octokit = await app.getInstallationOctokit(installation.id)
7983

8084
for (const repo of repos) {
8185
if (repo.private) {

0 commit comments

Comments
 (0)