Skip to content

Commit 58eacf0

Browse files
authored
Merge pull request #114 from arkedge/healthcheck
add healthcheck endpoint
2 parents b0969ab + 19a1789 commit 58eacf0

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/index.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,5 +211,17 @@ app.webhooks.on(
211211
handleEvent(pullRequestEventPayloadToArg),
212212
);
213213

214-
// eslint-disable-next-line @typescript-eslint/no-misused-promises
215-
http.createServer(createNodeMiddleware(app)).listen(8124);
214+
const middleware = createNodeMiddleware(app);
215+
http
216+
// eslint-disable-next-line @typescript-eslint/no-misused-promises
217+
.createServer(async (req, res) => {
218+
// `middleware` returns `false` when `req` is unhandled
219+
if (await middleware(req, res)) return;
220+
if (req.url === "/healthcheck") {
221+
res.writeHead(200);
222+
} else {
223+
res.writeHead(404);
224+
}
225+
res.end();
226+
})
227+
.listen(8124);

0 commit comments

Comments
 (0)