File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 3737 "js-yaml" : " ^4.1.0" ,
3838 "ldap-escape" : " ^2.0.6" ,
3939 "ldapjs" : " ^3.0.1" ,
40+ "nocache" : " ^4.0.0" ,
4041 "octokit" : " ^2.0.14" ,
4142 "openapi-backend" : " ^5.9.1" ,
4243 "swagger-ui-express" : " ^4.6.2"
Original file line number Diff line number Diff line change @@ -5,11 +5,13 @@ import fs from "fs";
55import path from "node:path" ;
66import swaggerUi from "swagger-ui-express" ;
77import { routes } from "./routes" ;
8- import { Log , SetupLogging } from "./logging" ;
8+ import { SetupLogging } from "./logging" ;
9+ import nocache from "nocache" ;
910
1011SetupLogging ( ) ;
1112
1213const app = express ( ) ;
14+ app . use ( nocache ( ) ) ;
1315
1416const port = process . env . PORT ;
1517
Original file line number Diff line number Diff line change @@ -7,14 +7,17 @@ export async function getSourceTeamHandler(
77 c : Context ,
88 _req : Request ,
99 res : Response
10- ) {
10+ ) {
1111 const teamName = _req . query . teamName as string ;
1212
1313 Log ( `Searching SoT for ${ teamName } ` )
1414
1515 const result = await SearchAllAsync ( teamName )
1616
17- Log ( `Found in SoT: ${ JSON . stringify ( result ) } ` )
17+ if ( result . Succeeded ) {
18+ Log ( `Found in SoT: ${ JSON . stringify ( result ) } ` )
19+ return res . status ( 200 ) . json ( result ) ;
20+ }
1821
19- return res . status ( 200 ) . json ( result ) ;
22+ return res . status ( 500 ) . json ( result )
2023}
Original file line number Diff line number Diff line change @@ -100,12 +100,6 @@ paths:
100100 schema :
101101 type : string
102102 required : true
103- - in : query
104- name : cb
105- description : For use in cache busting
106- schema :
107- type : string
108- required : false
109103 responses :
110104 " 200 " :
111105 description : A successful response
Original file line number Diff line number Diff line change @@ -140,20 +140,19 @@ export async function SearchAllAsync(groupName: string): SearchAllResponse {
140140 }
141141}
142142
143+ // TODO: do not directly use axios.create from within a function like this
144+ // it will cause a new client to be made per request.
145+ const httpClient = axios . create ( ) ;
146+ axiosRetry ( httpClient , { retries : 5 } ) ;
147+
143148async function ForwardSearch ( groupName : string ) : SearchAllResponse {
144149 Log ( `Forwarding request to '${ process . env . SOURCE_PROXY } '` ) ;
145-
146- // cb is for cache busting.
147- const requestUrl = `${ process . env . SOURCE_PROXY } /api/get-source-team?teamName=${ groupName } &cb=${ Date . now ( ) } ` ;
150+
151+ const requestUrl = `${ process . env . SOURCE_PROXY } /api/get-source-team?teamName=${ groupName } }` ;
148152
149153 Log ( `Retrieving group (${ groupName } ) information from '${ requestUrl } '` ) ;
150154 try {
151- // TODO: do not directly use axios.create from within a function like this
152- // it will cause a new client to be made per request.
153- const client = axios . create ( ) ;
154- axiosRetry ( client , { retries : 5 } ) ;
155-
156- const result = await client . get ( requestUrl ) ;
155+ const result = await httpClient . get ( requestUrl ) ;
157156 Log ( `Results for ${ groupName } : ${ result } ` ) ;
158157 return result . data as SearchAllResponse ;
159158 }
You can’t perform that action at this time.
0 commit comments