From 6548ca2e81b5425da6ef73b073a983864ac5d161 Mon Sep 17 00:00:00 2001 From: Nate Sawant Date: Tue, 18 Jun 2024 22:44:12 -0400 Subject: [PATCH] Delete unused test route --- src/server/api/tests/test-webhook.ts | 66 ---------------------------- 1 file changed, 66 deletions(-) delete mode 100644 src/server/api/tests/test-webhook.ts diff --git a/src/server/api/tests/test-webhook.ts b/src/server/api/tests/test-webhook.ts deleted file mode 100644 index 5a73f7e..0000000 --- a/src/server/api/tests/test-webhook.ts +++ /dev/null @@ -1,66 +0,0 @@ -import { App } from "octokit"; -import { readFileSync } from "fs"; - -async function testWebHook(): Promise { - const repo = "cy2550"; - - // Placeholder... need to figure out how to get access token - const owner = "wyattchris"; - - const privatePem = readFileSync("private-key.pem", { - encoding: "utf-8", - }); - - const app = new App({ - appId: process.env.GITHUB_APP_ID ?? "", - privateKey: privatePem, - }); - - const response = await app.octokit.request( - "GET /repos/{owner}/{repo}/installation", - { - owner: "wyattchris", - repo: "cy2550", - headers: { - "X-GitHub-Api-Version": "2022-11-28", - }, - }, - ); - - const installationId = response.data.id; - - const octokit = await app.getInstallationOctokit(installationId); - - try { - const response = await octokit.request( - `POST /repos/${owner}/${repo}/hooks`, - { - owner: "wyattchris", - repo: "cy2550", - name: "web", - active: true, - events: ["push", "pull_request"], - config: { - url: "https://example.com/webhook", - content_type: "json", - insecure_ssl: "1", - }, - headers: { - "X-GitHub-Api-Version": "2022-11-28", - }, - }, - ); - - // Assuming successful creation of webhook - console.log(response.data); - // eslint-disable-next-line @typescript-eslint/no-unsafe-return - return response.data; - } catch (error) { - // eslint-disable-next-line @typescript-eslint/restrict-plus-operands - throw new Error("Failed to create webhook: " + error); - } -} - -testWebHook() - .then(() => console.log("Webhook created!")) - .catch((error) => console.error(error));