Conversation
…shboard badge - Add InAppNotification model to Prisma schema - Rewrite inAppHandler to persist to Postgres (with in-memory fallback) - Add gateway notifications module (GET /api/v1/notifications, GET unread-count, POST /:id/read) - Add dashboard navbar unread badge with notification dropdown - Add unit tests for the notifications service - Wire up Prisma client in the gateway bootstrap - Update Swagger tags Closes mallonepay#43
|
@waterWang is attempting to deploy a commit to the scarface-dev1's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
Hi! 👋 To get this reviewed and merged: please rebase your branch onto Happy to take another look once it's rebased. Thanks! 🙏 |
|
Thanks for the contribution! This was part of the Stellar Wave 8 / GrantFox issue set. The issue this addresses is now implemented directly in Closing as superseded. If you believe part of this work is not covered by the current |
Summary
Persist in-app notifications in Postgres so they survive restarts, are visible across gateway instances, and are reachable from the dashboard.
Changes
packages/database/prisma/schema.prisma: AddedInAppNotificationmodel (providerId, event, data JSON, read, createdAt) with indexes on[providerId]and[providerId, read].packages/notifications/src/index.ts: RewroteinAppHandler.send()to persist to Postgres when a Prisma client is wired up, with the existing in-memory queue preserved as a fallback for tests/no-DB environments. AddedsetPrismaClient(), plus DB-backedgetInAppNotifications(),markInAppRead(), andgetUnreadCount().apps/gateway/src/modules/notifications/: New module with:GET /api/v1/notifications— paginated, wallet-scoped (default limit 50, supportsunreadOnly)GET /api/v1/notifications/unread-count— unread badge countPOST /api/v1/notifications/:id/read— mark a notification readapps/dashboard/src/components/layout/navbar.tsx: Bell icon now shows a live unread-count badge (polled every 30s) and opens a dropdown listing recent notifications with mark-as-read.apps/gateway/src/app.module.ts: RegisteredNotificationsModule.apps/gateway/src/main.ts: AddednotificationsOpenAPI tag.notifications.service.spec.tscovers service + in-memory fallback paths (100% coverage on the new service).Acceptance criteria
DATABASE_URLis set)prisma migrate devgenerates it)pnpm exec nx test gateway— new notifications suite passes (pre-existing failures in admin/analytics/payments/routes are unrelated: implicit-any TS errors and a DNS resolution test)How to test
Closes #43