Workflow-App/Workflow/app/api/mail-health/route.ts
sjcoetzeesj-coder 11d0178ab1 feat: commit Workflow app source; move CIPC credentials to env
Adds the full Next.js app (app/, components/, lib/, scripts/, assets/,
docs/, Dockerfile, compose, configs) to version control.

Security:
- CIPC BizPortal customer-code logins (Login 1 + Login 3) now read
  CIPC_LOGIN1_CODE / CIPC_LOGIN1_PASSWORD / CIPC_LOGIN3_CODE /
  CIPC_LOGIN3_PASSWORD from .env.local instead of source.
- BizPortal personal login in apply-bizportal route reads
  BIZPORTAL_ID_NO / BIZPORTAL_PASSWORD.
- Added .env.example as the committed template.

.gitignore excludes .env*, node_modules, .next, logs, sqlite, Playwright
storage_state.json (live CIPC cookies), scratch dirs, client PDFs and
debug screenshots.
2026-10-18 15:21:45 +02:00

32 lines
No EOL
890 B
TypeScript

// app/api/mail-health/route.ts
// GET /api/mail-health
//
// One call to answer: "will a letter actually send right now?"
// Checks the himalaya binary, its config, live credentials for both
// accounts, and the PDF service. Returns ok:false if anything would
// silently drop a letter.
import { NextResponse } from "next/server";
import { checkMailHealth } from "@/lib/mail-health";
export const dynamic = "force-dynamic";
export async function GET() {
try {
const result = await checkMailHealth();
return NextResponse.json(result, { status: result.ok ? 200 : 503 });
} catch (err) {
return NextResponse.json(
{
ok: false,
checks: [
{
name: "health check",
status: "fail",
detail: err instanceof Error ? err.message : "unknown error",
},
],
},
{ status: 500 }
);
}
}