You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Api Rest for the statistical management of production and sales of bioethanol based on cane and corn implemented with Api-Gateway, Nodemon, Serverless-Framework, NodeJs, DynamoDB, Systems Manager Parameter Store, Lambda among others. AWS services are tested locally. The project code and its documentation (less technical doc) have been developed in English.
Api Rest for the statistical management of the production and marketing of bioethanol based on cane and corn. For its main architecture, all dynamo operations are covered through modularized helpers, endpoints through controllers, enumerations are used, etc. All necessary CRUD operations are also applied, as well as validations of credentials, tokens, headers, body, etc. for each endpoint of each table. The dynamodb tables involved are bioethanolPrices, bioethanolTotal, and bioethanolTypes.
Important: There are security alerts from dependabot that were closed as they point to the "serverless-dynamodb-local" plugin. Do not apply security patches to that plugin, as version ^1.0.2 has problems creating tables and running the dynamo service. It is recommended to keep the latest stable version ^0.2.40 with the security alerts generated.
We install the Serverless Framework globally if we have not already done so
npm install -g serverless
We verify the version of Serverless installed
sls -v
We install all the necessary packages
npm i
Important: There are security alerts from dependabot that were closed as they point to the "serverless-dynamodb-local" plugin. Do not apply security patches to that plugin, as version ^1.0.2 has problems creating tables and running the dynamo service. It is recommended to keep the latest stable version ^0.2.40 with the security alerts generated.
For simplification purposes, the file for ssm variables (serverless_ssm.yml) is included. It is recommended not to include or change credentials, token, etc.
The following script configured in the project's package.json is responsible for
Lift serverless-offline ("serverless-offline")
run serverless-offline ("start")
run nodemon and serverless ("start:dev")
format all js and ts files with prettier ("format-prettier")
format all .md files with remark ("format-remark")
We run the app with nodemon to auto detect changes from the server.
npm run start:dev
Important: It is possible that there are other previous steps that have not been included due to synchronization between docs in relation to development. Please open a conversation thread within the 'Issues' section of the project.
We install the Serverless Framework globally if we have not already done so
npm install -g serverless
We verify the version of Serverless installed
sls -v
We initialize a serverles template
serverless create --template aws-nodejs
We initialize an npm project
npm init -y
We install serverless offline
npm i serverless-offline --save-dev
We add the plugin inside the serverless.yml
plugins:
- serverless-offline
We install serverless ssm
npm i serverless-offline-ssm --save-dev
We add the plugin inside the serverless.yml
plugins:
- serverless-offlline-ssm
We install the plugin to use dynamodb locally (Not the dynamoDB service, this is configured in the files within .dynamodb).
Important: There are security alerts from dependabot that were closed as they point to the "serverless-dynamodb-local" plugin. Do not apply security patches to that plugin, as version ^1.0.2 has problems creating tables and running the dynamo service. It is recommended to keep the latest stable version ^0.2.40 with the security alerts generated.
npm install serverless-dynamodb-local --save-dev
We add the plugin inside the serverless.yml
plugins:
- serverless-dynamodb-local
We install the dynamodb client sdk for the necessary db operations
npm install @aws-sdk/client-dynamodb
We install the dynamodb sdk lib for the necessary db operations
npm i @aws-sdk/lib-dynamodb
We will modify the initial template for the standardized configs.
We replaced the initial serverless.yml template with the following one as the base model (change name, etc)...
We should expect a console output with the following services raised when the previous command is executed
> crud-amazon-dynamodb-aws@1.0.0 start
> npm run serverless-offline
> crud-amazon-dynamodb-aws@1.0.0 serverless-offline
> sls offline start
serverless-offline-ssm checking serverless version 3.31.0.
Dynamodb Local Started, Visit: http://localhost:8000/shell
DynamoDB - created table xxxx
etc.....
We already have a functional app with an initial structure defined by Serverless-Framework. The application is deployed at http://localhost:4002 and we can test the endpoint declared in the serverless from postman
Clarification: The rest of the modifications applied to the initial template are not described due to document simplification issues. For more information consult See the Serverless-framework tutorial for using services, plugins, etc.
{
"message": "Bad request, check request body attributes for bioetanol-precios. Missing or incorrect"
}
Response (400 Bad Request)
{
"message": "Bad request, check missing or malformed headers"
}
Response (401 Unauthorized)
{
"message": "Not authenticated, check x_api_key and Authorization"
}
Response (500 Internal Server Error)
{
"message": "Internal Server Error. Unable to update object in db as failed to get a item by uuid 67ecfcf7-c338-43d8-9220-4d7b43b7e914 . Check if the item exists in the database and try again."
}