feat: webhook for forms
Node.js CI / Lint and Test (push) Successful in 45s

This commit is contained in:
2025-08-27 18:55:22 -07:00
parent b92fe0a730
commit d5c0abe4d8
6 changed files with 140 additions and 2 deletions
+15
View File
@@ -5,9 +5,11 @@
*/
import fastify from "fastify";
import { processFormSubmission } from "../modules/processFormSubmission.js";
import { processGithubEvent } from "../modules/processGitHubEvent.js";
import { logger } from "../utils/logger.js";
import type { Amari } from "../interfaces/amari.js";
import type { FormSubmission } from "../interfaces/formSubmission.js";
import type { GithubPayload } from "../interfaces/github.js";
const html = `<!DOCTYPE html>
@@ -79,6 +81,19 @@ export const instantiateServer = (amari: Amari): void => {
}
});
server.
// eslint-disable-next-line @typescript-eslint/naming-convention -- Fastify standard.
post<{ Body: FormSubmission }>("/form", async(request, response) => {
try {
await processFormSubmission(amari, request, response);
} catch (error) {
if (!(error instanceof Error)) {
return;
}
await logger.error("/form route", error);
}
});
server.listen({ port: 7044 }, (error) => {
if (error) {
void logger.error("instantiate server", error);