This repository contains a small nodejs/express app to tackle Comtravo's coding challenge below. Main challenge was asyncroniously consuming multiple mock 3rd party api's, merging results within a timeout limit.
Please plan and implement a service in Node.js which consumes 2 endpoints
(https://discovery-stub.comtravo.com/source1 & https://discovery-stub.comtravo.com/source2)
exposed by discovery-stub service(details see below).
Your service should get flights from these 2 routes, merge them, remove duplicates and send to the client.
As an identity of the flight can be used the combination of flight numbers and dates.
Note that discovery-stub service is not stable, i.e. it can sometimes fail or reply after couple of seconds.
The response time of your service shouldn't take longer than 1 second.
Please write tests for your implementation.
Below is the info regarding discovery service:
The URL: https://discovery-stub.comtravo.com/
API Specs: https://discovery-stub.comtravo.com/api-docs/
Heres the link for deployed example working on google cloud app engine standard
Install dependencies using, npm install
, then you can directly start api in local environment.
npm start
App is starting with swagger ui so you can directly use it to invoke calls to api, from http://localhost:8080/api-docs/
There are some env vars that need to be defined, you can check .env.template file and use it as a .env file template.
API_USER
and API_PASS
are not mandatory however 2nd source will always fail due to auth errors without them.
API_TIMEOUT
is set to 980 miliseconds when not set and can be used to override timeout value for data providers.
PORT
can be used to override default port which was 8000
for running tests, use:
npm run test
for checking linting, use:
npm run lint
- Model validations
- Making data services more moduler