66
77namespace MyWidgetService
88{
9- public class MyWidgetServiceStack : Stack
9+ internal sealed class MyWidgetServiceStack : Stack
1010 {
1111 public MyWidgetServiceStack ( Construct parent , string id , IStackProps props ) : base ( parent , id , props )
1212 {
13- var bucket = new Bucket ( this , "WidgetStore" , null ) ;
13+ var bucket = new Bucket ( this , "WidgetStore" ) ;
1414
1515 var handler = new Function ( this , "WidgetHandler" , new FunctionProps {
16- Runtime = Runtime . NODEJS_8_10 ,
17- Code = AssetCode . Asset ( "src/MyWidgetService/resources" ) ,
16+ Runtime = Runtime . NODEJS_10_X ,
17+ Code = Code . FromAsset ( "src/MyWidgetService/resources" ) ,
1818 Handler = "widgets.main" ,
19- Environment = new Dictionary < string , object > {
19+ Environment = new Dictionary < string , string > {
2020 { "BUCKET" , bucket . BucketName }
2121 }
2222 } ) ;
2323
24- bucket . GrantReadWrite ( handler , null ) ;
24+ bucket . GrantReadWrite ( handler ) ;
2525
2626 var api = new RestApi ( this , "widgets-api" , new RestApiProps {
2727 RestApiName = "Widget Service" ,
@@ -34,17 +34,17 @@ public MyWidgetServiceStack(Construct parent, string id, IStackProps props) : ba
3434 } ,
3535 } ) ;
3636
37- api . Root . AddMethod ( "GET" , getWidgetsIntegration , null ) ;
37+ api . Root . AddMethod ( "GET" , getWidgetsIntegration ) ;
3838
39- var widget = api . Root . AddResource ( "{id}" , null ) ;
39+ var widget = api . Root . AddResource ( "{id}" ) ;
4040
41- var postWidgetIntegration = new LambdaIntegration ( handler , null ) ;
42- var getWidgetIntegration = new LambdaIntegration ( handler , null ) ;
43- var deleteWidgetIntegration = new LambdaIntegration ( handler , null ) ;
41+ var postWidgetIntegration = new LambdaIntegration ( handler ) ;
42+ var getWidgetIntegration = new LambdaIntegration ( handler ) ;
43+ var deleteWidgetIntegration = new LambdaIntegration ( handler ) ;
4444
45- widget . AddMethod ( "POST" , postWidgetIntegration , null ) ;
46- widget . AddMethod ( "GET" , getWidgetIntegration , null ) ;
47- widget . AddMethod ( "DELETE" , deleteWidgetIntegration , null ) ;
45+ widget . AddMethod ( "POST" , postWidgetIntegration ) ;
46+ widget . AddMethod ( "GET" , getWidgetIntegration ) ;
47+ widget . AddMethod ( "DELETE" , deleteWidgetIntegration ) ;
4848 }
4949 }
5050}
0 commit comments