Workflow-App/Workflow/scripts/check-mail.ps1
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

55 lines
No EOL
1.9 KiB
PowerShell

# scripts/check-mail.ps1
# One command to prove the letter pipeline works BEFORE you rely on it.
#
# powershell -ExecutionPolicy Bypass -File scripts\check-mail.ps1
#
# Exits 0 when a resignation letter would actually be delivered.
# Exits 1 when something would silently drop it, and prints the fix.
#
# Why this exists: on 2026-10-09 a resignation letter for SUNE PIETERS was
# reported as "sent successfully" while himalaya was missing from PATH and
# the PDF service was down. Nothing failed loudly. This script makes it loud.
param(
[string]$BaseUrl = 'http://localhost:6001'
)
$ErrorActionPreference = 'Stop'
try {
$res = Invoke-WebRequest -Uri "$BaseUrl/api/mail-health" -UseBasicParsing -TimeoutSec 120
$body = $res.Content | ConvertFrom-Json
} catch {
Write-Host ''
Write-Host ' [FAIL] Could not reach the app health endpoint.' -ForegroundColor Red
Write-Host " $($_.Exception.Message)"
Write-Host ''
Write-Host ' Is the dev server running on port 6001?' -ForegroundColor Yellow
Write-Host ' Then run: powershell -ExecutionPolicy Bypass -File scripts\check-mail.ps1' -ForegroundColor Yellow
Write-Host ''
exit 1
}
$icon = @{ ok = ' [ OK ]'; warn = ' [WARN]'; fail = ' [FAIL]' }
$colour = @{ ok = 'Green'; warn = 'Yellow'; fail = 'Red' }
Write-Host ''
Write-Host ' Workflow mail health check' -ForegroundColor Cyan
Write-Host ' --------------------------' -ForegroundColor DarkGray
Write-Host ''
foreach ($c in $body.checks) {
Write-Host ("{0} {1,-18} {2}" -f $icon[$c.status], $c.name, $c.detail) -ForegroundColor $colour[$c.status]
if ($c.fix) { Write-Host (" -> {0}" -f $c.fix) -ForegroundColor DarkYellow }
}
Write-Host ''
if ($body.ok) {
Write-Host ' RESULT: letters will send.' -ForegroundColor Green
Write-Host ''
exit 0
} else {
Write-Host ' RESULT: letters would be LOST. Fix the [FAIL] items above.' -ForegroundColor Red
Write-Host ''
exit 1
}