airport-router v0.0.3
NodeJs Backend test-task
About package
Someone could find useful to extend this package that could help to find shortest/fastest way to go from Airport A to Airport B. Algorythm in the file ./src/app/index.ts
Task description
The test task consists of two parts, the main part, and a bonus part. We suggest tackling the bonus part once the main objective of the service has been achieved.
The task is to build a JSON over HTTP API endpoint that takes as input two IATA/ICAO airport codes and provides as output a route between these two airports so that:
- The route consists of at most 4 legs/flights (that is, 3 stops/layovers, if going from A->B, a valid route could be A->1->2->3->B, or for example A->1->B etc.) and;
- The route is the shortest such route as measured in kilometers of geographical distance.
For the bonus part, extend your service so that it also allows changing airports during stops that are within 100km of each other. For example, if going from A->B, a valid route could be A->1->2=>3->4->B, where “2=>3” is a change of airports done via ground. Multiple ground hops are allowed, but they cannot be consecutive. These switches are not considered as part of the legs/layover/hop count, but their distance should be reflected in the final distance calculated for the route.
Notes:
- The weekdays and flight times are not important for the purposes of the test task - you are free to assume that all flights can depart any required time
- You are free to choose to use any open-source libraries
- You can ask additional questions
Service
In this repository, you will find an express service written in typescript. The repository assumes you have configured Yarn and Node.js (18+) on your system.
Your goal is to modify this service so that it fulfills the requirements of the test task.
The service is already configured with data from OpenFlights, which albeit outdated, will work fine for the purposes of this test task.
The service also includes a set of tests, which can be executed via yarn test
, these represent two cases for the first part and one case for the second part of the task. Once you are confident that your solution works, these tests should pass. Notice that these tests also enforce a specific response format for your service.
Docker
The service is also setup to run in docker, you can use the docker-compose file to run either the service itself (exposes the same port 3000 as with yarn start
/yarn start:dev
) - docker-compose up -d service
.
You can also run the tests via docker-compose up test
.