production-ready-calculator-api

This is a sample project of how to create a production ready serverless api with tests and continues integration process

Server Status

 Status  Status

GitHub Repository

Tests

Installation

Install by running

npm install

Start the server with debug* (Optional to use F5 before running the script)

Start the server by running:

npm start

Start with nodemon by running:

npm run start-dev

Start the server with the netlify runner in dev mode (Debug is also optional here with F5)

Start the server by running:

npm run dev

Start the jest coverage tests

Start the tests by running:

npm test

API Design Documentation

/api/V0.1

POST

POST /api/V0.1/calculate

Query Parameters

Body

Response

Errors

For developers

Example Request

request({ method: 'POST', url: 'https://production-ready-calculator-api.netlify.app/api/V0.1/calculate', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ firstNumber: 2, secondNumber: 6, operator: '+' }, });

Example Response

200 OK

8

Unit tests cover status

Image_Of_Unit_Tests_Cover_Report

Pull Request / Contribute

PRs are only possible from a separate branch.

Before submitting a PR please validate lint, unit tests, test cover and version update:

*The correct way to increment the version is by using the correct npm script that represent the change you are introducing

Versions

Run npm version patch in cases of bug fixes or small modifications.

Run npm version minor in cases of functionality changes with non-breaking changes.

Run npm version major in cases of important functionality or any breaking changes.