1
00:00:00,240 --> 00:00:01,170
In this video.

2
00:00:01,200 --> 00:00:06,600
Finally, we are going to start developing our product microservices lambda function.

3
00:00:06,600 --> 00:00:12,210
So this will be using a SDK for JavaScript version three libraries.

4
00:00:12,210 --> 00:00:18,900
We are going to install NPM package, which is the client dynamic DB and required package from the dynamic

5
00:00:18,900 --> 00:00:22,530
DB interactions for the SDK JavaScript version three.

6
00:00:23,010 --> 00:00:28,470
So we will develop our lambda function as a Node.js project in our local computers with using visual

7
00:00:28,550 --> 00:00:29,280
pseudocode.

8
00:00:29,310 --> 00:00:35,310
After that, we will zip and upload our Node.js project into lambda function on the cloud environment.

9
00:00:35,310 --> 00:00:36,960
So let's get started.

10
00:00:36,990 --> 00:00:39,600
Please open the widgets to the code.

11
00:00:39,600 --> 00:00:45,810
I have created a separate folder in the lecture, but from now on we will continue through the the same

12
00:00:45,810 --> 00:00:48,030
folder until this section is finished.

13
00:00:48,030 --> 00:00:53,760
So that means I will be develop this project into this folder as a Node.js application.

14
00:00:53,760 --> 00:01:01,770
So, so these lambda function will be develop into the our folder of the lecture 189 which name is product

15
00:01:01,770 --> 00:01:03,030
cloud microservices?

16
00:01:03,330 --> 00:01:04,560
Okay, let's get started.

17
00:01:04,560 --> 00:01:08,070
I'm going to start with creating index JS file.

18
00:01:08,100 --> 00:01:15,690
This will be our actual lambda function, but before that we should create a package JSON file.

19
00:01:15,720 --> 00:01:22,500
In order to do that, please open the terminal and go to locate the folder structure.

20
00:01:23,440 --> 00:01:32,340
Of the correct one, which is the Section 21 and Lecture 189 product microservices OC.

21
00:01:32,410 --> 00:01:42,760
In this folder structure in the PowerShell command window, I'm going to run NPM init by command in

22
00:01:42,760 --> 00:01:46,540
order to create package JSON file with default values.

23
00:01:46,540 --> 00:01:53,230
So please hit the enter and this will be generate a package JSON file for this folder and this folder

24
00:01:53,230 --> 00:01:56,980
will be our product microservice lambda function.

25
00:01:56,980 --> 00:02:01,630
So if you open the package JSON file, you can see the default values of our application.

26
00:02:01,720 --> 00:02:08,440
So basically the first thing we should do that we should add a type and type should be modeled.

27
00:02:08,830 --> 00:02:14,530
So this is very important as you know, that we should add type model in order to gain ActionScript

28
00:02:14,560 --> 00:02:19,150
six standards and modular architecture on the SDK JavaScript Version three.

29
00:02:19,270 --> 00:02:23,740
These provide to use most eclipse codes into our Node.js projects.

30
00:02:23,740 --> 00:02:26,260
For example, we can add the import statements.

31
00:02:26,260 --> 00:02:27,760
So that's why this is mandatory.

32
00:02:27,760 --> 00:02:29,950
Please don't forget to add this line of code.

33
00:02:30,220 --> 00:02:33,190
Okay, let's continue the install required package.

34
00:02:33,490 --> 00:02:36,100
We edit the empty package json file.

35
00:02:36,100 --> 00:02:38,380
That means there is no any package now.

36
00:02:38,380 --> 00:02:42,670
So now we can start to installing required npm packages.

37
00:02:42,670 --> 00:02:45,550
So which packages are we are required.

38
00:02:45,550 --> 00:02:52,810
So if you look at our architecture in product microservices, it is required to dynamo ADB HDC packets.

39
00:02:52,810 --> 00:03:00,430
So that's why we should NPM install to record the ADB package which including a K JavaScript version

40
00:03:00,430 --> 00:03:01,270
three version.

41
00:03:01,390 --> 00:03:03,700
So how we can get these packets.

42
00:03:03,700 --> 00:03:09,670
So if you look at our documentation here, you can see the API reference documentation for HDC.

43
00:03:09,670 --> 00:03:16,000
So you can see that there is lots of packets that can available for our SDK libraries.

44
00:03:16,000 --> 00:03:20,530
So I'm going to search for the client dash Dynamo DB.

45
00:03:23,330 --> 00:03:31,580
So if you search for the client based on IMDB, you should search for the right hand side and open this

46
00:03:31,580 --> 00:03:32,480
dynamic TV.

47
00:03:32,510 --> 00:03:38,240
So that means we will use these packages when interacting or line IMDB to perform perturbation.

