The repository serves to manage the files that are deployed on AWS lambda using github actions.
- AWS Lambda/Gateway Auto Deploy Repository
Within AWS we have the following components:
- AWS DynamoDB which serves as a key pair table.
- AWS Lambda connecting our API Gateway with DynamoDB.
- AWS Gateway that manages access to our routes.
The github action uploads the index.js
file into AWS Lambda using the following steps:
- Inside the
.github\workflows
we have themain.yml
file that builds a VM inside Github, starting a ubuntu server that make the deploy. - The file
index.js
passes through NCC for unification. - The output dist is ziped.
- Finnaly the ziped file is passed to AWS lambda server.
AWS access management is done using an automated IAM user to access server acess keys.
Inside our API Gateway, we have the link https://g0deojz10k.execute-api.us-east-2.amazonaws.com, were we make the request to our routes.
On the DynamoDB we are going to use the following columns structure:
- email: This is our primary key, when the put method is called it passes trought a basic validation.
- name: The name of the user.
- fone: It have to be numeric.
- createdAt: When the rows was created, is automatically generated, in Epoch with ms.
- status: Have to be "prospect" or "client". It is set do default "prospoct".
- lastUpdatedAt: When the rows was last updated, is automatically generated, in Epoch with ms.
- customerAt: When the status "propspect" was changed to "customer", in Epoch with ms.
Our api have the following routes:
GET /leads
Returns the items list with the following structure:
{
"Items": [
{
"status": ...,
"createdAt": ...,
"lastUpdatedAt": ...,
"customerAt": ...,
"email": ...,
"name": ...,
"fone": ...
}
],
"Count": 1,
"ScannedCount": 1
}
PUT /leads
The item must be send with the following structure:
{
"email": ...,
"name": ...,
"fone": ...,
"status": ... (optional)
}
Remembering that as dynamo uses key pair. Returns:
{
"email": ...,
"name": ...,
"fone": ...,
"createdAt": ...,
"status": ...,
"lastUpdatedAt": ...,
"customerAt": ...
}
GET /lead/{email}
Where email is the email of the item without the brackets. Returns the item in Dynamo with the following structure:
{
"Item": {
"status": ...,
"createdAt": ...,
"lastUpdatedAt": ...,
"customerAt": ...,
"email": ...,
"name": ...,
"fone": ...
}
}
DELETE /lead/{email}
Where email is the email of the item without the brackets.
PATCH /lead/{email}
On the Json body, columns can be send to update the item. It keeps all the other columns as it is on DynamoDB.
Example:
{
"name": "much name! such easy! wow!"
}
It returns the full item:
{
"status": ...,
"createdAt": ...,
"lastUpdatedAt": ...,
"customerAt": ...,
"email": ...,
"name": ...,
"fone": ...
}
- Put the email as id.
- Validate email.
- Create the created at column.
- Create the last update at column.
- Create status column.
- Create an http patch method.
- Add correct http status to each method.
- Create Search Methods Using Parameters.
- Updated readme
- Changed routes from item/items to lead/leads
- Added functions to handle Dynamo
- Added the customerAt column
- Removed the Post method
- Changed project structure
- Email now is the primary key
- The methods now have their http status
- Added new columns
- Changed the language of the project.
- First version of the project with basic functionality.