File tree Expand file tree Collapse file tree 1 file changed +10
-5
lines changed
Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Original file line number Diff line number Diff line change 11import { Router } from 'express' ;
2+ import memoizee from 'memoizee' ;
23
34import { EnvVars } from '../config' ;
45
@@ -8,14 +9,18 @@ export const addTempleAdsRedirection = (
89 isMisesVariable : boolean ,
910 templeAdsPathMainPart = path
1011) => {
12+ const getRedirectionUrl = memoizee (
13+ ( extVersion : string , isMisesBrowser : boolean ) =>
14+ `${ EnvVars . TEMPLE_ADS_API_URL } /v1/api/ads-rules/${ extVersion } ${ templeAdsPathMainPart } ${
15+ isMisesVariable ? ( isMisesBrowser ? '/mises' : '/no-mises' ) : ''
16+ } `,
17+ { max : 1000 , normalizer : args => JSON . stringify ( args ) }
18+ ) ;
19+
1120 router . get ( path , ( req , res ) => {
1221 const { extVersion : rawExtVersion , isMisesBrowser : rawIsMisesBrowser } = req . query ;
1322 const extVersion = typeof rawExtVersion === 'string' ? rawExtVersion : '0.0.0' ;
1423 const isMisesBrowser = rawIsMisesBrowser === 'true' ;
15- res . redirect (
16- `${ EnvVars . TEMPLE_ADS_API_URL } /v1/api/ads-rules/${ extVersion } ${ templeAdsPathMainPart } ${
17- isMisesVariable ? ( isMisesBrowser ? '/mises' : '/no-mises' ) : ''
18- } `
19- ) ;
24+ res . redirect ( getRedirectionUrl ( extVersion , isMisesBrowser ) ) ;
2025 } ) ;
2126} ;
You can’t perform that action at this time.
0 commit comments