For this take home project I used a different node starter. This uses Serverless, node.js and TypeScript. I choose this starter to show how we can implement Typescript and OOP in a lambda function with serverless. This API could be deployed in AWS with a proper configuration and used as a service.
To create a new Serverless project.
$ serverless install --url https://github.com/mtoscan/generate-update-statement-typescript --name my-projectEnter the new directory
$ cd my-projectInstall the Node.js packages
$ npm installTo run a function on your local
$ serverless invoke local --function helloTo simulate API Gateway locally using serverless-offline
$ serverless offline startRun tests using
$ npm testI'm using Jest to run the tests. You can read more about setting up tests here.
- Improve type definitions to avoid use of any.
- More unit test cases
- Add environment variables
- Config serverless to deploy to AWS
You can import the file Backend_Take_Home.postman_collection.json in your postman app. You will find a collection of post request using the same data used in the test cases. Is required to simulate the API Gateway locally with serverless offline.