@@ -23,15 +23,24 @@ router.get(`/${apiVersion}/projects/health`, (req, res) => {
23
23
} ) ;
24
24
} ) ;
25
25
26
+ // List of public routes
27
+ const publicRoutes = [
28
+ `/${ apiVersion } /projects/copilots/opportunities` ,
29
+ `/${ apiVersion } /projects/copilot/opportunities/:id(\\d+)` ,
30
+ ] ;
26
31
27
32
// All project service endpoints need authentication
28
33
const jwtAuth = require ( 'tc-core-library-js' ) . middleware . jwtAuthenticator ;
29
34
30
35
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
+ }
32
41
// JWT authentication
33
- jwtAuth ( config ) ( req , res , next )
34
- ) ,
42
+ return jwtAuth ( config ) ( req , res , next ) ;
43
+ } ,
35
44
) ;
36
45
37
46
router . all (
@@ -392,8 +401,8 @@ router.route('/v5/projects/:projectId(\\d+)/copilots/requests/:copilotRequestId(
392
401
// Project Copilot Opportunity
393
402
router . route ( '/v5/projects/copilots/opportunities' )
394
403
. 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' ) ) ;
397
406
398
407
// Project Estimation Items
399
408
router . route ( '/v5/projects/:projectId(\\d+)/estimations/:estimationId(\\d+)/items' )
0 commit comments