Giter Club home page Giter Club logo

express-api's Introduction

Technical Test

Matt McInnes Sparesbox Technical Test 2021

Installation

Option 1

Run on your local machine

Exposes API on port 3000

If you have a Mailgun account

  1. Fill in the missing fields in env
  2. 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

Option 2

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

Option 3

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

Documentation

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

Testing

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

Compromises/Reasoning

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

General Information

API

Express as the router/server

Mocha as the testing framework

Chai as the assertion library

Mailgun as the email service

CloudFormation

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.