@@ -8,59 +8,55 @@ interface SwnApiGatewayProps {
88 orderingMicroservices : IFunction 
99} 
1010
11- export  class  SwnApiGateway  extends  Construct  { 
11+ export  class  SwnApiGateway  extends  Construct  {   
1212
13-  constructor ( scope : Construct ,  id : string ,  props : SwnApiGatewayProps ) { 
13+  constructor ( scope : Construct ,  id : string ,  props : SwnApiGatewayProps )   { 
1414 super ( scope ,  id ) ; 
1515
1616 // Product api gateway 
1717 this . createProductApi ( props . productMicroservice ) ; 
1818 // Basket api gateway 
19-  this . createBasketApi ( props . basketMicroservice ) ;   
19+  this . createBasketApi ( props . basketMicroservice ) ; 
2020 // Ordering api gateway 
2121 this . createOrderApi ( props . orderingMicroservices ) ; 
2222 } 
2323
2424 private  createProductApi ( productMicroservice : IFunction )  { 
25-  
26-  // Product microservices api gateway 
27-  // root name = product 
28-  
29-  // GET /product 
30-  // POST /product 
31- 
32-  // Single product with id parameter 
33-  // GET /product/{id} 
34-  // PUT /product/{id} 
35-  // DELETE /product/{id} 
36- 
37-  const  apigw  =  new  LambdaRestApi ( this ,  'productApi' ,  { 
38-  restApiName : 'Product Service' , 
39-  handler : productMicroservice , 
40-  proxy : false 
41-  } ) ; 
42-  
43-  const  product  =  apigw . root . addResource ( 'product' ) ; 
44-  product . addMethod ( 'GET' ) ;  // GET /product 
45-  product . addMethod ( 'POST' ) ;  // POST /product 
46-  
47-  const  singleProduct  =  product . addResource ( '{id}' ) ; 
48-  singleProduct . addMethod ( 'GET' ) ;  // GET /product/{id} 
49-  singleProduct . addMethod ( 'PUT' ) ;  // PUT /product/{id} 
50-  singleProduct . addMethod ( 'DELETE' ) ;  // DELETE /product/{id} 
51- 
52-  return  singleProduct ; 
25+  // Product microservices api gateway 
26+  // root name = product 
27+ 
28+  // GET /product 
29+  // POST /product 
30+ 
31+  // Single product with id parameter 
32+  // GET /product/{id} 
33+  // PUT /product/{id} 
34+  // DELETE /product/{id} 
35+ 
36+  const  apigw  =  new  LambdaRestApi ( this ,  'productApi' ,  { 
37+  restApiName : 'Product Service' , 
38+  handler : productMicroservice , 
39+  proxy : false 
40+  } ) ; 
41+  
42+  const  product  =  apigw . root . addResource ( 'product' ) ; 
43+  product . addMethod ( 'GET' ) ;  // GET /product 
44+  product . addMethod ( 'POST' ) ;  // POST /product 
45+  
46+  const  singleProduct  =  product . addResource ( '{id}' ) ;  // product/{id} 
47+  singleProduct . addMethod ( 'GET' ) ;  // GET /product/{id} 
48+  singleProduct . addMethod ( 'PUT' ) ;  // PUT /product/{id} 
49+  singleProduct . addMethod ( 'DELETE' ) ;  // DELETE /product/{id} 
5350 } 
5451
5552 private  createBasketApi ( basketMicroservice : IFunction )  { 
56-  
5753 // Basket microservices api gateway 
5854 // root name = basket 
5955
6056 // GET /basket 
6157 // POST /basket 
6258
63-  // Single basket with userName parameter 
59+  // //  Single basket with userName parameter - resource name = basket/{userName}  
6460 // GET /basket/{userName} 
6561 // DELETE /basket/{userName} 
6662
@@ -87,10 +83,14 @@ export class SwnApiGateway extends Construct {
8783 } 
8884
8985 private  createOrderApi ( orderingMicroservices : IFunction )  { 
90-  
91-  // GET /order  
92-  // GET /order/{userName} 
93-  
86+  // Ordering microservices api gateway 
87+  // root name = order 
88+ 
89+  // GET /order 
90+  // GET /order/{userName} 
91+  // expected request : xxx/order/swn?orderDate=timestamp 
92+  // ordering ms grap input and query parameters and filter to dynamo db 
93+ 
9494 const  apigw  =  new  LambdaRestApi ( this ,  'orderApi' ,  { 
9595 restApiName : 'Order Service' , 
9696 handler : orderingMicroservices , 
@@ -107,5 +107,4 @@ export class SwnApiGateway extends Construct {
107107
108108 return  singleOrder ; 
109109 } 
110- 
111110} 
0 commit comments