From 4f1e974623f7e38693d3e202cd387c51f652b9d8 Mon Sep 17 00:00:00 2001 From: Elizabeth Hunt Date: Sun, 15 Dec 2024 01:57:28 -0800 Subject: logout on end --- src/api.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/api.ts') diff --git a/src/api.ts b/src/api.ts index cfb446a..722dc70 100644 --- a/src/api.ts +++ b/src/api.ts @@ -1,5 +1,5 @@ +import { transformDurations } from "./duration"; import { perform } from "./email"; -import type { EmailJob } from "./job"; import { ConsoleLogger } from "./logger"; export const main = (port: number) => { @@ -10,7 +10,12 @@ export const main = (port: number) => { const url = new URL(req.url); if (req.method === "POST" && url.pathname === "/api/email") { - const job: EmailJob = await req.json(); + const prevalidatedJob = transformDurations(await req.json()); + if (prevalidatedJob._tag === "Left") { + return new Response(prevalidatedJob.left, { status: 400 }); + } + const job = prevalidatedJob.right; + const jobInsensitive = structuredClone(job); jobInsensitive.from.username = "****REDACTED****"; jobInsensitive.from.password = "****REDACTED****"; -- cgit v1.2.3-70-g09d2