diff options
author | Elizabeth Hunt <elizabeth.hunt@simponic.xyz> | 2024-12-15 01:57:28 -0800 |
---|---|---|
committer | Elizabeth Hunt <elizabeth.hunt@simponic.xyz> | 2024-12-15 02:05:18 -0800 |
commit | 4f1e974623f7e38693d3e202cd387c51f652b9d8 (patch) | |
tree | 947892a7f7608cb31424c8c37adea7c26a857bee /src/api.ts | |
parent | 53187bede7e871ceca8fe4fabd18822002eb9316 (diff) | |
download | uptime-4f1e974623f7e38693d3e202cd387c51f652b9d8.tar.gz uptime-4f1e974623f7e38693d3e202cd387c51f652b9d8.zip |
logout on end
Diffstat (limited to 'src/api.ts')
-rw-r--r-- | src/api.ts | 9 |
1 files changed, 7 insertions, 2 deletions
@@ -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****"; |