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 17, 2024
1 parent 6c1a175 commit 0ed3848
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,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;
Expand All @@ -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 };

0 comments on commit 0ed3848

Please sign in to comment.