diff --git a/index.js b/index.js index 952243e..b44e8d7 100644 --- a/index.js +++ b/index.js @@ -4,6 +4,7 @@ import { mapRepoFromStorageToUi } from "./utils/index.js"; import { getQueryParams } from "./utils/queryParams.js"; import { sortByType } from "./utils/sorting.js"; import { TowtruckDatabase } from "./db/index.js"; +import { handleWebhooks } from "./webhooks/index.js"; nunjucks.configure({ autoescape: true, @@ -11,6 +12,8 @@ nunjucks.configure({ }); const httpServer = createServer(async (request, response) => { + if (await handleWebhooks(request, response)) return; + const url = new URL(request.url, `http://${request.headers.host}`); if (url.pathname !== "/") { diff --git a/octokitApp.js b/octokitApp.js index 6b7c195..e5697b6 100644 --- a/octokitApp.js +++ b/octokitApp.js @@ -1,4 +1,4 @@ -import { App, createNodeMiddleware } from "@octokit/app"; +import { App } from "@octokit/app"; const APP_ID = process.env.APP_ID; const PRIVATE_KEY = process.env.PRIVATE_KEY; @@ -20,10 +20,4 @@ const app = new App({ }, }); -app.webhooks.onAny(({ name }) => { - console.log(name, "event received"); -}); - -const middleware = createNodeMiddleware(app); - -export const OctokitApp = { app, middleware }; +export const OctokitApp = { app };