Matt McInnes Sparesbox Technical Test 2021
Run on your local machine
Exposes API on port 3000
If you have a Mailgun account
- Fill in the missing fields in
env
- Copy
env
to.env
If you don't you can download a copy of the CloudFormation .env from here
Run the following commands to start the program
npm install
npm run serve
Deploy to AWS using CloudFormation using deploy command
Depends on AWS CLI Tools, curl, bash
This executes the deploy.sh file in the project root and uses your configured AWS credentials
The URL will be displayed in the terminal after deployment
The API is exposed on port 80
npm run deploy
Deploy to AWS using CloudFormation manually
Depends on AWS CLI Tools
From the project root run, replace $privateKey with the name of an available key
aws cloudformation deploy --template-file template.json --stack-name technical-test --parameter-overrides KeyName=$privatekey
aws cloudformation describe-stacks --stack-name technical-test | grep OutputValue
Swagger API files are provided with the project
These can be accessed at the root of the API or in the /static/swagger
folder of the project
http://127.0.0.1:3000/
will return the raw JSON data
http://127.0.0.1:3000/?format=html
will return a rendered HTML page of the documentation
Tests have been written using the Mocha library
Tests are located in the test
folder of the project
To execute them run the following commands, this will install all dependencies including Mocha
npm install
npm run test
SQLite was chosen due to the portability and quick setup. If the project was any larger than this or expected to grow larger I would have used a full-fledged RDBMS and ORM
Deployment script has only been tested on macOS due to time constraints
Express as the router/server
Mocha as the testing framework
Chai as the assertion library
Mailgun as the email service
Deploys a t2.small EC2 instance running Amazon Linux
Installs git, Docker, curl
Downloads Dockerfile, .env from S3
Runs git clone against the Github repository here
Builds and starts the docker image