{"id":21524112,"url":"https://github.com/helloakn/develop-aws-lambda-functions-locally","last_synced_at":"2025-04-28T11:50:16.053Z","repository":{"id":111312859,"uuid":"488799919","full_name":"helloakn/develop-aws-lambda-functions-locally","owner":"helloakn","description":"In this example. I use express node package as the api gateway. separated functions and layers.","archived":false,"fork":false,"pushed_at":"2022-05-08T03:46:14.000Z","size":53,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-11-24T01:23:25.180Z","etag":null,"topics":["aws-lambda","faas-platform","lambda-functions","lambda-layers","lambda-local","microservices","nodejs","rest-api"],"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/helloakn.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":"2022-05-05T01:58:04.000Z","updated_at":"2023-06-30T02:34:19.000Z","dependencies_parsed_at":"2023-05-23T08:15:37.888Z","dependency_job_id":null,"html_url":"https://github.com/helloakn/develop-aws-lambda-functions-locally","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/helloakn%2Fdevelop-aws-lambda-functions-locally","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/helloakn%2Fdevelop-aws-lambda-functions-locally/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/helloakn%2Fdevelop-aws-lambda-functions-locally/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/helloakn%2Fdevelop-aws-lambda-functions-locally/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/helloakn","download_url":"https://codeload.github.com/helloakn/develop-aws-lambda-functions-locally/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":235388546,"owners_count":18981945,"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-lambda","faas-platform","lambda-functions","lambda-layers","lambda-local","microservices","nodejs","rest-api"],"created_at":"2024-11-24T01:20:56.406Z","updated_at":"2025-01-24T05:11:02.596Z","avatar_url":"https://github.com/helloakn.png","language":"JavaScript","readme":"# Develop AWS LAMBDA Functions/Layers as Locally\n\n[![NodeJs](https://img.shields.io/badge/nodejs-v16.14.2-green)](https://github.com/helloakn/develop-aws-lambda-functions-locally) \n[![NPM](https://img.shields.io/badge/npm-v8.5.0-green)](https://github.com/helloakn/develop-aws-lambda-functions-locally) \n[![Express](https://img.shields.io/badge/express-v^4.17.3-green)](https://github.com/helloakn/develop-aws-lambda-functions-locally)\n[![Language](https://img.shields.io/badge/dynamic/json?color=blueviolet\u0026label=Language\u0026query=language\u0026url=https%3A%2F%2Fapi.github.com%2Frepos%2Fhelloakn%2Fdevelop-aws-lambda-functions-locally)](https://github.com/helloakn/develop-aws-lambda-functions-locally)\n[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/feross/standard)\n[![Star Count](https://img.shields.io/badge/dynamic/json?color=brightgreen\u0026label=Star\u0026query=stargazers_count\u0026url=https%3A%2F%2Fapi.github.com%2Frepos%2Fhelloakn%2Fdevelop-aws-lambda-functions-locally)](https://github.com/helloakn/develop-aws-lambda-functions-locally)\n\nThis is just for simple project.  \nHowever, you can learn the file structure and strategies for aws lambda to develop in local.  \n\nbenefit of these file structure is to deploy easily as functions or the whole project.  \ncan be used for :  \n![](https://img.shields.io/static/v1?label=\u0026message=Monolith\u0026color=blue) ![](https://img.shields.io/static/v1?label=\u0026message=Yes\u0026color=green)  \n![](https://img.shields.io/static/v1?label=\u0026message=MicroService\u0026color=blue) ![](https://img.shields.io/static/v1?label=\u0026message=Yes\u0026color=green)    \n![](https://img.shields.io/static/v1?label=\u0026message=FaaS\u0026color=blue) ![](https://img.shields.io/static/v1?label=\u0026message=Yes\u0026color=green)  \n\n\n\n## Table of Contents\n- File Structure\n  - Before installation the npm dependences\n  - After installation the npm dependences\n- npm Dependences\n- How to Setup\n- How to Run\n- How to Test\n- Swagger\n- Acknowledgement\n\n### File Structure\nStructure is base on lambda functions.  \nSo we can easily deploy to lambda or ECS or EC2 as the monolith or microservice.  \nWe can separate authorizer and functions too.  \nAll the services on our code would be functions in Lambda and middleware will be lambda Authorizer as well as all the others are the layers.  \n\n#### Before installation the npm dependences\n```nth\n.\n├── http                        # dir for sqlite3 database\n|   ├── routes                  # sqlite3 db file\n│   │   ├── routegenerator.js\n│   │   └── routelist.js\n|   ├── package.json            # sqlite3 db file\n|   └── server.js               # sqlite3 db file\n├── lambda                      # nodejs source code\n│   ├── functions               # administrator and customer middlewares\n│   │   └── ...                 \n│   └── layers                  # Controllers , we can deploy them to AWS Lambda functions\n│       ├── v1                  # For all admin functions\n│       │   ├── package.json\n│       │   └── ...\n│       └── v2                  # For all user functions\n│           ├── package.json\n│           └── ...\n├── resources                   # for documentations\n│   └── ...\n├── .eslintrc.cjs               # for standar code check\n├── package.json \n├── README.md              \n└── ...\n```\n\n#### After installation the npm dependences\n```nth\n.\n├── http                        # dir for sqlite3 database\n|   ├── routes                  # sqlite3 db file\n│   │   ├── routegenerator.js\n│   │   └── routelist.js\n|   ├── package.json            # sqlite3 db file\n│   ├── node_modules\n│   │   └── ...\n|   └── server.js               # sqlite3 db file\n├── lambda                      # nodejs source code\n│   ├── functions               # administrator and customer middlewares\n│   │   └── ...                 \n│   └── layers                  # Controllers , we can deploy them to AWS Lambda functions\n│       ├── v1                  # For all admin functions\n│       │   ├── package.json\n│       │   ├── node_modules\n│       │   │   └── ...\n│       │   └── ...\n│       └── v2                  # For all user functions\n│           ├── package.json\n│           ├── node_modules\n│           │   └── ...\n│           └── ...\n├── resources                   # for documentations\n│   └── ...\n├── .eslintrc.cjs               # for standar code check\n├── package.json \n├── node_modules\n│   └── ...\n├── README.md              \n└── ...\n```\n\n### npm Dependences\n- Root\n  * [supervisor](https://www.npmjs.com/package/supertest)  ^0.12.0 - to restart app on source code changes or crash app\n  * [jest](https://www.npmjs.com/package/jest)  ^28.0.3 - for unit testing\n  * [supertest](https://www.npmjs.com/package/supertest)  ^6.2.3 - for api testing\n  - http\n    * [express](https://www.npmjs.com/package/express) ^4.18.1 - to handle rest api\n    * [cors](https://www.npmjs.com/package/cors) ^2.8.5 - for api cors allown and deny\n    * [swagger-jsdoc](https://www.npmjs.com/package/swagger-jsdoc)  ^6.2.1 - for api doc \n    * [swagger-ui-express](https://www.npmjs.com/package/swagger-ui-express)  ^4.3.0 - express api doc\n  - lambda\n    - functions\n      * nothing to install\n    - layers\n      - layerauthorizer\n        * [jsonwebtoken](https://www.npmjs.com/package/jsonwebtoken)  ^8.5.1 - JWT  \n      - v1\n        * [dotenv](https://www.npmjs.com/package/dotenv) ^16.0.0 - to load environment variable from .env file or sys environment variable\n        * [md5](https://www.npmjs.com/package/md5)  ^2.3.0 - for one way password hex \n        * [jsonwebtoken](https://www.npmjs.com/package/jsonwebtoken)  ^8.5.1 - JWT \n        * [mysql](https://www.npmjs.com/package/mysql)  ^2.18.1 - for db crud \n        \n### How to Setup\nWe have to install npm dependence to run our program smoothly. \npls follow as the singlie line of  the following command.\n```shell\nnpm run setup\n```\n![alt text](resources/install.png)  \n\n## How to Run\nConfiguration is just for dev(local) only. we can easily execute our program in local as the following command.\n```shell\nnpm run dev\n```\n## How to Test\nI use jest and supertest npm package for testing. main program is base on commajs and jest is base on model type. however we can run and test our program because i have configured in package.json. You can check the testing source code in [./test](https://github.com/helloakn/node-multi-authorizer-jwt/tree/main/tests) directory too. \nHere is the command to run the testing.\n```shell\nnpm test\n```\n![alt text](resources/test.png)  \n\n## Swagger\nwe can reach to our swagger from this link...  \n[Link](http://localhost:9999/swagger/)  API Doc swagger -\u003e http://localhost:9999/swagger/ \nWe can test the api ourselves.\n\n![alt text](resources/swagger.png) \n\n## Acknowledgement\nThank you all for visiting to my repo. please feel free to contact me.","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhelloakn%2Fdevelop-aws-lambda-functions-locally","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhelloakn%2Fdevelop-aws-lambda-functions-locally","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhelloakn%2Fdevelop-aws-lambda-functions-locally/lists"}