Provides an API for storing user data in dynamo db. Only provides a PUT and a GET to allow you to add/update and get a user. Data held against the user is any JSON.
The API is secured by checking the user is only getting or putting data for the subject that they have identified as.
- If the user exists, responds with status code 200 and the information about the user
- If the user doesn't exist, responds with 404.
- If the user exists, responds with status code 200 and the information that was stored
- If the user doesn't exist, responds with status code 201 and the information that was stored
You'll need to have NPM the Serverless Framework installed.
- To install NPM, you'll need to download it from https://www.npmjs.com/get-npm
- Once NPM is installed you can run
npm install -g serverless
to install the Serverless Framework - Now run
npm install
to install the required packages for this application
When running locally or deploying to development environment variables will be loaded from .env.development. You can create this file based on .env.example
For more information see https://www.npmjs.com/package/serverless-dotenv-plugin
npm run offline
To test:
curl -X GET http://localhost:3000/user/100
curl -X PUT http://localhost:3000/user/100 -d '{"name": "Alice"}'
curl -X GET http://localhost:3000/user/100
curl -X PUT http://localhost:3000/user/100 -d '{"name": "Bob"}'
curl -X GET http://localhost:3000/user/100
Note that if you get
Error --------------------------------------------------
Unable to start DynamoDB Local process!
You'll need to run
sls dynamodb install --localPath ./bin
To deploy development run sls deploy
To deploy production run sls deploy -s production
Run all tests with npm run test
In the .test.
files alongside the source. Run with npm run unit
In the test/integration
folder. Run with npm run integration
Uses LambCI to build on a push to GitHub. As part of the build, we'll run the tests against a functions and database created in the cloud.
If all is successful, deploys to production.