bulltrackers-module 1.0.602 → 1.0.603

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.
@@ -31,5 +31,17 @@ module.exports = (dependencies) => {
31
31
  router.use('/settings', settingsRoutes);
32
32
  router.use('/reviews', reviewsRoutes);
33
33
 
34
+ // Legacy route: /user/:userId/sync -> forwards to sync/request logic
35
+ // This maintains backward compatibility with frontend calls
36
+ router.post('/user/:userId/sync', async (req, res) => {
37
+ // Import sync handler (need to require it here to get the exported function)
38
+ const { handleSyncRequest } = require('./sync.js');
39
+ // Set targetId from URL param for the handler
40
+ req.body = req.body || {};
41
+ req.body.targetId = req.params.userId;
42
+ // Call the sync request handler
43
+ await handleSyncRequest(req, res);
44
+ });
45
+
34
46
  return router;
35
47
  };
@@ -11,12 +11,14 @@ const {
11
11
 
12
12
  const router = express.Router();
13
13
 
14
- // POST /sync/request (Unified - Auto-detects user type)
15
- router.post('/request', async (req, res) => {
14
+ // Helper function for sync request logic (shared between /sync/request and /user/:userId/sync)
15
+ const handleSyncRequest = async (req, res) => {
16
16
  try {
17
17
  const { pubsub, db } = req.dependencies;
18
18
  // targetId can be passed (for PIs) or default to self
19
- const targetId = req.body.targetId || req.targetUserId;
19
+ // For /user/:userId/sync, targetId comes from URL param
20
+ // For /sync/request, targetId comes from body or req.targetUserId
21
+ const targetId = req.body.targetId || req.params.userId || req.targetUserId;
20
22
 
21
23
  // 1. Rate Limits
22
24
  const isDev = await isDeveloper(db, req.targetUserId);
@@ -107,6 +109,8 @@ router.post('/request', async (req, res) => {
107
109
  res.json({
108
110
  success: true,
109
111
  requestIds,
112
+ requestId: requestIds[0], // Return first request ID for backward compatibility
113
+ status: 'queued',
110
114
  userTypes: {
111
115
  isSignedInUser: isSignedIn,
112
116
  isPopularInvestor: isPI
@@ -116,7 +120,10 @@ router.post('/request', async (req, res) => {
116
120
  } catch (error) {
117
121
  res.status(500).json({ error: error.message });
118
122
  }
119
- });
123
+ };
124
+
125
+ // POST /sync/request (Unified - Auto-detects user type)
126
+ router.post('/request', handleSyncRequest);
120
127
 
121
128
  // GET /sync/status/:targetId
122
129
  router.get('/status/:targetId', async (req, res) => {
@@ -129,4 +136,6 @@ router.get('/status/:targetId', async (req, res) => {
129
136
  }
130
137
  });
131
138
 
132
- module.exports = router;
139
+ // Export handler for use in main router
140
+ module.exports = router;
141
+ module.exports.handleSyncRequest = handleSyncRequest;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bulltrackers-module",
3
- "version": "1.0.602",
3
+ "version": "1.0.603",
4
4
  "description": "Helper Functions for Bulltrackers.",
5
5
  "main": "index.js",
6
6
  "files": [