Skip to content

Commit

Permalink
Allow Towtruck server to listen for webhooks
Browse files Browse the repository at this point in the history
  • Loading branch information
danlivings-dxw committed Oct 10, 2024
1 parent bb65e2f commit 2a1624d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
3 changes: 3 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@ 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,
watch: true,
});

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 !== "/") {
Expand Down
10 changes: 2 additions & 8 deletions octokitApp.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { readFileSync } from "fs";
import { App, createNodeMiddleware } from "@octokit/app";
import { App } from "@octokit/app";

const APP_ID = process.env.APP_ID;
const PRIVATE_KEY_PATH = process.env.PRIVATE_KEY_PATH;
Expand All @@ -21,10 +21,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 };

0 comments on commit 2a1624d

Please sign in to comment.