feat(demo): Mail-Benachrichtigungen bei Demo-Ablauf

Neue Mail-Templates (lib/mail.js):
- sendDemoExpiryReminderMail: 7 Tage vor Ablauf
- sendDemoLastDayMail: 1 Tag vor Ablauf (Letzter-Tag-Reminder)
- sendDemoExpiredMail: am Ablauftag (setzt Tenant-Status abgelaufen)

Cron-Job (lib/expiryJob.js):
- node-cron taeglich 08:00 UTC (anpassbar via CRON_EXPIRY_AT)
- 3 Windows pruefen, idempotent ueber notified_*_at Timestamp-Spalten
- BETWEEN-Fenster [n-1, n] Tage fuer Robustheit

DB-Migration (bootstrap.js):
- Beim Backend-Start automatisches ALTER TABLE fuer
  notified_7d_at, notified_1d_at, notified_expired_at (idempotent)

Manueller Test: docker exec pfandsystem-demo-backend node -e "
  import(\"./lib/expiryJob.js\").then(m => m.runExpiryCheck())"
This commit is contained in:
christian
2026-05-26 15:59:25 +00:00
parent d9c10211d8
commit 3228fe4ab3
5 changed files with 218 additions and 33 deletions

View File

@@ -15,6 +15,7 @@ import mitarbeiterRoutes from './routes/mitarbeiter.js';
import geraeteRoutes from './routes/geraete.js';
import { bootstrapSuperAdmin } from './scripts/bootstrap.js';
import { startExpiryCron } from './lib/expiryJob.js';
dotenv.config();
@@ -56,6 +57,7 @@ app.use((req, res) => res.status(404).json({ error: 'Route nicht gefunden' }));
bootstrapSuperAdmin()
.catch(err => console.error('Bootstrap-Fehler:', err))
.finally(() => {
startExpiryCron();
app.listen(PORT, '0.0.0.0', () => {
console.log(`Backend läuft auf Port ${PORT}`);
});