dubs-server 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/settings.local.json +280 -0
- package/CLAUDE.md +46 -0
- package/CONNECT4_PRODUCTION_DEPLOY.md +155 -0
- package/CURRENT_SESSION.md +171 -0
- package/CURRENT_SESSION_DRAW.md +516 -0
- package/MARCH_MADNESS_SURVIVOR.md +254 -0
- package/PANDA.md +166 -0
- package/Procfile +4 -0
- package/README.md +476 -0
- package/controllers/livescoresController.js +376 -0
- package/controllers/pickemController.js +554 -0
- package/controllers/survivorAdminController.js +887 -0
- package/controllers/survivorController.js +623 -0
- package/cron/oracleMonitor.js +77 -0
- package/cron/pickemOracleMonitor.js +73 -0
- package/data/jackpot-history.json +952 -0
- package/data/ncaaTeams.js +406 -0
- package/documentation/API_SECURITY_GUIDE.md +327 -0
- package/documentation/ARCADE_API.md +593 -0
- package/documentation/ARCADE_IMPLEMENTATION_SUMMARY.md +399 -0
- package/documentation/ARCADE_QUICKSTART.md +242 -0
- package/documentation/AUTOMATIC_MODE_ORACLE.md +321 -0
- package/documentation/BUG_FIX_COHORT_DATE_DISPLAY.md +171 -0
- package/documentation/CLAIM_MIGRATION_INSTRUCTIONS.md +52 -0
- package/documentation/CLAIM_STATUS_FIX.md +67 -0
- package/documentation/CLI_TOOL_GUIDE.md +372 -0
- package/documentation/COHORT_RETENTION_ANALYSIS.md +295 -0
- package/documentation/COHORT_RETENTION_IMPLEMENTATION_COMPLETE.md +461 -0
- package/documentation/COHORT_RETENTION_SUMMARY.md +204 -0
- package/documentation/COMPLETE_PROJECT_SUMMARY.md +490 -0
- package/documentation/DATABASE_QUERIES.md +269 -0
- package/documentation/DATABASE_RETENTION_POLICY.md +390 -0
- package/documentation/DATABASE_SETUP_GUIDE.md +361 -0
- package/documentation/DATABASE_SETUP_SUMMARY.md +247 -0
- package/documentation/DEMO_API_CURL_COMMANDS.md +656 -0
- package/documentation/DEPLOYMENT_SUMMARY.txt +100 -0
- package/documentation/DUPLICATE_NOTIFICATIONS_FIXED.md +201 -0
- package/documentation/EXCHANGE_RATES_INTEGRATION.md +371 -0
- package/documentation/FINAL_API_PROTECTION_TABLE.md +175 -0
- package/documentation/GAME_START_NOTIFICATIONS_DEPLOYMENT.md +256 -0
- package/documentation/GAME_START_NOTIFICATIONS_INTEGRATION.md +275 -0
- package/documentation/HEROKU_DEPLOYMENT.md +134 -0
- package/documentation/HEROKU_SCHEDULER_SETUP.md +271 -0
- package/documentation/JACKPOT_API.md +521 -0
- package/documentation/JACKPOT_DEPLOYMENT_GUIDE.md +362 -0
- package/documentation/JWT_IMPLEMENTATION_SUMMARY.md +373 -0
- package/documentation/JWT_QUICK_SETUP.md +268 -0
- package/documentation/JWT_TESTING_GUIDE.md +404 -0
- package/documentation/KEEPER_RECOVERY_GUIDE.md +381 -0
- package/documentation/KEEPER_SETUP.md +206 -0
- package/documentation/KEEPER_STATE_MACHINE.md +423 -0
- package/documentation/LATEST_PRODUCTION_SETUP.md +387 -0
- package/documentation/LOCAL_VOTING_TEST.md +279 -0
- package/documentation/ORACLE_FIXES_SUMMARY.md +188 -0
- package/documentation/ORACLE_POSTGRESQL_UPDATE.md +202 -0
- package/documentation/PAYMENT_DEPLOYMENT.md +209 -0
- package/documentation/PNL_TRACKING_SETUP.md +189 -0
- package/documentation/PREVENTING_LOCKUP_ERRORS.md +472 -0
- package/documentation/PRODUCTION_READY_SUMMARY.md +227 -0
- package/documentation/PUBLIC_VS_PRIVATE_ENDPOINTS.md +278 -0
- package/documentation/QUICK_AUTH_SETUP.md +99 -0
- package/documentation/QUICK_DEPLOY.md +224 -0
- package/documentation/QUICK_FIX.md +114 -0
- package/documentation/QUICK_START.md +152 -0
- package/documentation/REFEREE_MODE_GUIDE.md +392 -0
- package/documentation/RETENTION_CORE_ACTION_UPDATE.md +313 -0
- package/documentation/RETENTION_UPDATE_SUMMARY.md +108 -0
- package/documentation/RUN_MIGRATION_NOW.md +39 -0
- package/documentation/SCRIPTS_UPDATE_SUMMARY.md +251 -0
- package/documentation/SETUP_GUIDE.md +184 -0
- package/documentation/STATE_MACHINE_IMPLEMENTATION.md +250 -0
- package/documentation/TELEGRAM_NOTIFICATIONS_DIAGNOSIS.md +361 -0
- package/documentation/UNIFIED_ARCHITECTURE.md +231 -0
- package/documentation/VOTING_DEPLOYMENT_SUMMARY.md +392 -0
- package/documentation/WEBSOCKET_ARCHITECTURE.md +881 -0
- package/documentation/WHAT_WE_BUILT_TODAY.md +369 -0
- package/documentation/latest/LATEST_PRODUCTION_SETUP.md +865 -0
- package/ecosystem.config.js +65 -0
- package/env.template +125 -0
- package/middleware/apiKeyAuth.js +136 -0
- package/middleware/authenticate.js +214 -0
- package/middleware/developerUserAuth.js +76 -0
- package/middleware/socketAuth.js +69 -0
- package/package.json +49 -0
- package/postman/Dubs-API-v1-With-Voting.postman_collection.json +555 -0
- package/postman/Dubs-API-v1.postman_collection.json +205 -0
- package/postman/Dubs_Developer_API.postman_collection.json +662 -0
- package/postman/QUICKSTART.md +118 -0
- package/postman/QUICK_REFERENCE.md +246 -0
- package/postman/README.md +71 -0
- package/postman/VOTING_API_GUIDE.md +426 -0
- package/refactor/Animations.md +148 -0
- package/refactor/Chat.md +252 -0
- package/routes/actionsRoutes.js +699 -0
- package/routes/adminRoutes.js +370 -0
- package/routes/analyticsRoutes.js +1262 -0
- package/routes/arcadeRoutes.js +557 -0
- package/routes/authRoutes.js +2310 -0
- package/routes/avatarRoutes.js +85 -0
- package/routes/botRoutes.js +211 -0
- package/routes/chatRoutes.js +377 -0
- package/routes/cryptoPriceRoutes.js +105 -0
- package/routes/developerRoutes.js +4201 -0
- package/routes/deviceRoutes.js +214 -0
- package/routes/dmRoutes.js +167 -0
- package/routes/esportsRoutes.js +806 -0
- package/routes/exchangeRateRoutes.js +233 -0
- package/routes/gamesRoutes.js +3028 -0
- package/routes/jackpotRoutes.js +754 -0
- package/routes/keeperMonitoringRoutes.js +156 -0
- package/routes/keeperWebhookRoutes.js +466 -0
- package/routes/livescoresRoutes.js +31 -0
- package/routes/pickemAdminRoutes.js +199 -0
- package/routes/pickemRoutes.js +231 -0
- package/routes/playerStatsRoutes.js +147 -0
- package/routes/portfolioRoutes.js +217 -0
- package/routes/promoRoutes.js +418 -0
- package/routes/referralEarningsRoutes.js +392 -0
- package/routes/socialRoutes.js +459 -0
- package/routes/sportsRoutes.js +1271 -0
- package/routes/survivorAdminRoutes.js +345 -0
- package/routes/survivorRoutes.js +756 -0
- package/routes/uploadRoutes.js +256 -0
- package/routes/userProfileRoutes.js +244 -0
- package/routes/whatsNewRoutes.js +331 -0
- package/scripts/.claude/settings.local.json +15 -0
- package/scripts/README.md +170 -0
- package/scripts/RESTART_EVERYTHING.sh +104 -0
- package/scripts/add-claim-columns.sql +48 -0
- package/scripts/add-crypto-prices-cache.sql +27 -0
- package/scripts/add-exchange-rates-cache.sql +40 -0
- package/scripts/add-game-invite-column.sql +23 -0
- package/scripts/add-game-invite-notification.sql +33 -0
- package/scripts/add-game-invite-telegram-pref.sql +16 -0
- package/scripts/add-game-joined-notification.sql +16 -0
- package/scripts/add-game-joined-pref.js +40 -0
- package/scripts/add-game-joined-preference.sql +6 -0
- package/scripts/add-game-start-notifications.sql +41 -0
- package/scripts/add-notification-flags-to-games.sql +55 -0
- package/scripts/add-pending-game-dismissals.sql +19 -0
- package/scripts/add-preferred-currency.sql +34 -0
- package/scripts/add-winner-columns.js +61 -0
- package/scripts/add_mention_system.sql +53 -0
- package/scripts/add_payment_system.sql +96 -0
- package/scripts/add_sports_event_id_column.sql +22 -0
- package/scripts/analyze-cohort-data-heroku.js +276 -0
- package/scripts/analyze-cohort-data.js +295 -0
- package/scripts/analyze-prod-cohorts.sh +10 -0
- package/scripts/backfill-matchup-images.js +245 -0
- package/scripts/backfill-missing-signatures.js +175 -0
- package/scripts/backfill-referral-earnings.js +202 -0
- package/scripts/check-chat-schema.js +130 -0
- package/scripts/check-db.sh +14 -0
- package/scripts/check_oracle_in_game.js +54 -0
- package/scripts/cleanup-database.js +193 -0
- package/scripts/clear-notification-cache.js +85 -0
- package/scripts/convert-mnemonic.js +50 -0
- package/scripts/create-users-table.sql +44 -0
- package/scripts/debug-cohort-counts.js +248 -0
- package/scripts/debug-winner-calc.js +84 -0
- package/scripts/deploy-payment-system.sh +118 -0
- package/scripts/deploy-to-heroku.sh +63 -0
- package/scripts/diagnose-locked-round.js +143 -0
- package/scripts/dubs-cli.js +720 -0
- package/scripts/dump-account.js +65 -0
- package/scripts/find-vrf-offset.js +48 -0
- package/scripts/fix-chat-notifications-constraint.sql +122 -0
- package/scripts/fix-claim-columns.js +124 -0
- package/scripts/fix-constraint-now.js +44 -0
- package/scripts/fix-lock-timestamps.js +96 -0
- package/scripts/fix-locked-round.sh +126 -0
- package/scripts/fix-missing-badges.sql +91 -0
- package/scripts/fix-payment-notifications.sql +41 -0
- package/scripts/force-new-round.js +55 -0
- package/scripts/force-resolve-and-claim.js +278 -0
- package/scripts/important/README.md +115 -0
- package/scripts/important/authority-force-lock.js +197 -0
- package/scripts/important/authority-resolve-game.js +267 -0
- package/scripts/important/check-game-status.js +373 -0
- package/scripts/important/list-pending-games-by-version.js +270 -0
- package/scripts/important/reconcile-v1-v2-payouts.js +270 -0
- package/scripts/initialize-jackpot.js +111 -0
- package/scripts/jackpot/.claude/settings.local.json +10 -0
- package/scripts/jackpot/force-reset.js +84 -0
- package/scripts/jackpot/initialize-mainnet.js +100 -0
- package/scripts/jackpot/keeper.js +742 -0
- package/scripts/jackpot/status.js +107 -0
- package/scripts/jackpot/update-round-duration.js +143 -0
- package/scripts/keeper-bot.js +112 -0
- package/scripts/list-pending-games.js +131 -0
- package/scripts/migrate-chat-v2.js +127 -0
- package/scripts/migrate-chat-winners.js +84 -0
- package/scripts/migrate-chat.sh +17 -0
- package/scripts/migrate-game-invite.js +83 -0
- package/scripts/migrate-heroku-game-notifications.sh +159 -0
- package/scripts/migrations/001_analytics_tables.sql +422 -0
- package/scripts/migrations/002_add_matchup_image_url.sql +14 -0
- package/scripts/migrations/003_referral_earnings.sql +208 -0
- package/scripts/migrations/004_add_whats_new_notification_type.sql +62 -0
- package/scripts/migrations/005_add_connect4_your_turn_notification.sql +61 -0
- package/scripts/migrations/005_push_notifications.sql +55 -0
- package/scripts/migrations/006_add_draw_team_players.sql +28 -0
- package/scripts/migrations/006_add_game_cancelled_notification.sql +62 -0
- package/scripts/migrations/007_add_gif_url.sql +8 -0
- package/scripts/migrations/008_add_connect4_columns.sql +139 -0
- package/scripts/migrations/008_add_pool_tracking.sql +22 -0
- package/scripts/migrations/009_create_survivor_pool_tables.sql +174 -0
- package/scripts/migrations/010_add_survivor_pool_outcome.sql +28 -0
- package/scripts/migrations/011_create_developer_tables.sql +67 -0
- package/scripts/migrations/011_fix_keeper_tables.sql +85 -0
- package/scripts/migrations/012_create_developer_webhooks.sql +31 -0
- package/scripts/migrations/013_add_network_mode.sql +18 -0
- package/scripts/migrations/014_create_developer_app_users.sql +19 -0
- package/scripts/migrations/015_add_ui_config.sql +4 -0
- package/scripts/migrations/016_add_resolution_secret.sql +4 -0
- package/scripts/migrations/017_add_external_game_id.sql +3 -0
- package/scripts/migrations/018_create_pickem_tables.sql +115 -0
- package/scripts/migrations/019_expo_push_tokens.sql +19 -0
- package/scripts/migrations/create_whats_new_tables.sql +88 -0
- package/scripts/migrations/drop_live_games_tables.sql +34 -0
- package/scripts/open-jackpot-round.js +85 -0
- package/scripts/purge-all-data.sh +329 -0
- package/scripts/purge-all-data.sql +142 -0
- package/scripts/purge-heroku-data.sh +149 -0
- package/scripts/purge-heroku-data.sql +62 -0
- package/scripts/rebuild-heroku-database.sh +113 -0
- package/scripts/recover-funds.js +357 -0
- package/scripts/regenerate-epl-images.js +278 -0
- package/scripts/resize-s3-matchup-images.js +374 -0
- package/scripts/resolve-direct.js +88 -0
- package/scripts/resolve-mock-game.js +124 -0
- package/scripts/resolve-pickem-game.js +55 -0
- package/scripts/resolve-round-manual.js +83 -0
- package/scripts/resolve-stuck-game.js +382 -0
- package/scripts/resolve-stuck-round.js +42 -0
- package/scripts/run-connect4-migration.sh +16 -0
- package/scripts/run-mention-migration.sh +32 -0
- package/scripts/run-payment-migration.sh +51 -0
- package/scripts/run-preferred-currency-migration.sh +31 -0
- package/scripts/run-referral-earnings-migration.sh +32 -0
- package/scripts/run-survivor-outcome-migration.sh +16 -0
- package/scripts/seed-test-users.js +346 -0
- package/scripts/setup-auth-tables.js +78 -0
- package/scripts/setup-complete-database.sql +992 -0
- package/scripts/setup-database-fresh.sh +359 -0
- package/scripts/setup-heroku-keeper.sh +48 -0
- package/scripts/setup-keeper-database.js +83 -0
- package/scripts/setup-keeper-state-db.sql +110 -0
- package/scripts/setup-oracle.sh +39 -0
- package/scripts/setup-pnl-tracking.js +111 -0
- package/scripts/start-devnet.sh +14 -0
- package/scripts/test-arcade-devnet.sh +160 -0
- package/scripts/test-arcade-match.sh +109 -0
- package/scripts/test-automatic-mode.sh +239 -0
- package/scripts/test-connect4-cancel-claim.js +370 -0
- package/scripts/test-connect4-e2e.js +369 -0
- package/scripts/test-connect4-resolve.js +369 -0
- package/scripts/test-game-state-endpoint.js +136 -0
- package/scripts/test-invite-notification.js +86 -0
- package/scripts/test-jackpot-api.sh +71 -0
- package/scripts/test-poll-confirmation.js +267 -0
- package/scripts/test-resolve-game.js +271 -0
- package/scripts/test-resolve-signature.js +223 -0
- package/scripts/test-signature-preservation.js +124 -0
- package/scripts/test-state-machine.js +291 -0
- package/scripts/test-webhook-receiver.js +60 -0
- package/scripts/update-notification-constraint.js +52 -0
- package/scripts/verify-account-layout.js +145 -0
- package/scripts/verify-winner-algorithm.js +278 -0
- package/server.js +5259 -0
- package/services/arcadeMatchService.js +763 -0
- package/services/automaticGameOracle.js +1596 -0
- package/services/chatService.js +1612 -0
- package/services/connect4GameService.js +1049 -0
- package/services/connect4NotificationService.js +374 -0
- package/services/cryptoPriceService.js +223 -0
- package/services/customGameResolver.js +260 -0
- package/services/db.js +79 -0
- package/services/directMessageService.js +389 -0
- package/services/discordNotifications.js +160 -0
- package/services/exchangeRateService.js +289 -0
- package/services/expoPushService.js +314 -0
- package/services/gamesCacheService.js +539 -0
- package/services/jackpotHistory.js +331 -0
- package/services/jackpotService.js +856 -0
- package/services/keeperStateService.js +355 -0
- package/services/matchupImageService.js +591 -0
- package/services/notificationCacheService.js +407 -0
- package/services/pickemOracle.js +440 -0
- package/services/playerStatsService.js +389 -0
- package/services/portfolioService.js +555 -0
- package/services/promoService.js +757 -0
- package/services/promoTreasuryService.js +239 -0
- package/services/pushNotifications.js +353 -0
- package/services/redisService.js +422 -0
- package/services/referralEarningsService.js +728 -0
- package/services/s3Service.js +396 -0
- package/services/socialService.js +1202 -0
- package/services/survivorOracle.js +469 -0
- package/services/survivorSimulator.js +475 -0
- package/services/telegramNotifications.js +461 -0
- package/services/userProfileStatsService.js +1185 -0
- package/services/whatsNewService.js +388 -0
- package/utils/urlHelper.js +95 -0
|
@@ -0,0 +1,865 @@
|
|
|
1
|
+
# 🚀 DUBS Server Production Setup
|
|
2
|
+
|
|
3
|
+
**Created:** December 14, 2025
|
|
4
|
+
**Last Updated:** December 14, 2025
|
|
5
|
+
|
|
6
|
+
This document contains critical operational information for the `dubs-server-prod` Heroku application.
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## 📋 Quick Reference
|
|
11
|
+
|
|
12
|
+
| Field | Value |
|
|
13
|
+
|-------|-------|
|
|
14
|
+
| **App Name** | `dubs-server-prod` |
|
|
15
|
+
| **Production URL** | https://dubs-server-prod-9c91d3f01199.herokuapp.com/ |
|
|
16
|
+
| **Git Remote** | `heroku-prod` |
|
|
17
|
+
| **Team** | dubs |
|
|
18
|
+
| **Region** | US |
|
|
19
|
+
| **Stack** | heroku-24 |
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## 🖥️ Infrastructure
|
|
24
|
+
|
|
25
|
+
### Dynos (Compute)
|
|
26
|
+
|
|
27
|
+
| Dyno | Type | Size | Purpose |
|
|
28
|
+
|------|------|------|---------|
|
|
29
|
+
| `web.1` | Standard-1X | 512MB RAM | Express.js API server |
|
|
30
|
+
| `oracle.1` | Standard-1X | 512MB RAM | Automatic game resolution oracle |
|
|
31
|
+
|
|
32
|
+
### Database (PostgreSQL)
|
|
33
|
+
|
|
34
|
+
| Field | Value |
|
|
35
|
+
|-------|-------|
|
|
36
|
+
| **Addon Name** | `postgresql-regular-65857` |
|
|
37
|
+
| **Plan** | Standard-0 |
|
|
38
|
+
| **Cost** | ~$50/month |
|
|
39
|
+
| **PG Version** | 17.5 |
|
|
40
|
+
| **Storage Limit** | 64 GB |
|
|
41
|
+
| **Max Connections** | 200 |
|
|
42
|
+
| **Region** | US East (AWS) |
|
|
43
|
+
| **Created** | December 14, 2025 |
|
|
44
|
+
|
|
45
|
+
#### Database Features
|
|
46
|
+
|
|
47
|
+
| Feature | Status |
|
|
48
|
+
|---------|--------|
|
|
49
|
+
| Fork/Follow | ✅ Available |
|
|
50
|
+
| Point-in-Time Rollback | ✅ Available |
|
|
51
|
+
| Continuous Protection | ✅ On |
|
|
52
|
+
| Data Encryption | ✅ In Use |
|
|
53
|
+
| Connection Pooling | ✅ Available |
|
|
54
|
+
|
|
55
|
+
#### Database vs Dev Comparison
|
|
56
|
+
|
|
57
|
+
| Property | PROD | DEV |
|
|
58
|
+
|----------|------|-----|
|
|
59
|
+
| **Addon** | `postgresql-regular-65857` | `postgresql-colorful-22525` |
|
|
60
|
+
| **Plan** | Standard-0 ($50/mo) | Essential-0 ($5/mo) |
|
|
61
|
+
| **Storage** | 64 GB | 1 GB |
|
|
62
|
+
| **Connections** | 200 | 20 |
|
|
63
|
+
| **Rollback** | ✅ Yes | ❌ No |
|
|
64
|
+
| **Fork/Follow** | ✅ Yes | ❌ No |
|
|
65
|
+
|
|
66
|
+
⚠️ **Important:** These are completely separate databases with different credentials. No data is shared between environments.
|
|
67
|
+
|
|
68
|
+
#### Database Tables (34 total)
|
|
69
|
+
|
|
70
|
+
**Authentication & Users:**
|
|
71
|
+
- `users` - User profiles
|
|
72
|
+
- `auth_nonces` - Signature verification nonces
|
|
73
|
+
- `user_sessions` - JWT sessions
|
|
74
|
+
- `user_badges` - Achievement badges
|
|
75
|
+
- `telegram_notification_preferences` - Notification settings
|
|
76
|
+
|
|
77
|
+
**Chat System:**
|
|
78
|
+
- `chat_messages` - Chat messages
|
|
79
|
+
- `chat_notifications` - In-app notifications
|
|
80
|
+
- `chat_payments` - SOL payment tracking
|
|
81
|
+
- `chat_reactions` - Emoji reactions
|
|
82
|
+
- `direct_messages` - Private messages
|
|
83
|
+
- `message_mentions` - @mentions
|
|
84
|
+
|
|
85
|
+
**Games & Betting:**
|
|
86
|
+
- `games` - Sports betting games
|
|
87
|
+
- `user_game_refs` - User game participation
|
|
88
|
+
- `pending_game_dismissals` - Dismissed game notifications
|
|
89
|
+
- `sports_betting_stats` - Betting statistics
|
|
90
|
+
- `audit_logs` - Action logging
|
|
91
|
+
|
|
92
|
+
**Social Features:**
|
|
93
|
+
- `friends` - Friend relationships
|
|
94
|
+
- `friend_requests` - Pending requests
|
|
95
|
+
- `user_relationships` - Blocks, etc.
|
|
96
|
+
- `groups` - Group chats
|
|
97
|
+
- `group_members` - Group membership
|
|
98
|
+
|
|
99
|
+
**Live Games (ESPN Integration):**
|
|
100
|
+
- `live_games` - Real-time game data
|
|
101
|
+
- `live_game_plays` - Play-by-play
|
|
102
|
+
- `live_game_stats` - Game statistics
|
|
103
|
+
- `live_game_subscriptions` - User subscriptions
|
|
104
|
+
- `live_game_polling_log` - Polling history
|
|
105
|
+
|
|
106
|
+
**Jackpot System:**
|
|
107
|
+
- `jackpot_rounds` - Round history
|
|
108
|
+
- `keeper_actions` - Keeper logs
|
|
109
|
+
- `keeper_health` - Health checks
|
|
110
|
+
- `keeper_rounds` - Round state
|
|
111
|
+
|
|
112
|
+
**Player Stats:**
|
|
113
|
+
- `player_stats` - Aggregate stats
|
|
114
|
+
- `player_history` - Transaction history
|
|
115
|
+
|
|
116
|
+
**Caching:**
|
|
117
|
+
- `crypto_prices_cache` - Crypto price cache
|
|
118
|
+
- `exchange_rates_cache` - Currency rates cache
|
|
119
|
+
|
|
120
|
+
### S3 Storage (Avatar Uploads)
|
|
121
|
+
|
|
122
|
+
| Field | Value |
|
|
123
|
+
|-------|-------|
|
|
124
|
+
| **Bucket** | `dubs-avatars-prod` |
|
|
125
|
+
| **Region** | `us-east-2` |
|
|
126
|
+
| **Public URL** | `https://dubs-avatars-prod.s3.us-east-2.amazonaws.com/avatars/` |
|
|
127
|
+
| **Access** | Public read for `/avatars/*` |
|
|
128
|
+
| **CORS** | Enabled for browser uploads |
|
|
129
|
+
|
|
130
|
+
**Note:** The bucket/region is determined by `NODE_ENV=production` in the code, not by env vars.
|
|
131
|
+
|
|
132
|
+
---
|
|
133
|
+
|
|
134
|
+
## 🗄️ Database Access
|
|
135
|
+
|
|
136
|
+
### Connection Details
|
|
137
|
+
|
|
138
|
+
| Field | Value |
|
|
139
|
+
|-------|-------|
|
|
140
|
+
| **Host** | `ec2-34-202-113-158.compute-1.amazonaws.com` |
|
|
141
|
+
| **Port** | `5432` |
|
|
142
|
+
| **Database** | `d6jpka002e1ept` |
|
|
143
|
+
| **User** | `uddg5sp8vh4l8g` |
|
|
144
|
+
| **Password** | Run: `heroku config:get DATABASE_URL --app dubs-server-prod` |
|
|
145
|
+
| **SSL Mode** | `require` (mandatory) |
|
|
146
|
+
|
|
147
|
+
### Connect via Heroku CLI (Recommended)
|
|
148
|
+
|
|
149
|
+
```bash
|
|
150
|
+
# Interactive psql session
|
|
151
|
+
heroku pg:psql --app dubs-server-prod
|
|
152
|
+
|
|
153
|
+
# Run a single query
|
|
154
|
+
heroku pg:psql --app dubs-server-prod -c "SELECT COUNT(*) FROM users;"
|
|
155
|
+
|
|
156
|
+
# Run a SQL file
|
|
157
|
+
heroku pg:psql --app dubs-server-prod < scripts/some-migration.sql
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
### Get Connection String
|
|
161
|
+
|
|
162
|
+
```bash
|
|
163
|
+
# View DATABASE_URL (contains credentials)
|
|
164
|
+
heroku config:get DATABASE_URL --app dubs-server-prod
|
|
165
|
+
|
|
166
|
+
# Format: postgres://USER:PASSWORD@HOST:PORT/DATABASE
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
### Connect with External Tools (pgAdmin, DBeaver, TablePlus)
|
|
170
|
+
|
|
171
|
+
Use the connection details above, or run:
|
|
172
|
+
|
|
173
|
+
```bash
|
|
174
|
+
heroku pg:credentials:url --app dubs-server-prod
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
⚠️ **Important:** Heroku Postgres requires SSL. Set `sslmode=require` in your connection settings.
|
|
178
|
+
|
|
179
|
+
### Database Backup & Restore
|
|
180
|
+
|
|
181
|
+
```bash
|
|
182
|
+
# Create manual backup
|
|
183
|
+
heroku pg:backups:capture --app dubs-server-prod
|
|
184
|
+
|
|
185
|
+
# List backups
|
|
186
|
+
heroku pg:backups --app dubs-server-prod
|
|
187
|
+
|
|
188
|
+
# Download latest backup
|
|
189
|
+
heroku pg:backups:download --app dubs-server-prod
|
|
190
|
+
|
|
191
|
+
# Restore from backup
|
|
192
|
+
heroku pg:backups:restore b001 DATABASE_URL --app dubs-server-prod
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
### Database Maintenance
|
|
196
|
+
|
|
197
|
+
```bash
|
|
198
|
+
# View database info
|
|
199
|
+
heroku pg:info --app dubs-server-prod
|
|
200
|
+
|
|
201
|
+
# View active connections
|
|
202
|
+
heroku pg:psql --app dubs-server-prod -c "SELECT * FROM pg_stat_activity WHERE datname = current_database();"
|
|
203
|
+
|
|
204
|
+
# Kill idle connections (if needed)
|
|
205
|
+
heroku pg:killall --app dubs-server-prod
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
---
|
|
209
|
+
|
|
210
|
+
## ⚙️ Configuration Variables (Complete Reference)
|
|
211
|
+
|
|
212
|
+
This section documents **every** environment variable used by the production server, organized by function.
|
|
213
|
+
|
|
214
|
+
---
|
|
215
|
+
|
|
216
|
+
### 🔗 Solana / Blockchain
|
|
217
|
+
|
|
218
|
+
These variables configure the connection to Solana and the smart contract.
|
|
219
|
+
|
|
220
|
+
| Variable | Value | Used By | Description |
|
|
221
|
+
|----------|-------|---------|-------------|
|
|
222
|
+
| `PROGRAM_ID` | `85wJGp9uc8w2FeKX9CEHsudTo1UVCrmuRFy37oCcaoG1` | `server.js`, `oracleMonitor.js` | **Mainnet Sports Betting Program ID.** The deployed Solana program address for all sports betting operations (game creation, betting, resolution, payouts). |
|
|
223
|
+
| `JACKPOT_PROGRAM_ID` | `85wJGp9uc8w2FeKX9CEHsudTo1UVCrmuRFy37oCcaoG1` | `jackpotService.js` | **Reserved for future jackpot program.** Currently set to same as PROGRAM_ID. ⚠️ Note: `jackpotService.js` has this **hardcoded** - the env var is not actively read. |
|
|
224
|
+
| `SOLANA_NETWORK` | `https://api.mainnet-beta.solana.com` | `server.js`, `oracleMonitor.js` | **Solana RPC endpoint.** Used for all blockchain interactions (fetching accounts, sending transactions). Can be changed to a private RPC for better rate limits. |
|
|
225
|
+
| `ORACLE_WALLET_JSON` | `[135,155,140,...]` (64-byte JSON array) | `oracleMonitor.js` | **Oracle keypair (private key).** The Solana wallet that signs game resolution transactions. This wallet must match the `oracle` authority in the deployed program and needs SOL for tx fees. |
|
|
226
|
+
| `KEEPER_PRIVATE_KEY` | `[135,155,140,...]` (64-byte JSON array) | `jackpotService.js` | **Keeper keypair for jackpot rounds.** Used to trigger jackpot round transitions. Currently same wallet as oracle. |
|
|
227
|
+
|
|
228
|
+
**🔐 Security:** `ORACLE_WALLET_JSON` and `KEEPER_PRIVATE_KEY` are **private keys**. Never expose in logs or client-side code.
|
|
229
|
+
|
|
230
|
+
---
|
|
231
|
+
|
|
232
|
+
### 🗄️ Database
|
|
233
|
+
|
|
234
|
+
| Variable | Value | Used By | Description |
|
|
235
|
+
|----------|-------|---------|-------------|
|
|
236
|
+
| `DATABASE_URL` | `postgres://uddg5sp8vh4l8g:...@ec2-34-202-113-158.compute-1.amazonaws.com:5432/d6jpka002e1ept` | All services | **PostgreSQL connection string.** Auto-set by Heroku when Postgres addon is provisioned. Contains host, port, username, password, and database name. SSL is required. |
|
|
237
|
+
|
|
238
|
+
**Used by:**
|
|
239
|
+
- `server.js` - Main Express app database connections
|
|
240
|
+
- `oracleMonitor.js` - Game state queries
|
|
241
|
+
- All API routes - User data, games, chat, etc.
|
|
242
|
+
|
|
243
|
+
---
|
|
244
|
+
|
|
245
|
+
### ☁️ AWS / S3 Storage
|
|
246
|
+
|
|
247
|
+
These variables configure avatar image uploads to S3.
|
|
248
|
+
|
|
249
|
+
| Variable | Value | Used By | Description |
|
|
250
|
+
|----------|-------|---------|-------------|
|
|
251
|
+
| `AWS_ACCESS_KEY_ID` | `AKIAZPVQ6PRW5OIQYGUI` | `s3Service.js` | **AWS IAM access key.** Used to authenticate S3 API requests for avatar uploads. |
|
|
252
|
+
| `AWS_SECRET_ACCESS_KEY` | `q0IwdvM+I/UXovupqc...` | `s3Service.js` | **AWS IAM secret key.** Paired with access key for S3 authentication. |
|
|
253
|
+
|
|
254
|
+
**Note:** The S3 bucket name (`dubs-avatars-prod`) and region (`us-east-2`) are **NOT** configured via env vars. They are determined by `NODE_ENV=production` in `s3Service.js`:
|
|
255
|
+
|
|
256
|
+
```javascript
|
|
257
|
+
this.bucketName = process.env.NODE_ENV === 'production'
|
|
258
|
+
? 'dubs-avatars-prod' : 'dubs-avatars-dev';
|
|
259
|
+
this.region = process.env.NODE_ENV === 'production'
|
|
260
|
+
? 'us-east-2' : 'us-east-1';
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
---
|
|
264
|
+
|
|
265
|
+
### 🌐 API Endpoints
|
|
266
|
+
|
|
267
|
+
These variables define URLs for inter-service communication.
|
|
268
|
+
|
|
269
|
+
| Variable | Value | Used By | Description |
|
|
270
|
+
|----------|-------|---------|-------------|
|
|
271
|
+
| `API_BASE_URL` | `https://dubs-server-prod-9c91d3f01199.herokuapp.com` | Various | **This server's public URL.** Used when generating absolute URLs (e.g., in emails, redirects). |
|
|
272
|
+
| `DUBS_SERVER_URL` | `https://dubs-server-prod-9c91d3f01199.herokuapp.com` | `oracleMonitor.js` | **Oracle's reference to this server.** The oracle uses this to query game data from the PostgreSQL-backed API when resolving games. |
|
|
273
|
+
| `LIVE_SCORES_API_URL` | `https://dubs-api-prod-9e38ab6733f8.herokuapp.com` | `oracleMonitor.js` | **Live scores API endpoint.** Points to `dubs-api` service which provides final game scores. Oracle fetches scores from here to determine game winners. |
|
|
274
|
+
| `TELEGRAM_BOT_URL` | `https://dubs-telegram-bot-eb6ad9ec87b7.herokuapp.com` | `server.js` (notifications) | **Telegram bot server URL.** Used to send push notifications to users via Telegram when games they bet on are starting. |
|
|
275
|
+
|
|
276
|
+
---
|
|
277
|
+
|
|
278
|
+
### 🔐 Authentication & Security
|
|
279
|
+
|
|
280
|
+
| Variable | Value | Used By | Description |
|
|
281
|
+
|----------|-------|---------|-------------|
|
|
282
|
+
| `JWT_SECRET` | `d7ac140e29ae46324336c12b3cf58ec944c1a9...` | `authRoutes.js`, auth middleware | **JSON Web Token signing secret.** Used to sign and verify JWT tokens for user authentication. ✅ This is **different** between dev and prod (rotated). |
|
|
283
|
+
| `BOT_SECRET` | `telegram-bot-secret-key` | `server.js` (bot endpoints) | **Shared secret for Telegram bot.** Used to verify requests from the Telegram bot are authentic. Used in bot-to-server communication. |
|
|
284
|
+
| `TELEGRAM_BOT_TOKEN` | `7294073418:AAFJRJJzR8PB3dhGQIdMq1q0sdZ...` | `server.js` (notifications) | **Telegram Bot API token.** The token from @BotFather used to send messages via Telegram Bot API. |
|
|
285
|
+
|
|
286
|
+
---
|
|
287
|
+
|
|
288
|
+
### ⏱️ Timing / Polling Intervals
|
|
289
|
+
|
|
290
|
+
These control how frequently background processes run.
|
|
291
|
+
|
|
292
|
+
| Variable | Value (ms) | Used By | Description |
|
|
293
|
+
|----------|------------|---------|-------------|
|
|
294
|
+
| `ORACLE_CHECK_INTERVAL` | `60000` (60s) | `oracleMonitor.js` | **Game resolution check frequency.** How often the oracle checks for finished games that need to be resolved on-chain and payouts distributed. |
|
|
295
|
+
|
|
296
|
+
**Performance Note:** These intervals affect API rate limits and database write frequency. Adjust carefully.
|
|
297
|
+
|
|
298
|
+
---
|
|
299
|
+
|
|
300
|
+
### 🌍 Environment
|
|
301
|
+
|
|
302
|
+
| Variable | Value | Used By | Description |
|
|
303
|
+
|----------|-------|---------|-------------|
|
|
304
|
+
| `NODE_ENV` | `production` | Entire app | **Node.js environment mode.** Affects: S3 bucket/region selection, error verbosity, logging level, and various conditional behaviors throughout the codebase. |
|
|
305
|
+
|
|
306
|
+
---
|
|
307
|
+
|
|
308
|
+
### 📋 Complete Variable Summary
|
|
309
|
+
|
|
310
|
+
| Variable | Category | Status |
|
|
311
|
+
|----------|----------|--------|
|
|
312
|
+
| `PROGRAM_ID` | Solana | ✅ Active |
|
|
313
|
+
| `JACKPOT_PROGRAM_ID` | Solana | ⚠️ Set but hardcoded in code |
|
|
314
|
+
| `SOLANA_NETWORK` | Solana | ✅ Active |
|
|
315
|
+
| `ORACLE_WALLET_JSON` | Solana | ✅ Active (🔐 Sensitive) |
|
|
316
|
+
| `KEEPER_PRIVATE_KEY` | Solana | ✅ Active (🔐 Sensitive) |
|
|
317
|
+
| `DATABASE_URL` | Database | ✅ Active (🔐 Sensitive) |
|
|
318
|
+
| `AWS_ACCESS_KEY_ID` | AWS | ✅ Active |
|
|
319
|
+
| `AWS_SECRET_ACCESS_KEY` | AWS | ✅ Active (🔐 Sensitive) |
|
|
320
|
+
| `API_BASE_URL` | API URLs | ✅ Active |
|
|
321
|
+
| `DUBS_SERVER_URL` | API URLs | ✅ Active |
|
|
322
|
+
| `LIVE_SCORES_API_URL` | API URLs | ✅ Active |
|
|
323
|
+
| `TELEGRAM_BOT_URL` | API URLs | ✅ Active |
|
|
324
|
+
| `JWT_SECRET` | Security | ✅ Active (🔐 Sensitive) |
|
|
325
|
+
| `BOT_SECRET` | Security | ✅ Active |
|
|
326
|
+
| `TELEGRAM_BOT_TOKEN` | Security | ✅ Active (🔐 Sensitive) |
|
|
327
|
+
| `ORACLE_CHECK_INTERVAL` | Timing | ✅ Active |
|
|
328
|
+
| `LIVE_GAME_DISCOVERY_INTERVAL` | Timing | ✅ Active |
|
|
329
|
+
| `LIVE_GAME_POLL_INTERVAL` | Timing | ✅ Active |
|
|
330
|
+
| `LIVE_GAME_STATS_INTERVAL` | Timing | ✅ Active |
|
|
331
|
+
| `NODE_ENV` | Environment | ✅ Active |
|
|
332
|
+
|
|
333
|
+
**Total: 20 active variables** (7 are sensitive/secrets)
|
|
334
|
+
|
|
335
|
+
---
|
|
336
|
+
|
|
337
|
+
### View All Config
|
|
338
|
+
|
|
339
|
+
```bash
|
|
340
|
+
heroku config --app dubs-server-prod
|
|
341
|
+
```
|
|
342
|
+
|
|
343
|
+
### Update Config
|
|
344
|
+
|
|
345
|
+
```bash
|
|
346
|
+
# Set single variable
|
|
347
|
+
heroku config:set VARIABLE_NAME=value --app dubs-server-prod
|
|
348
|
+
|
|
349
|
+
# Set multiple variables
|
|
350
|
+
heroku config:set VAR1=value1 VAR2=value2 --app dubs-server-prod
|
|
351
|
+
|
|
352
|
+
# Remove a variable
|
|
353
|
+
heroku config:unset VARIABLE_NAME --app dubs-server-prod
|
|
354
|
+
```
|
|
355
|
+
|
|
356
|
+
---
|
|
357
|
+
|
|
358
|
+
## 🔌 API Endpoints Reference
|
|
359
|
+
|
|
360
|
+
This section documents all API endpoints, their security status, and usage by the `dubs-jackpot-spa` frontend.
|
|
361
|
+
|
|
362
|
+
### Legend
|
|
363
|
+
|
|
364
|
+
| Symbol | Meaning |
|
|
365
|
+
|--------|---------|
|
|
366
|
+
| 🔐 | **Secured** - Requires JWT token in `Authorization: Bearer <token>` header |
|
|
367
|
+
| 🌐 | **Public** - No authentication required |
|
|
368
|
+
| ✅ | Used by SPA (`dubs-jackpot-spa/app/v2/`) |
|
|
369
|
+
| ❌ | Not used by SPA (internal/bot/other) |
|
|
370
|
+
|
|
371
|
+
---
|
|
372
|
+
|
|
373
|
+
### 🔑 Authentication (`/auth`)
|
|
374
|
+
|
|
375
|
+
| Method | Endpoint | Security | SPA | Description |
|
|
376
|
+
|--------|----------|----------|-----|-------------|
|
|
377
|
+
| GET | `/auth/nonce/:walletAddress` | 🌐 Public | ✅ | Get nonce for wallet signature |
|
|
378
|
+
| GET | `/auth/check-username/:username` | 🌐 Public | ✅ | Check if username is available |
|
|
379
|
+
| POST | `/auth/verify-signature` | 🌐 Public | ✅ | Verify wallet signature |
|
|
380
|
+
| POST | `/auth/register` | 🌐 Public | ✅ | Register new user (returns JWT) |
|
|
381
|
+
| POST | `/auth/login` | 🌐 Public | ✅ | Login existing user (returns JWT) |
|
|
382
|
+
| GET | `/auth/user/:walletAddress` | 🌐 Public | ✅ | Get public user profile (limited data) |
|
|
383
|
+
| GET | `/auth/user/me` | 🔐 Secured | ✅ | Get full authenticated user profile |
|
|
384
|
+
| PUT | `/auth/user/:walletAddress` | 🔐 Secured | ✅ | Update user profile |
|
|
385
|
+
| POST | `/auth/user/:walletAddress/onboarding-complete` | 🔐 Secured | ✅ | Mark onboarding complete |
|
|
386
|
+
| GET | `/auth/validate-session` | 🔐 Secured | ✅ | Validate current JWT session |
|
|
387
|
+
| POST | `/auth/logout` | 🔐 Secured | ✅ | Logout current session |
|
|
388
|
+
| POST | `/auth/logout-all` | 🔐 Secured | ✅ | Logout all sessions |
|
|
389
|
+
| POST | `/auth/user/me/generate-referral-code` | 🔐 Secured | ✅ | Generate user's referral code |
|
|
390
|
+
| GET | `/auth/user/me/referred-users` | 🔐 Secured | ✅ | Get list of referred users |
|
|
391
|
+
| GET | `/auth/user/me/badges` | 🔐 Secured | ✅ | Get earned badges |
|
|
392
|
+
| POST | `/auth/user/me/check-badges` | 🔐 Secured | ✅ | Check and award new badges |
|
|
393
|
+
| POST | `/auth/user/me/link-telegram` | 🔐 Secured | ✅ | Link Telegram account |
|
|
394
|
+
| POST | `/auth/user/me/unlink-telegram` | 🔐 Secured | ✅ | Unlink Telegram account |
|
|
395
|
+
| GET | `/auth/user/me/telegram` | 🔐 Secured | ✅ | Get Telegram connection status |
|
|
396
|
+
| GET | `/auth/user/me/telegram-notification-preferences` | 🔐 Secured | ✅ | Get notification preferences |
|
|
397
|
+
| PUT | `/auth/user/me/telegram-notification-preferences` | 🔐 Secured | ✅ | Update notification preferences |
|
|
398
|
+
|
|
399
|
+
---
|
|
400
|
+
|
|
401
|
+
### 👥 Social (`/social`)
|
|
402
|
+
|
|
403
|
+
| Method | Endpoint | Security | SPA | Description |
|
|
404
|
+
|--------|----------|----------|-----|-------------|
|
|
405
|
+
| GET | `/social/search` | 🔐 Secured | ✅ | Search users by username |
|
|
406
|
+
| POST | `/social/friend-request/:targetUserId` | 🔐 Secured | ✅ | Send friend request |
|
|
407
|
+
| GET | `/social/friend-requests` | 🔐 Secured | ✅ | Get pending friend requests |
|
|
408
|
+
| POST | `/social/request/:requestId/accept` | 🔐 Secured | ✅ | Accept friend request |
|
|
409
|
+
| POST | `/social/request/:requestId/reject` | 🔐 Secured | ✅ | Reject friend request |
|
|
410
|
+
| GET | `/social/friends` | 🔐 Secured | ✅ | Get friends list |
|
|
411
|
+
| DELETE | `/social/friend/:targetUserId` | 🔐 Secured | ✅ | Remove friend |
|
|
412
|
+
|
|
413
|
+
---
|
|
414
|
+
|
|
415
|
+
### 💬 Direct Messages (`/dm`)
|
|
416
|
+
|
|
417
|
+
| Method | Endpoint | Security | SPA | Description |
|
|
418
|
+
|--------|----------|----------|-----|-------------|
|
|
419
|
+
| GET | `/dm/conversations` | 🔐 Secured | ✅ | Get all DM conversations |
|
|
420
|
+
| GET | `/dm/conversation/:walletAddress` | 🔐 Secured | ✅ | Get conversation history |
|
|
421
|
+
| POST | `/dm/send` | 🔐 Secured | ✅ | Send direct message |
|
|
422
|
+
| POST | `/dm/read/:walletAddress` | 🔐 Secured | ✅ | Mark messages as read |
|
|
423
|
+
| GET | `/dm/unread` | 🔐 Secured | ✅ | Get unread DM count |
|
|
424
|
+
|
|
425
|
+
---
|
|
426
|
+
|
|
427
|
+
### 💬 Chat (`/chat`)
|
|
428
|
+
|
|
429
|
+
| Method | Endpoint | Security | SPA | Description |
|
|
430
|
+
|--------|----------|----------|-----|-------------|
|
|
431
|
+
| GET | `/chat/messages` | 🔐 Secured | ✅ | Get chat messages (via WebSocket primarily) |
|
|
432
|
+
| POST | `/chat/messages` | 🔐 Secured | ✅ | Send chat message |
|
|
433
|
+
| GET | `/chat/notifications` | 🔐 Secured | ✅ | Get chat notifications |
|
|
434
|
+
| POST | `/chat/reactions` | 🔐 Secured | ✅ | Add reaction to message |
|
|
435
|
+
|
|
436
|
+
---
|
|
437
|
+
|
|
438
|
+
### 📊 Player Stats (`/stats`)
|
|
439
|
+
|
|
440
|
+
| Method | Endpoint | Security | SPA | Description |
|
|
441
|
+
|--------|----------|----------|-----|-------------|
|
|
442
|
+
| GET | `/stats/player/:walletAddress` | 🌐 Public | ✅ | Get player statistics |
|
|
443
|
+
| GET | `/stats/player/:walletAddress/history` | 🔐 Secured | ✅ | Get player game history (detailed betting history) |
|
|
444
|
+
| GET | `/stats/leaderboard` | 🌐 Public | ✅ | Get leaderboard |
|
|
445
|
+
|
|
446
|
+
---
|
|
447
|
+
|
|
448
|
+
### 👤 User Profile (`/api/profile`)
|
|
449
|
+
|
|
450
|
+
| Method | Endpoint | Security | SPA | Description |
|
|
451
|
+
|--------|----------|----------|-----|-------------|
|
|
452
|
+
| GET | `/api/profile/:walletAddress` | 🌐 Public | ✅ | Get comprehensive profile stats |
|
|
453
|
+
| GET | `/api/profile/:walletAddress/summary` | 🌐 Public | ✅ | Get quick summary for tooltips |
|
|
454
|
+
| GET | `/api/profile/:walletAddress/games` | 🔐 Secured | ✅ | Get user's games history (sensitive) |
|
|
455
|
+
| GET | `/api/profile/:walletAddress/friends` | 🌐 Public | ✅ | Get user's friends list |
|
|
456
|
+
| GET | `/api/profile/leaderboard/:type` | 🌐 Public | ✅ | Get leaderboard by type |
|
|
457
|
+
| POST | `/api/profile/batch` | 🔐 Secured | ✅ | Get batch profile stats (prevents scraping) |
|
|
458
|
+
|
|
459
|
+
---
|
|
460
|
+
|
|
461
|
+
### ⚽ Sports (`/api/sports`, `/api/livescores`)
|
|
462
|
+
|
|
463
|
+
| Method | Endpoint | Security | SPA | Description |
|
|
464
|
+
|--------|----------|----------|-----|-------------|
|
|
465
|
+
| GET | `/api/sports/events/:league` | 🌐 Public | ✅ | Get upcoming sports events |
|
|
466
|
+
| GET | `/api/sports/teams/:league` | 🌐 Public | ✅ | Get teams for league |
|
|
467
|
+
| GET | `/api/livescores` | 🌐 Public | ✅ | Get live scores (all leagues) |
|
|
468
|
+
| GET | `/api/livescores/:league` | 🌐 Public | ❌ | Get live scores for specific league |
|
|
469
|
+
|
|
470
|
+
---
|
|
471
|
+
|
|
472
|
+
### 🎮 Games (`/api/games`, `/api/auth/games`)
|
|
473
|
+
|
|
474
|
+
| Method | Endpoint | Security | SPA | Description |
|
|
475
|
+
|--------|----------|----------|-----|-------------|
|
|
476
|
+
| GET | `/api/games/stats` | 🌐 Public | ✅ | Get platform statistics |
|
|
477
|
+
| GET | `/api/games/health` | 🌐 Public | ✅ | Server health check |
|
|
478
|
+
| GET | `/api/games/pending/:walletAddress` | 🌐 Public | ✅ | Get pending games for user |
|
|
479
|
+
| GET | `/api/games/active/:walletAddress` | 🌐 Public | ✅ | Get active games for user |
|
|
480
|
+
| GET | `/api/games/claimable/:walletAddress` | 🌐 Public | ✅ | Get claimable games |
|
|
481
|
+
| POST | `/api/auth/games/save` | 🔐 Secured | ✅ | Save game to database |
|
|
482
|
+
| POST | `/api/audit/log` | 🌐 Public | ✅ | Log audit event |
|
|
483
|
+
|
|
484
|
+
---
|
|
485
|
+
|
|
486
|
+
### 💸 Transactions (`/api/v1/prod/transaction`)
|
|
487
|
+
|
|
488
|
+
| Method | Endpoint | Security | SPA | Description |
|
|
489
|
+
|--------|----------|----------|-----|-------------|
|
|
490
|
+
| POST | `/api/v1/prod/transaction/build/create-and-join-automatic` | 🌐 Public | ✅ | Build sports bet transaction |
|
|
491
|
+
| POST | `/api/v1/prod/transaction/build/join-game` | 🌐 Public | ✅ | Build join game transaction |
|
|
492
|
+
| POST | `/api/v1/prod/transaction/build/claim` | 🌐 Public | ✅ | Build claim winnings transaction |
|
|
493
|
+
|
|
494
|
+
---
|
|
495
|
+
|
|
496
|
+
### 💱 Exchange Rates (`/api/exchange-rates`)
|
|
497
|
+
|
|
498
|
+
| Method | Endpoint | Security | SPA | Description |
|
|
499
|
+
|--------|----------|----------|-----|-------------|
|
|
500
|
+
| GET | `/api/exchange-rates` | 🌐 Public | ✅ | Get all exchange rates |
|
|
501
|
+
| GET | `/api/exchange-rates/pair/:from/:to` | 🌐 Public | ✅ | Get specific currency pair |
|
|
502
|
+
| GET | `/api/exchange-rates/convert` | 🌐 Public | ✅ | Convert amount between currencies |
|
|
503
|
+
| GET | `/api/exchange-rates/currencies` | 🌐 Public | ✅ | Get supported currencies |
|
|
504
|
+
|
|
505
|
+
---
|
|
506
|
+
|
|
507
|
+
### 💰 Crypto Prices (`/api/crypto-prices`)
|
|
508
|
+
|
|
509
|
+
| Method | Endpoint | Security | SPA | Description |
|
|
510
|
+
|--------|----------|----------|-----|-------------|
|
|
511
|
+
| GET | `/api/crypto-prices/solana` | 🌐 Public | ✅ | Get SOL price in multiple currencies |
|
|
512
|
+
| GET | `/api/crypto-prices/solana/usd` | 🌐 Public | ✅ | Get SOL price in USD |
|
|
513
|
+
|
|
514
|
+
---
|
|
515
|
+
|
|
516
|
+
### 📈 Analytics (`/api/analytics`)
|
|
517
|
+
|
|
518
|
+
| Method | Endpoint | Security | SPA | Description |
|
|
519
|
+
|--------|----------|----------|-----|-------------|
|
|
520
|
+
| POST | `/api/analytics/events` | 🌐 Public | ✅ | Track analytics event |
|
|
521
|
+
| GET | `/api/analytics/events` | 🌐 Public | ❌ | Get analytics events (admin) |
|
|
522
|
+
| GET | `/api/analytics/funnel/:funnelId` | 🌐 Public | ❌ | Get funnel data (admin) |
|
|
523
|
+
| GET | `/api/analytics/summary` | 🌐 Public | ❌ | Get analytics summary (admin) |
|
|
524
|
+
|
|
525
|
+
---
|
|
526
|
+
|
|
527
|
+
### 📤 Upload (`/upload`)
|
|
528
|
+
|
|
529
|
+
| Method | Endpoint | Security | SPA | Description |
|
|
530
|
+
|--------|----------|----------|-----|-------------|
|
|
531
|
+
| POST | `/upload/avatar/presigned-url` | 🔐 Secured | ✅ | Get presigned URL for avatar upload |
|
|
532
|
+
| POST | `/upload/registration-avatar/presigned-url` | 🌐 Public | ✅ | Get presigned URL during registration |
|
|
533
|
+
|
|
534
|
+
---
|
|
535
|
+
|
|
536
|
+
### 🎰 Arcade (`/arcade`) - Not Used by SPA
|
|
537
|
+
|
|
538
|
+
| Method | Endpoint | Security | SPA | Description |
|
|
539
|
+
|--------|----------|----------|-----|-------------|
|
|
540
|
+
| GET | `/arcade/games` | 🌐 Public | ❌ | Get arcade games |
|
|
541
|
+
| POST | `/arcade/play` | 🔐 Secured | ❌ | Play arcade game |
|
|
542
|
+
|
|
543
|
+
---
|
|
544
|
+
|
|
545
|
+
### 🎯 Jackpot (`/jackpot`) - Not Used by SPA
|
|
546
|
+
|
|
547
|
+
| Method | Endpoint | Security | SPA | Description |
|
|
548
|
+
|--------|----------|----------|-----|-------------|
|
|
549
|
+
| GET | `/jackpot/current-round` | 🌐 Public | ❌ | Get current jackpot round |
|
|
550
|
+
| GET | `/jackpot/history` | 🌐 Public | ❌ | Get jackpot history |
|
|
551
|
+
|
|
552
|
+
---
|
|
553
|
+
|
|
554
|
+
### 🤖 Bot (`/api/bot`) - Internal Only
|
|
555
|
+
|
|
556
|
+
| Method | Endpoint | Security | SPA | Description |
|
|
557
|
+
|--------|----------|----------|-----|-------------|
|
|
558
|
+
| POST | `/api/bot/notify` | 🔐 Bot Secret | ❌ | Send notification (bot-to-server) |
|
|
559
|
+
| POST | `/api/bot/game-start` | 🔐 Bot Secret | ❌ | Notify game start |
|
|
560
|
+
|
|
561
|
+
---
|
|
562
|
+
|
|
563
|
+
### 🔧 Keeper (`/api/keeper`, `/api/keeper-webhook`) - Internal Only
|
|
564
|
+
|
|
565
|
+
| Method | Endpoint | Security | SPA | Description |
|
|
566
|
+
|--------|----------|----------|-----|-------------|
|
|
567
|
+
| GET | `/api/keeper/health` | 🌐 Public | ❌ | Keeper health check |
|
|
568
|
+
| POST | `/api/keeper-webhook/trigger` | 🔐 Internal | ❌ | Trigger keeper action |
|
|
569
|
+
|
|
570
|
+
---
|
|
571
|
+
|
|
572
|
+
### 🏒 Live Games (`/api/v1/live-games`)
|
|
573
|
+
|
|
574
|
+
| Method | Endpoint | Security | SPA | Description |
|
|
575
|
+
|--------|----------|----------|-----|-------------|
|
|
576
|
+
| GET | `/api/v1/live-games` | 🌐 Public | ✅ | Get live games (via WebSocket primarily) |
|
|
577
|
+
| GET | `/api/v1/live-games/:gameId` | 🌐 Public | ✅ | Get specific live game |
|
|
578
|
+
| GET | `/api/v1/live-games/:gameId/plays` | 🌐 Public | ✅ | Get play-by-play data |
|
|
579
|
+
|
|
580
|
+
---
|
|
581
|
+
|
|
582
|
+
### 📋 Endpoint Summary
|
|
583
|
+
|
|
584
|
+
| Category | Total | 🔐 Secured | 🌐 Public | ✅ SPA Uses |
|
|
585
|
+
|----------|-------|------------|-----------|-------------|
|
|
586
|
+
| Auth | 21 | 15 | 6 | 21 |
|
|
587
|
+
| Social | 7 | 7 | 0 | 7 |
|
|
588
|
+
| DM | 5 | 5 | 0 | 5 |
|
|
589
|
+
| Chat | 4 | 4 | 0 | 4 |
|
|
590
|
+
| Stats | 3 | 1 | 2 | 3 |
|
|
591
|
+
| Profile | 6 | 2 | 4 | 6 |
|
|
592
|
+
| Sports | 4 | 0 | 4 | 3 |
|
|
593
|
+
| Games | 7 | 1 | 6 | 7 |
|
|
594
|
+
| Transactions | 3 | 0 | 3 | 3 |
|
|
595
|
+
| Exchange Rates | 4 | 0 | 4 | 4 |
|
|
596
|
+
| Crypto Prices | 2 | 0 | 2 | 2 |
|
|
597
|
+
| Analytics | 4 | 0 | 4 | 1 |
|
|
598
|
+
| Upload | 2 | 1 | 1 | 2 |
|
|
599
|
+
| Arcade | 2 | 1 | 1 | 0 |
|
|
600
|
+
| Jackpot | 2 | 0 | 2 | 0 |
|
|
601
|
+
| Bot | 2 | 2 | 0 | 0 |
|
|
602
|
+
| Keeper | 2 | 1 | 1 | 0 |
|
|
603
|
+
| Live Games | 3 | 0 | 3 | 3 |
|
|
604
|
+
| **TOTAL** | **83** | **40** | **43** | **71** |
|
|
605
|
+
|
|
606
|
+
---
|
|
607
|
+
|
|
608
|
+
### 🔒 Security Notes
|
|
609
|
+
|
|
610
|
+
1. **Secured endpoints** require `Authorization: Bearer <JWT_TOKEN>` header
|
|
611
|
+
2. **Public endpoints** can be called without authentication
|
|
612
|
+
3. **Bot endpoints** use `BOT_SECRET` for authentication
|
|
613
|
+
4. **All user-modifying actions** (profile updates, messages, friends) require authentication
|
|
614
|
+
5. **Read-only data** (stats, profiles, scores) is generally public
|
|
615
|
+
|
|
616
|
+
---
|
|
617
|
+
|
|
618
|
+
## 🚀 Deployment
|
|
619
|
+
|
|
620
|
+
### Deploy from Local
|
|
621
|
+
|
|
622
|
+
```bash
|
|
623
|
+
cd /path/to/dubs-server
|
|
624
|
+
|
|
625
|
+
# Deploy main branch to production
|
|
626
|
+
git push heroku-prod main
|
|
627
|
+
|
|
628
|
+
# Deploy specific branch
|
|
629
|
+
git push heroku-prod feature-branch:main
|
|
630
|
+
```
|
|
631
|
+
|
|
632
|
+
### Rollback
|
|
633
|
+
|
|
634
|
+
```bash
|
|
635
|
+
# View releases
|
|
636
|
+
heroku releases --app dubs-server-prod
|
|
637
|
+
|
|
638
|
+
# Rollback to previous release
|
|
639
|
+
heroku rollback --app dubs-server-prod
|
|
640
|
+
|
|
641
|
+
# Rollback to specific version
|
|
642
|
+
heroku rollback v10 --app dubs-server-prod
|
|
643
|
+
```
|
|
644
|
+
|
|
645
|
+
---
|
|
646
|
+
|
|
647
|
+
## 📊 Monitoring & Logs
|
|
648
|
+
|
|
649
|
+
### View Logs
|
|
650
|
+
|
|
651
|
+
```bash
|
|
652
|
+
# Tail all logs
|
|
653
|
+
heroku logs --tail --app dubs-server-prod
|
|
654
|
+
|
|
655
|
+
# View specific dyno logs
|
|
656
|
+
heroku logs --tail --dyno web.1 --app dubs-server-prod
|
|
657
|
+
heroku logs --tail --dyno oracle.1 --app dubs-server-prod
|
|
658
|
+
|
|
659
|
+
# View last N lines
|
|
660
|
+
heroku logs -n 500 --app dubs-server-prod
|
|
661
|
+
|
|
662
|
+
# Filter by source
|
|
663
|
+
heroku logs --source app --app dubs-server-prod
|
|
664
|
+
heroku logs --source heroku --app dubs-server-prod
|
|
665
|
+
```
|
|
666
|
+
|
|
667
|
+
### Check Dyno Status
|
|
668
|
+
|
|
669
|
+
```bash
|
|
670
|
+
# View running dynos
|
|
671
|
+
heroku ps --app dubs-server-prod
|
|
672
|
+
|
|
673
|
+
# Restart all dynos
|
|
674
|
+
heroku restart --app dubs-server-prod
|
|
675
|
+
|
|
676
|
+
# Restart specific dyno
|
|
677
|
+
heroku restart web.1 --app dubs-server-prod
|
|
678
|
+
heroku restart oracle.1 --app dubs-server-prod
|
|
679
|
+
```
|
|
680
|
+
|
|
681
|
+
### Database Monitoring
|
|
682
|
+
|
|
683
|
+
```bash
|
|
684
|
+
# View database metrics
|
|
685
|
+
heroku pg:info --app dubs-server-prod
|
|
686
|
+
|
|
687
|
+
# View slow queries (requires pg:diagnose)
|
|
688
|
+
heroku pg:diagnose --app dubs-server-prod
|
|
689
|
+
|
|
690
|
+
# View table sizes
|
|
691
|
+
heroku pg:psql --app dubs-server-prod -c "
|
|
692
|
+
SELECT
|
|
693
|
+
schemaname,
|
|
694
|
+
tablename,
|
|
695
|
+
pg_size_pretty(pg_total_relation_size(schemaname||'.'||tablename)) as size
|
|
696
|
+
FROM pg_tables
|
|
697
|
+
WHERE schemaname = 'public'
|
|
698
|
+
ORDER BY pg_total_relation_size(schemaname||'.'||tablename) DESC;
|
|
699
|
+
"
|
|
700
|
+
```
|
|
701
|
+
|
|
702
|
+
---
|
|
703
|
+
|
|
704
|
+
## 🔐 Security Notes
|
|
705
|
+
|
|
706
|
+
### Sensitive Variables
|
|
707
|
+
|
|
708
|
+
The following variables contain sensitive data - **NEVER commit to git**:
|
|
709
|
+
|
|
710
|
+
- `DATABASE_URL` - Database connection string with password
|
|
711
|
+
- `JWT_SECRET` - Token signing secret
|
|
712
|
+
- `ORACLE_WALLET_JSON` - Oracle private key
|
|
713
|
+
- `KEEPER_PRIVATE_KEY` - Keeper private key
|
|
714
|
+
- `TELEGRAM_BOT_TOKEN` - Bot authentication token
|
|
715
|
+
- `AWS_SECRET_ACCESS_KEY` - AWS S3 access
|
|
716
|
+
|
|
717
|
+
### Oracle Wallet
|
|
718
|
+
|
|
719
|
+
The oracle wallet is stored in `ORACLE_WALLET_JSON` as a JSON array (Solana keypair format).
|
|
720
|
+
|
|
721
|
+
**Public Key:** `FWUJCthDfPcgmTvdQWM5uofxxiYjqJFMMwiLYvS7LBFa`
|
|
722
|
+
|
|
723
|
+
This wallet is hardcoded in the Solana program and receives 0.2% oracle fees.
|
|
724
|
+
|
|
725
|
+
---
|
|
726
|
+
|
|
727
|
+
## 🔧 Maintenance Tasks
|
|
728
|
+
|
|
729
|
+
### Run Database Migrations
|
|
730
|
+
|
|
731
|
+
```bash
|
|
732
|
+
# Run complete schema setup
|
|
733
|
+
heroku pg:psql --app dubs-server-prod < scripts/setup-complete-database.sql
|
|
734
|
+
|
|
735
|
+
# Run specific migration
|
|
736
|
+
heroku pg:psql --app dubs-server-prod < scripts/add-preferred-currency.sql
|
|
737
|
+
```
|
|
738
|
+
|
|
739
|
+
### Scale Dynos
|
|
740
|
+
|
|
741
|
+
```bash
|
|
742
|
+
# Scale up (more dynos or bigger size)
|
|
743
|
+
heroku ps:scale web=2:standard-2x --app dubs-server-prod
|
|
744
|
+
|
|
745
|
+
# Scale down
|
|
746
|
+
heroku ps:scale web=1:standard-1x --app dubs-server-prod
|
|
747
|
+
|
|
748
|
+
# Turn off oracle (if needed)
|
|
749
|
+
heroku ps:scale oracle=0 --app dubs-server-prod
|
|
750
|
+
```
|
|
751
|
+
|
|
752
|
+
### Run One-Off Commands
|
|
753
|
+
|
|
754
|
+
```bash
|
|
755
|
+
# Run a script
|
|
756
|
+
heroku run node scripts/some-script.js --app dubs-server-prod
|
|
757
|
+
|
|
758
|
+
# Open a shell
|
|
759
|
+
heroku run bash --app dubs-server-prod
|
|
760
|
+
```
|
|
761
|
+
|
|
762
|
+
### S3 Bucket Management
|
|
763
|
+
|
|
764
|
+
```bash
|
|
765
|
+
# List avatars
|
|
766
|
+
aws s3 ls s3://dubs-avatars-prod/avatars/ --summarize
|
|
767
|
+
|
|
768
|
+
# View bucket size
|
|
769
|
+
aws s3 ls s3://dubs-avatars-prod/ --recursive --summarize
|
|
770
|
+
|
|
771
|
+
# Delete old avatars (use with caution)
|
|
772
|
+
aws s3 rm s3://dubs-avatars-prod/avatars/OLD_FILE.jpg
|
|
773
|
+
|
|
774
|
+
# Check bucket policy
|
|
775
|
+
aws s3api get-bucket-policy --bucket dubs-avatars-prod
|
|
776
|
+
|
|
777
|
+
# Check CORS
|
|
778
|
+
aws s3api get-bucket-cors --bucket dubs-avatars-prod
|
|
779
|
+
```
|
|
780
|
+
|
|
781
|
+
---
|
|
782
|
+
|
|
783
|
+
## 🚨 Troubleshooting
|
|
784
|
+
|
|
785
|
+
### App Not Responding
|
|
786
|
+
|
|
787
|
+
1. Check dyno status: `heroku ps --app dubs-server-prod`
|
|
788
|
+
2. Check logs: `heroku logs --tail --app dubs-server-prod`
|
|
789
|
+
3. Restart: `heroku restart --app dubs-server-prod`
|
|
790
|
+
|
|
791
|
+
### Database Connection Issues
|
|
792
|
+
|
|
793
|
+
1. Check connection count: `heroku pg:info --app dubs-server-prod`
|
|
794
|
+
2. Kill idle connections: `heroku pg:killall --app dubs-server-prod`
|
|
795
|
+
3. Restart app: `heroku restart --app dubs-server-prod`
|
|
796
|
+
|
|
797
|
+
### Oracle Not Resolving Games
|
|
798
|
+
|
|
799
|
+
1. Check oracle logs: `heroku logs --tail --dyno oracle.1 --app dubs-server-prod`
|
|
800
|
+
2. Verify `ORACLE_WALLET_JSON` is set correctly
|
|
801
|
+
3. Check Solana RPC endpoint is responsive
|
|
802
|
+
4. Verify oracle wallet has SOL for transaction fees
|
|
803
|
+
|
|
804
|
+
### High Memory Usage
|
|
805
|
+
|
|
806
|
+
1. Check metrics: `heroku ps --app dubs-server-prod`
|
|
807
|
+
2. Scale to larger dyno: `heroku ps:scale web=1:standard-2x --app dubs-server-prod`
|
|
808
|
+
|
|
809
|
+
### Avatar Upload Issues
|
|
810
|
+
|
|
811
|
+
1. Check S3 credentials: `heroku config:get AWS_ACCESS_KEY_ID --app dubs-server-prod`
|
|
812
|
+
2. Verify bucket exists: `aws s3 ls s3://dubs-avatars-prod/`
|
|
813
|
+
3. Check CORS: `aws s3api get-bucket-cors --bucket dubs-avatars-prod`
|
|
814
|
+
4. Test presigned URL endpoint: `curl -X POST https://dubs-server-prod-9c91d3f01199.herokuapp.com/upload/avatar/presigned-url -H "Authorization: Bearer TOKEN" -d '{"walletAddress":"...","fileExtension":"png"}'`
|
|
815
|
+
|
|
816
|
+
---
|
|
817
|
+
|
|
818
|
+
## 💰 Cost Summary
|
|
819
|
+
|
|
820
|
+
| Resource | Monthly Cost |
|
|
821
|
+
|----------|--------------|
|
|
822
|
+
| Postgres Standard-0 | $50 |
|
|
823
|
+
| Standard-1X Dyno (web) | ~$25 |
|
|
824
|
+
| Standard-1X Dyno (oracle) | ~$25 |
|
|
825
|
+
| **Total Estimated** | **~$100/month** |
|
|
826
|
+
|
|
827
|
+
---
|
|
828
|
+
|
|
829
|
+
## 🔗 Related Resources
|
|
830
|
+
|
|
831
|
+
- **Mainnet Deployment Docs:** `../dubs/docs/LATEST_MAINNET_DEPLOYMENT.md`
|
|
832
|
+
- **Program ID:** `85wJGp9uc8w2FeKX9CEHsudTo1UVCrmuRFy37oCcaoG1`
|
|
833
|
+
- **Solana Explorer:** https://explorer.solana.com/address/85wJGp9uc8w2FeKX9CEHsudTo1UVCrmuRFy37oCcaoG1
|
|
834
|
+
|
|
835
|
+
---
|
|
836
|
+
|
|
837
|
+
## 📞 Quick Commands Cheat Sheet
|
|
838
|
+
|
|
839
|
+
```bash
|
|
840
|
+
# Logs
|
|
841
|
+
heroku logs --tail --app dubs-server-prod
|
|
842
|
+
|
|
843
|
+
# Restart
|
|
844
|
+
heroku restart --app dubs-server-prod
|
|
845
|
+
|
|
846
|
+
# Deploy
|
|
847
|
+
git push heroku-prod main
|
|
848
|
+
|
|
849
|
+
# Database shell
|
|
850
|
+
heroku pg:psql --app dubs-server-prod
|
|
851
|
+
|
|
852
|
+
# Config
|
|
853
|
+
heroku config --app dubs-server-prod
|
|
854
|
+
|
|
855
|
+
# Status
|
|
856
|
+
heroku ps --app dubs-server-prod
|
|
857
|
+
|
|
858
|
+
# Open in browser
|
|
859
|
+
heroku open --app dubs-server-prod
|
|
860
|
+
```
|
|
861
|
+
|
|
862
|
+
---
|
|
863
|
+
|
|
864
|
+
**Document maintained by:** Dubs Team
|
|
865
|
+
**For questions:** Check Heroku dashboard or logs first
|