ADR 0003: VAPID self-hosted today, DeviceToken model agnostic to
platform so iOS/Android (Expo/APNs/FCM) plug in as new senders later.
Backend (apps/api/src/modules/notifications)
- sender.ts: NotificationSender interface, WebPushSender via VAPID
- notifications.routes.ts: GET /me/notifications/config, POST/DELETE
/me/device-tokens, PATCH /me/notifications/settings, POST /me/notifications/test
- scheduler.ts: node-cron Mon 09:00 Europe/Rome for weekly weigh-in
reminder; auto-cleanup of expired tokens on 404/410
- env: VAPID_PUBLIC_KEY/PRIVATE_KEY/SUBJECT (all optional → push gracefully off)
Frontend
- public/sw.js minimal (push + notificationclick)
- lib/notifications/push-client.ts: subscribe / unsubscribe / getCurrentSubscription
- profile/notifications-{actions,panel}.tsx: editorial panel with toggles,
device list, "send test", per-device removal
- pushReady requires both permission AND active subscription (covers the
case where the user revoked the SW but kept the browser permission)
Schema
- DeviceToken { userId, platform, endpoint, p256dh, auth, token, userAgent,
createdAt, lastSeenAt } with unique(userId, endpoint)
- ExtendedPrismaClient type exported from @ketopath/db
- NotificationSettings zod schema in @ketopath/shared
Tooling
- lint-staged: split .js out of eslint glob so service worker is only
formatted (it lives outside the TS project)
i18n
- Notifications namespace (it) with typed error keys
Smoke tested: POST /me/device-tokens 201, POST /me/notifications/test 200,
real push delivered to a macOS Chrome device.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
62 lines
1.9 KiB
JSON
62 lines
1.9 KiB
JSON
{
|
|
"name": "ketopath",
|
|
"version": "0.0.0",
|
|
"private": true,
|
|
"description": "KetoPath monorepo — web app per la gestione di chetogenica e digiuno intermittente",
|
|
"packageManager": "pnpm@9.12.0",
|
|
"engines": {
|
|
"node": ">=20.11",
|
|
"pnpm": ">=9"
|
|
},
|
|
"scripts": {
|
|
"dev": "pnpm --parallel --filter \"./apps/*\" dev",
|
|
"dev:web": "pnpm --filter @ketopath/web dev",
|
|
"dev:api": "pnpm --filter @ketopath/api dev",
|
|
"build": "pnpm --filter \"./apps/*\" build",
|
|
"start": "pnpm --filter \"./apps/*\" start",
|
|
"lint": "eslint . --max-warnings=0",
|
|
"lint:fix": "eslint . --fix",
|
|
"format": "prettier --write .",
|
|
"format:check": "prettier --check .",
|
|
"typecheck": "tsc -b",
|
|
"test": "vitest run",
|
|
"test:watch": "vitest",
|
|
"test:coverage": "vitest run --coverage",
|
|
"test:e2e": "pnpm --filter @ketopath/web test:e2e",
|
|
"db:generate": "pnpm --filter @ketopath/db db:generate",
|
|
"db:migrate": "pnpm --filter @ketopath/db db:migrate",
|
|
"db:migrate:deploy": "pnpm --filter @ketopath/db db:migrate:deploy",
|
|
"db:studio": "pnpm --filter @ketopath/db db:studio",
|
|
"db:format": "pnpm --filter @ketopath/db db:format",
|
|
"db:seed": "pnpm --filter @ketopath/db db:seed",
|
|
"prepare": "husky"
|
|
},
|
|
"devDependencies": {
|
|
"@types/node": "^20.12.7",
|
|
"@typescript-eslint/eslint-plugin": "^7.7.0",
|
|
"@typescript-eslint/parser": "^7.7.0",
|
|
"eslint": "^8.57.0",
|
|
"eslint-config-prettier": "^9.1.0",
|
|
"eslint-plugin-import": "^2.29.1",
|
|
"husky": "^9.0.11",
|
|
"lint-staged": "^15.2.2",
|
|
"prettier": "^3.2.5",
|
|
"prettier-plugin-tailwindcss": "^0.5.14",
|
|
"typescript": "5.4.5",
|
|
"vitest": "^1.6.0",
|
|
"@vitest/coverage-v8": "^1.6.0"
|
|
},
|
|
"lint-staged": {
|
|
"*.{ts,tsx,jsx,cjs,mjs}": [
|
|
"eslint --fix --max-warnings=0",
|
|
"prettier --write"
|
|
],
|
|
"*.js": [
|
|
"prettier --write"
|
|
],
|
|
"*.{json,md,yml,yaml,css}": [
|
|
"prettier --write"
|
|
]
|
|
}
|
|
}
|