feat: Web Push notifications

- VAPID-based push via web-push package
- push_subscriptions table: endpoint + keys per user (upsert on conflict)
- GET /api/push/vapid-key — public key for subscribe flow
- POST/DELETE /api/push/subscribe — store/remove subscription
- POST /api/push/test — manual test notification
- Hourly scheduler: notifies users day before homework due + countdown expires
- SW: push event handler shows notification; notificationclick opens /app
- Settings: Push section with enable/disable/test buttons, auto-detects
  browser support and VAPID availability
This commit is contained in:
Simon
2026-04-23 11:44:28 +02:00
parent a765d2d088
commit 7d464c21eb
8 changed files with 344 additions and 7 deletions
+5 -1
View File
@@ -6,6 +6,7 @@ const path = require('path');
const routes = require('./src/routes');
const { router: filesRouter } = require('./src/files');
const teacherRouter = require('./src/teacher');
const { startNotificationScheduler } = require('./src/push');
if (!process.env.JWT_SECRET) {
console.error('FATAL: JWT_SECRET environment variable is not set.');
@@ -51,4 +52,7 @@ app.get('/app', html('app.html'));
app.get('/reset-password', html('reset-password.html'));
app.get('/{*path}', html('index.html'));
app.listen(PORT, '127.0.0.1', () => console.log(`info1 läuft auf :${PORT}`));
app.listen(PORT, '127.0.0.1', () => {
console.log(`info1 läuft auf :${PORT}`);
startNotificationScheduler();
});