generated from nhcarrigan/template
This commit is contained in:
+11
-2
@@ -7,6 +7,7 @@
|
||||
import fastify from "fastify";
|
||||
import { processGithubEvent } from "../modules/processGitHubEvent.js";
|
||||
import { logger } from "../utils/logger.js";
|
||||
import type { Amari } from "../interfaces/amari.js";
|
||||
import type { GithubPayload } from "../interfaces/github.js";
|
||||
|
||||
const html = `<!DOCTYPE html>
|
||||
@@ -52,8 +53,9 @@ const html = `<!DOCTYPE html>
|
||||
|
||||
/**
|
||||
* Starts up a web server for health monitoring.
|
||||
* @param amari - Amari's instance.
|
||||
*/
|
||||
export const instantiateServer = (): void => {
|
||||
export const instantiateServer = (amari: Amari): void => {
|
||||
try {
|
||||
const server = fastify({
|
||||
logger: false,
|
||||
@@ -67,7 +69,14 @@ export const instantiateServer = (): void => {
|
||||
server.
|
||||
// eslint-disable-next-line @typescript-eslint/naming-convention -- Fastify standard.
|
||||
post<{ Body: GithubPayload }>("/github", async(request, response) => {
|
||||
await processGithubEvent(request, response);
|
||||
try {
|
||||
await processGithubEvent(amari, request, response);
|
||||
} catch (error) {
|
||||
if (!(error instanceof Error)) {
|
||||
return;
|
||||
}
|
||||
await logger.error("/github route", error);
|
||||
}
|
||||
});
|
||||
|
||||
server.listen({ port: 7044 }, (error) => {
|
||||
|
||||
Reference in New Issue
Block a user