Skip to content

Commit 8430f66

Browse files
Merge pull request #789 from topcoder-platform/PM-589
PM-589 Make opportunity routes public
2 parents cabb308 + 82d6a6e commit 8430f66

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

src/routes/index.js

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,24 @@ router.get(`/${apiVersion}/projects/health`, (req, res) => {
2323
});
2424
});
2525

26+
// List of public routes
27+
const publicRoutes = [
28+
`/${apiVersion}/projects/copilots/opportunities`,
29+
`/${apiVersion}/projects/copilot/opportunities/:id(\\d+)`,
30+
];
2631

2732
// All project service endpoints need authentication
2833
const jwtAuth = require('tc-core-library-js').middleware.jwtAuthenticator;
2934

3035
router.all(
31-
RegExp(`\\/${apiVersion}\\/(copilots|projects|timelines|orgConfig|customer-payments)(?!\\/health).*`), (req, res, next) => (
36+
RegExp(`\\/${apiVersion}\\/(copilots|projects|timelines|orgConfig|customer-payments)(?!\\/health).*`),
37+
(req, res, next) => {
38+
if (publicRoutes.some(route => req.path.match(new RegExp(`^${route}$`)))) {
39+
return next();
40+
}
3241
// JWT authentication
33-
jwtAuth(config)(req, res, next)
34-
),
42+
return jwtAuth(config)(req, res, next);
43+
},
3544
);
3645

3746
router.all(
@@ -392,8 +401,8 @@ router.route('/v5/projects/:projectId(\\d+)/copilots/requests/:copilotRequestId(
392401
// Project Copilot Opportunity
393402
router.route('/v5/projects/copilots/opportunities')
394403
.get(require('./copilotOpportunity/list'));
395-
router.route('/v5/projects/copilots/opportunities/:id(\\d+)')
396-
.get(require('./copilotOpportunity/get'))
404+
router.route('/v5/projects/copilot/opportunity/:id(\\d+)')
405+
.get(require('./copilotOpportunity/get'));
397406

398407
// Project Estimation Items
399408
router.route('/v5/projects/:projectId(\\d+)/estimations/:estimationId(\\d+)/items')

0 commit comments

Comments
 (0)