@@ -31,8 +31,8 @@ function* loadHtml() {
3131 return html ;
3232}
3333
34- function * getRestaurants ( ) {
35- let url = URL . parse ( process . env . restaurants_api ) ;
34+ function * getRestaurants ( restaurantsApiUrl ) {
35+ let url = URL . parse ( restaurantsApiUrl ) ;
3636 let opts = {
3737 host : url . hostname ,
3838 path : url . pathname
@@ -41,14 +41,14 @@ function* getRestaurants() {
4141 aws4 . sign ( opts ) ;
4242
4343 let httpReq = http ( {
44- uri : process . env . restaurants_api ,
44+ uri : restaurantsApiUrl ,
4545 headers : opts . headers
4646 } ) ;
4747
4848 return new Promise ( ( resolve , reject ) => {
4949 let f = co . wrap ( function * ( subsegment ) {
5050 if ( subsegment ) {
51- subsegment . addMetadata ( 'url' , process . env . restaurants_api ) ;
51+ subsegment . addMetadata ( 'url' , restaurantsApiUrl ) ;
5252 }
5353
5454 try {
@@ -80,7 +80,7 @@ const handler = co.wrap(function* (event, context, callback) {
8080
8181 let restaurants = yield cloudwatch . trackExecTime (
8282 "GetRestaurantsLatency" ,
83- ( ) => getRestaurants ( )
83+ ( ) => getRestaurants ( context . restaurants_api )
8484 ) ;
8585 log . debug ( `loaded ${ restaurants . length } restaurants` ) ;
8686
@@ -89,10 +89,10 @@ const handler = co.wrap(function* (event, context, callback) {
8989 dayOfWeek,
9090 restaurants,
9191 awsRegion,
92- cognitoUserPoolId : process . env . cognito_user_pool_id ,
93- cognitoClientId : process . env . cognito_client_id ,
94- searchUrl : `${ process . env . restaurants_api } /search` ,
95- placeOrderUrl : `${ process . env . orders_api } `
92+ cognitoUserPoolId : context . cognito_user_pool_id ,
93+ cognitoClientId : context . cognito_client_id ,
94+ searchUrl : `${ context . restaurants_api } /search` ,
95+ placeOrderUrl : `${ context . orders_api } `
9696 } ;
9797 let html = Mustache . render ( template , view ) ;
9898 log . debug ( `rendered HTML [${ html . length } bytes]` ) ;
@@ -116,6 +116,7 @@ module.exports.handler = middy(handler)
116116 . use ( ssm ( {
117117 cache : true ,
118118 cacheExpiryInMillis : 3 * 60 * 1000 , // 3 mins
119+ setToContext : true ,
119120 names : {
120121 restaurants_api : `/bigmouth/${ STAGE } /restaurants_api` ,
121122 orders_api : `/bigmouth/${ STAGE } /orders_api` ,
0 commit comments