{"id":19961525,"url":"https://github.com/jhelison/http-crud-leads-function","last_synced_at":"2025-07-11T01:04:40.153Z","repository":{"id":92613946,"uuid":"399817709","full_name":"jhelison/http-crud-leads-function","owner":"jhelison","description":"The repository serves to manage the files that are deployed on AWS lambda using github actions.","archived":false,"fork":false,"pushed_at":"2021-08-28T12:05:46.000Z","size":59,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-01T16:47:45.779Z","etag":null,"topics":["aws","aws-lambda","dynamodb","gateway-api","lambda","serverless","vtex","vtex-io"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jhelison.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-08-25T12:52:00.000Z","updated_at":"2021-09-01T10:30:00.000Z","dependencies_parsed_at":null,"dependency_job_id":"93d146be-67a0-4613-87fd-92d52b97dcba","html_url":"https://github.com/jhelison/http-crud-leads-function","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/jhelison/http-crud-leads-function","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jhelison%2Fhttp-crud-leads-function","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jhelison%2Fhttp-crud-leads-function/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jhelison%2Fhttp-crud-leads-function/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jhelison%2Fhttp-crud-leads-function/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jhelison","download_url":"https://codeload.github.com/jhelison/http-crud-leads-function/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jhelison%2Fhttp-crud-leads-function/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264702701,"owners_count":23651814,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aws","aws-lambda","dynamodb","gateway-api","lambda","serverless","vtex","vtex-io"],"created_at":"2024-11-13T02:07:42.550Z","updated_at":"2025-07-11T01:04:40.143Z","avatar_url":"https://github.com/jhelison.png","language":"JavaScript","readme":"# AWS Lambda/Gateway Auto Deploy Repository\nThe repository serves to manage the files that are deployed on **AWS lambda** using github actions.\n \n:bangbang: This is under construction! See the todo list at the end for more details.\n\n## Table of contents\n\n- [AWS Lambda/Gateway Auto Deploy Repository](#aws-lambda-gateway-auto-deploy-repository)\n  * [Table of contents](#table-of-contents)\n  * [How it works.](#how-it-works)\n    + [How the AWS server works.](#how-the-aws-server-works)\n    + [How does Github actions work.](#how-does-github-actions-work)\n  * [Acess to the server](#acess-to-the-server)\n    + [GET /leads - All items](#get--leads---all-items)\n      - [Status codes](#status-codes)\n    + [PUT /leads - New item](#put--leads---new-item)\n      - [Status codes](#status-codes-1)\n    + [GET /lead/{email} - Specific item](#get--lead--email----specific-item)\n      - [Status codes](#status-codes-2)\n    + [DELETE /lead/{email} - Delete item](#delete--lead--email----delete-item)\n      - [Status codes](#status-codes-3)\n    + [PATCH /lead/{email} - Update on specific columns](#patch--lead--email----update-on-specific-columns)\n      - [Status codes](#status-codes-4)\n  * [Todo](#todo)\n  * [Changelog](#changelog)\n \n## How it works.\n \n### How the AWS server works.\nWithin **AWS** we have the following components:\n- **AWS DynamoDB** which serves as a key pair table.\n- **AWS Lambda** connecting our **API Gateway** with **DynamoDB**.\n- **AWS Gateway** that manages access to our routes.\n \n### How does Github actions work.\nThe github action uploads the `index.js` file into **AWS Lambda** using the following steps:\n- Inside the `.github\\workflows` we have the `main.yml` file that builds a VM inside **Github**, starting a ubuntu server that make the deploy.\n- The file `index.js` passes through NCC for unification.\n- The output dist is ziped.\n- Finnaly the ziped file is passed to **AWS lambda server**.\n \n**AWS** access management is done using an automated IAM user to access server acess keys.\n \n## Acess to the server\nInside our API Gateway, we have the link https://g0deojz10k.execute-api.us-east-2.amazonaws.com, were we make the request to our routes.\n\nOn the DynamoDB we are going to use the following columns structure:\n\n- email: This is our primary key, when the put method is called it passes trought a basic validation.\n- name: The name of the user.\n- fone: It have to be numeric.\n- createdAt: When the rows was created, is automatically generated, in Epoch with ms.\n- status: Have to be \"prospect\" or \"client\". It is set do default \"prospoct\".\n- lastUpdatedAt: When the rows was last updated, is automatically generated, in Epoch with ms.\n- customerAt: When the status \"propspect\" was changed to \"customer\", in Epoch with ms.\n\n:bangbang: Everytime the status is changed from \"prospect\" to \"customer\" the customerAt is updated.\n \nOur api have the following routes:\n \n### GET /leads - All items\n \n```http\n  GET /leads\n```\nReturns the items list with the following structure:\n```json\n{\n  \"Items\": [\n    {\n      \"status\": ...,\n      \"createdAt\": ...,\n      \"lastUpdatedAt\": ...,\n      \"customerAt\": ...,\n      \"email\": ...,\n      \"name\": ...,\n      \"fone\": ...\n    }\n  ],\n  \"Count\": 1,\n  \"ScannedCount\": 1\n}\n```\n\n#### Status codes\n[200](https://httpstatuses.com/200)\n\n### PUT /leads - New item\n \n```http\n  PUT /leads\n```\n \nThe item must be send with the following structure:\n \n```json\n{\n  \"email\": ...,\n  \"name\": ...,\n  \"fone\": ...,\n  \"status\": ... (optional)\n}\n```\n \nRemembering that as dynamo uses key pair.\nReturns:\n\n```json\n{\n  \"email\": ...,\n  \"name\": ...,\n  \"fone\": ...,\n  \"createdAt\": ...,\n  \"status\": ...,\n  \"lastUpdatedAt\": ...,\n  \"customerAt\": ...\n}\n```\n\n#### Status codes\n- [201](https://httpstatuses.com/201).\n- [409](https://httpstatuses.com/409), when the email is alread on DynamoDB.\n\n### GET /lead/{email} - Specific item\n \n```http\n  GET /lead/{email}\n```\nWhere email is the email of the item without the brackets.\nReturns the item in Dynamo with the following structure:\n```json\n{\n  \"Item\": {\n    \"status\": ...,\n    \"createdAt\": ...,\n    \"lastUpdatedAt\": ...,\n    \"customerAt\": ...,\n    \"email\": ...,\n    \"name\": ...,\n    \"fone\": ...\n  }\n}\n```\n#### Status codes\n- [200](https://httpstatuses.com/200).\n- [404](https://httpstatuses.com/404).\n\n\n### DELETE /lead/{email} - Delete item\n\n```http\n  DELETE /lead/{email}\n```\nWhere email is the email of the item without the brackets.\n\n#### Status codes\n- [204](https://httpstatuses.com/204).\n- [404](https://httpstatuses.com/404).\n\n### PATCH /lead/{email} - Update on specific columns\n\n```http\n  PATCH /lead/{email}\n```\nOn the Json body, columns can be send to update the item. It keeps all the other columns as it is on DynamoDB.\n\nExample:\n```json\n{\n\t\"name\": \"much name! such easy! wow!\"\n}\n```\n\nIt returns the full item:\n```json\n{\n  \"status\": ...,\n  \"createdAt\": ...,\n  \"lastUpdatedAt\": ...,\n  \"customerAt\": ...,\n  \"email\": ...,\n  \"name\": ...,\n  \"fone\": ...\n}\n```\n\n#### Status codes\n- [200](https://httpstatuses.com/200).\n- [404](https://httpstatuses.com/404).\n## Todo\n \n- [x]  Put the email as id.\n- [x]  Validate email.\n- [x]  Create the created at column.\n- [x]  Create the last update at column.\n- [x]  Create status column.\n- [x]  Create an http patch method.\n- [x]  Add correct http status to each method.\n- [ ]  Create Search Methods Using Parameters.\n\n## Changelog\n### 1.2.1 28/08/2021\n- Updated readme\n### 1.2.0 27/08/2021\n- Changed routes from item/items to lead/leads\n- Added functions to handle Dynamo\n- Added the customerAt column\n- Removed the Post method\n- Changed project structure\n### 1.1.0 26/08/2021\n- Email now is the primary key\n- The methods now have their http status\n- Added new columns\n### 1.0.1 25/08/2021\n- Changed the language of the project.\n### 1.0.0 24/08/2021\n- First version of the project with basic functionality.","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjhelison%2Fhttp-crud-leads-function","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjhelison%2Fhttp-crud-leads-function","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjhelison%2Fhttp-crud-leads-function/lists"}