Skip to content

🚀 L³ application demo with preconfigured routes and middleware.

Notifications You must be signed in to change notification settings

lambda-lambda-lambda/example

Repository files navigation

restfulApiHandler

application demo with preconfigured routes and middleware.

Dependencies

VS Code extensions

Cloning this project

$ git clone --recurse-submodules https://github.com/lambda-lambda-lambda/example.git

Running your app

In the VS Code Command Palette choose "Open Folder in Container" which will launch your application in a Docker container allowing for realtime development and testing. Once launched, the application can be accessed at http://localhost:3000/api and tested using the VS Code Swagger Viewer (swagger.json) or by appending ?swagger-ui=html to any active routes.

Deploying to AWS

$ ./deploy --profile <AWS credentials profile>

AWS requirements

In order to successfully deploy your application you must have set-up your AWS Config and have created an IAM user with the following policies:

WARNING: The policies above are provided to ensure a successful application deployment. It is recommended that you adjust these policies to meet the security requirements of your Lambda application. They should NOT be used in a Production environment.

Mounting the AWS configuration

In order to deploy from within the container using VS Code terminal you will need to enable* the following line in: .devcontainer/devcontainer.json

"mounts": ["source=${localEnv:HOME}/.aws,target=/root/.aws,type=bind,consistency=cached"],

(*) Requires container rebuild.

Developers

CLI options

Run ESLint on project sources:

$ npm run lint

Generate Swagger OpenAPI definitions:

$ npm run genapi

Generate documentation using JSDoc:

$ npm run gendoc

Run Mocha integration tests:

$ npm run test

Known issues

Project files are assigned incorrect priviledges

If you experience this when working between local/remote development environments this is due to the user UID not being present during build time. In this case the default 1000 is defined as both the UID/GID for the remote user. You can override this behavior by updating the following project devcontainer.json build arguments or by exporting the UID/GID in your .bash_profile.

"build": {
  "dockerfile": "Dockerfile",
  "args": {
    "UID": "${localEnv:UID:1234}", // Default to 1234
    "GID": "${localEnv:GID:1234}"
  }
},

References