48
00:03:38,270 --> 00:03:44,180
If you scroll down, you can see the NPM install command so we can see the package detail into API reference

49
00:03:44,180 --> 00:03:47,540
documentation of SDK version three.

50
00:03:47,630 --> 00:03:52,670
So go to Dynamo DB package and find the installing part and copy this line of code.

51
00:03:52,850 --> 00:04:00,380
So we are using these NPM packages and this is the our first requirement for the NPM dependencies.

52
00:04:00,380 --> 00:04:05,750
I'm going to copy this line of code and come to our package JSON file.

53
00:04:06,080 --> 00:04:13,550
So in the same location, I'm going to copy and paste, which is the NPM install client dynamo DB.

54
00:04:13,580 --> 00:04:16,850
So hit the enter and see what's going happened.

55
00:04:17,690 --> 00:04:24,860
So as you can see that this is creating required node modules folder and will be modify or package JSON

56
00:04:24,860 --> 00:04:25,430
file.

57
00:04:26,610 --> 00:04:27,360
Yes.

58
00:04:27,360 --> 00:04:30,390
See that nobodies are created successfully.

59
00:04:30,390 --> 00:04:35,820
And if you check the our package JSON file, if you scroll down you can see the dependencies of the

60
00:04:35,820 --> 00:04:37,680
dynamic DB edit successfully.

61
00:04:37,680 --> 00:04:42,120
So that means we are ready to use these packages into our index.

62
00:04:42,120 --> 00:04:44,730
JS which will be the lambda function code.

63
00:04:45,430 --> 00:04:48,760
So also we need to install one more package.

64
00:04:48,850 --> 00:04:53,890
Install required dynamic ADB SDK package, which is the util dynamic db.

65
00:04:54,280 --> 00:04:57,070
I'm going to show the details in the documentation.

66
00:04:57,190 --> 00:05:01,660
You can come here and see that there is a util library for dynamic DB.

67
00:05:01,690 --> 00:05:06,950
This package provides utilities to be used in the client dynamic DB package.

68
00:05:06,970 --> 00:05:14,170
And if we look at the dynamic DB document class, it is automatically performs the necessary marshalling

69
00:05:14,170 --> 00:05:15,900
and marshalling operations.

70
00:05:15,910 --> 00:05:20,470
So see that there is two main method which is the Marshall and Marshall.

71
00:05:20,500 --> 00:05:26,830
And you can see that these utility class are important to Marshall and Marshall operation.

72
00:05:26,860 --> 00:05:29,740
You can see the example on this documentation here.

73
00:05:29,740 --> 00:05:33,140
You can see that there is an item definition of the dynamic DB.

74
00:05:33,160 --> 00:05:39,340
So with the Marshall method, we don't specify any data type of the dynamic DB Normally, maybe you

75
00:05:39,340 --> 00:05:46,390
remember in the last section, we always provide the data types like string as or number.

76
00:05:46,390 --> 00:05:50,880
And so Marshall Method avoid these kind of operations.

77
00:05:50,890 --> 00:05:56,260
We only write the item, value, item, value and item name in here.

78
00:05:56,290 --> 00:06:02,560
This is providing some utilities and providing unnecessary data types using from the Dynamo DB.

79
00:06:02,560 --> 00:06:07,180
It is automatically perform these data type operations on behind the scenes.

80
00:06:07,180 --> 00:06:12,430
So that's why it is very useful utilization package that we are going to use here.

81
00:06:12,430 --> 00:06:16,060
You can see, for example, get item from the Dynamo DB.

82
00:06:16,090 --> 00:06:24,220
Normally when we are get item operation in the key section, we provide the number and string parameter

83
00:06:24,250 --> 00:06:24,850
in here.

84
00:06:24,850 --> 00:06:29,640
But with Marshall, we only provide a partition key and passing key value.

85
00:06:29,880 --> 00:06:36,910
Okay, we understand the utility library and now it is time to install the required utility package

86
00:06:36,910 --> 00:06:38,050
to our application.

87
00:06:38,050 --> 00:06:41,000
Please go back to package json file in here.

88
00:06:41,020 --> 00:06:45,160
So another so another NPM package is in here.

89
00:06:45,190 --> 00:06:46,810
You can see that we will.

90
00:06:46,810 --> 00:06:47,230
Right.

91
00:06:47,230 --> 00:06:50,830
NPM install a double SDK utility db.

92
00:06:50,860 --> 00:06:54,070
So I hit the enter to install this package.

93
00:06:54,770 --> 00:06:56,150
And wait for a while.

94
00:06:57,200 --> 00:06:59,300
As you can see that in the dependencies.

95
00:06:59,300 --> 00:07:04,510
Now we have two dependencies to interact with Dynamo DB and perform business logics.

96
00:07:04,520 --> 00:07:09,680
So finally we are ready to start the development with using these ac-dc packets.
