Skip to content

Commit d2e1de0

Browse files
feat: add WebPush support for notifications and implement rate limiting
- Added WebPush subscription keys (webPushP256dh, webPushAuth) to device schema and GraphQL types. - Updated registerDevice mutation to require WebPush keys for web platform. - Enhanced notification sending logic to handle WebPush messages with proper payload construction. - Implemented a scheduler for processing scheduled notifications. - Introduced a worker for handling notification jobs with retry logic. - Added rate limiting middleware for GraphQL endpoint. - Created utility functions for Redis connection and rate limiting. - Established a notification queue using BullMQ for managing notification jobs.
1 parent 71adf82 commit d2e1de0

32 files changed

+2325
-165
lines changed

.env.example

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,19 @@ HOST=localhost
1818
# Push provider configurations are stored per-app in the database
1919
# No global defaults needed - each app has its own FCM/APNs/WebPush config
2020

21-
# Redis (for queue system - to be implemented)
22-
REDIS_URL=redis://localhost:6379
21+
# Redis (for queue system and rate limiting)
22+
REDIS_HOST=localhost
23+
REDIS_PORT=6379
24+
REDIS_PASSWORD=
25+
26+
# Rate Limiting
27+
RATE_LIMIT_DEFAULT=1000
28+
RATE_LIMIT_WINDOW=3600
29+
# Set to true to disable rate limiting in development
30+
RATE_LIMIT_DISABLED=false
31+
32+
# Scheduler (for scheduled notifications)
33+
SCHEDULER_ENABLED=true
2334

2435
# Email Configuration (for notifications about service)
2536
SMTP_HOST=smtp.gmail.com

app/components/AppSidebar.vue

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
} from 'abckit/shadcn/sidebar'
1212
import {
1313
BarChart3,
14+
Bell,
1415
FileText,
1516
Github,
1617
Home,
@@ -63,6 +64,12 @@ const navTools = computed(() => [
6364
icon: Smartphone,
6465
isActive: route.path.startsWith('/devices'),
6566
},
67+
{
68+
title: 'Web Push Test',
69+
url: '/test-webpush',
70+
icon: Bell,
71+
isActive: route.path.startsWith('/test-webpush'),
72+
},
6673
])
6774
6875
const navHelp = computed(() => [

app/layouts/default.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ const pageTitle = computed(() => {
2020
return 'Send Notification'
2121
if (path.startsWith('/devices'))
2222
return 'Device Testing'
23+
if (path.startsWith('/test-webpush'))
24+
return 'Web Push Test'
2325
if (path.startsWith('/docs'))
2426
return 'Documentation'
2527
if (path.startsWith('/settings'))

0 commit comments

Comments
 (0)