In this video.
Finally, we are going to start developing our product microservices lambda function.
So this will be using a SDK for JavaScript version three libraries.
We are going to install NPM package, which is the client dynamic DB and required package from the dynamic
DB interactions for the SDK JavaScript version three.
So we will develop our lambda function as a Node.js project in our local computers with using visual
pseudocode.
After that, we will zip and upload our Node.js project into lambda function on the cloud environment.
So let's get started.
Please open the widgets to the code.
I have created a separate folder in the lecture, but from now on we will continue through the the same
folder until this section is finished.
So that means I will be develop this project into this folder as a Node.js application.
So, so these lambda function will be develop into the our folder of the lecture 189 which name is product
cloud microservices?
Okay, let's get started.
I'm going to start with creating index JS file.
This will be our actual lambda function, but before that we should create a package JSON file.
In order to do that, please open the terminal and go to locate the folder structure.
Of the correct one, which is the Section 21 and Lecture 189 product microservices OC.
In this folder structure in the PowerShell command window, I'm going to run NPM init by command in
order to create package JSON file with default values.
So please hit the enter and this will be generate a package JSON file for this folder and this folder
will be our product microservice lambda function.
So if you open the package JSON file, you can see the default values of our application.
So basically the first thing we should do that we should add a type and type should be modeled.
So this is very important as you know, that we should add type model in order to gain ActionScript
six standards and modular architecture on the SDK JavaScript Version three.
These provide to use most eclipse codes into our Node.js projects.
For example, we can add the import statements.
So that's why this is mandatory.
Please don't forget to add this line of code.
Okay, let's continue the install required package.
We edit the empty package json file.
That means there is no any package now.
So now we can start to installing required npm packages.
So which packages are we are required.
So if you look at our architecture in product microservices, it is required to dynamo ADB HDC packets.
So that's why we should NPM install to record the ADB package which including a K JavaScript version
three version.
So how we can get these packets.
So if you look at our documentation here, you can see the API reference documentation for HDC.
So you can see that there is lots of packets that can available for our SDK libraries.
So I'm going to search for the client dash Dynamo DB.
So if you search for the client based on IMDB, you should search for the right hand side and open this
dynamic TV.
So that means we will use these packages when interacting or line IMDB to perform perturbation.
If you scroll down, you can see the NPM install command so we can see the package detail into API reference
documentation of SDK version three.
So go to Dynamo DB package and find the installing part and copy this line of code.
So we are using these NPM packages and this is the our first requirement for the NPM dependencies.
I'm going to copy this line of code and come to our package JSON file.
So in the same location, I'm going to copy and paste, which is the NPM install client dynamo DB.
So hit the enter and see what's going happened.
So as you can see that this is creating required node modules folder and will be modify or package JSON
file.
Yes.
See that nobodies are created successfully.
And if you check the our package JSON file, if you scroll down you can see the dependencies of the
dynamic DB edit successfully.
So that means we are ready to use these packages into our index.
JS which will be the lambda function code.
So also we need to install one more package.
Install required dynamic ADB SDK package, which is the util dynamic db.
I'm going to show the details in the documentation.
You can come here and see that there is a util library for dynamic DB.
This package provides utilities to be used in the client dynamic DB package.
And if we look at the dynamic DB document class, it is automatically performs the necessary marshalling
and marshalling operations.
So see that there is two main method which is the Marshall and Marshall.
And you can see that these utility class are important to Marshall and Marshall operation.
You can see the example on this documentation here.
You can see that there is an item definition of the dynamic DB.
So with the Marshall method, we don't specify any data type of the dynamic DB Normally, maybe you
remember in the last section, we always provide the data types like string as or number.
And so Marshall Method avoid these kind of operations.
We only write the item, value, item, value and item name in here.
This is providing some utilities and providing unnecessary data types using from the Dynamo DB.
It is automatically perform these data type operations on behind the scenes.
So that's why it is very useful utilization package that we are going to use here.
You can see, for example, get item from the Dynamo DB.
Normally when we are get item operation in the key section, we provide the number and string parameter
in here.
But with Marshall, we only provide a partition key and passing key value.
Okay, we understand the utility library and now it is time to install the required utility package
to our application.
Please go back to package json file in here.
So another so another NPM package is in here.
You can see that we will.
Right.
NPM install a double SDK utility db.
So I hit the enter to install this package.
And wait for a while.
As you can see that in the dependencies.
Now we have two dependencies to interact with Dynamo DB and perform business logics.
So finally we are ready to start the development with using these ac-dc packets.