@@ -9,7 +9,7 @@ import Application from 'shared';
9
9
import config from 'config' ;
10
10
import express from 'express' ;
11
11
import fetch from 'isomorphic-fetch' ;
12
- import { logger } from 'topcoder-react-lib' ;
12
+ import { logger , services } from 'topcoder-react-lib' ;
13
13
import fs from 'fs' ;
14
14
import moment from 'moment' ;
15
15
import path from 'path' ;
@@ -145,6 +145,28 @@ async function onExpressJsSetup(server) {
145
145
tcCommunitiesDemoApi ,
146
146
) ;
147
147
148
+ // Get registrants from challenge
149
+ server . use (
150
+ '/community-app-assets/api/registrants/:challengeId' ,
151
+ async ( req , res , next ) => {
152
+ const tokenM2M = await services . api . getTcM2mToken ( ) ;
153
+ const params = {
154
+ challengeId : req . params . challengeId ,
155
+ roleId : req . query . roleId ,
156
+ } ;
157
+ const url = `${ config . API . V5 } /resources?${ qs . stringify ( params ) } ` ;
158
+ try {
159
+ let data = await fetch ( url , {
160
+ headers : { Authorization : `Bearer ${ tokenM2M } ` } ,
161
+ } ) ;
162
+ data = await data . text ( ) ;
163
+ res . send ( data ) ;
164
+ } catch ( err ) {
165
+ next ( err ) ;
166
+ }
167
+ } ,
168
+ ) ;
169
+
148
170
server . use (
149
171
'/community-app-assets/api/edit-contentful-entry/:id' ,
150
172
( req , res ) => res . redirect ( `${ CMS_BASE_URL } /entries/${ req . params . id } ` ) ,
0 commit comments