service to detect season based on geo position
- Dependencies
- Quick start
- Application environment
- Unit test
- Integration test
- API documentation
- Season algorithm
this service integrates with
- install node and yarn. Install yarn using below command.
npm install -g yarn
- clone the repo from the github.
git clone "git@github.com:iAbhishek91/season-predictor-api.git"
- install the required packages
yarn
- quick start the application (refer application environment section for detail information)
yarn start
- best way to run this application is in docker. Note the Docker file runs the application in test mode. more detail below.
we have two mode of this application: dev and test.
- dev mode:
- run with mocks, without actual integration
- development and unit testing should be performed on this env.
- execute the below command for starting the app in dev mode.
- post used: 2424
yarn start
- test mode
- runs with actual integration with other services.
- end to end test can be performed in this mode.
- execute the below command for starting the app in dev mode.
- port used: 1212
yarn start:test
alternatively, using docker
# from the root folder of season-predictor-api
docker build -t abdas81/season-predictor .
# from the root folder of temperature-service-api
docker build -t abdas81/temperature-service .
# from the root folder of season-predictor-api
docker-compose up
Note: The images are uploaded in docker hub. Please refer docker hub Docker compose will automatically pull from globa docker registry.
- this microservice has 100% unit test coverage.
- also lint test are integrated.
yarn test
post execution of unit test, following reports are generated.
- coverage report: available at
./coverage/Icov-report/index.html
. - unit test report: avialble at
./unitTestResult.html
NOTE: integration test runs on test mode of the app because dev environment runs on Mock. Pre requisits: start both the service in docker. To start app under test mode under, refer sectionApplication environment
- all out integration tests are in
./test
folder.
yarn test:integration
post execution of integration test, following reports are generated.
- integration test report: avialble at
./integrationTestResult.html
refer API documentation: <hosted-domain>/api/v1/docs
based on temperature and humidity, season is determined based on the below ficticious algorithm:
- termperature between 0 and 45 degree centigrade and humidity < 50 % - WINTER
- termperature between 46 and 100 degree centigrade and humidity >= 50 % - SUMMER
- termperature between 0 and 45 degree centigrade and humidity > 50 % - AUTUMN
- termperature between 46 and 100 degree centigrade and humidity <= 50 % - SPRING
in this app we use different types of mock to facilitate development and unit testing.
- module mocks: axios module is mocked on global level for unit testing.
- service mocks: we have custom mock server built-in which stubs
temperature-service-api
. Hence we can easily develop in isolation.
NOTE: mocks only works in development environment.