Skip to content

NavidBinAhmed/webapp_3_flight-path-tracker-javascript

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Flight Path Tracker Microservice API

Here is a detail doc for the format of the API endpoint

Overview

The created API for Flight Path Tracker as a microservice helps track and determine a passenger's flight path based on a list of unordered pair(s) of flight records, source and arrival points. On a broader sense, the API accepts a request that contains a list of flights defined by source and destination airport codes (IATA), sorts them, and returns the complete, compact, and viable flight path from take-off to the destination arrival airports.

Flow of Work

A. Tools Used and Steps of Development :

Tools

  1. Created a specified folder "JavaScript Flight Path Tracker" on local machine, H:/

  2. Opened VS Code via command terminal in the specified folder

  3. Initialized the project via 'bash'' terminal running the following commands mkdir flight-path-tracker cd flight-path-tracker npm init -y Which appeared this at my VS code terminal: HP@DESKTOP - 9LVHOGF MINGW64 /h/JavaScript Flight Path Tracker/flight-path-tracker

  4. Installed 2 following packages using the command below: express and body perser npm install express body-parser

  5. Created flight path sourcing logic on "findFlightPath.js" on the same directory

  6. Created server with express js and set up the '/calculate' API endpoint on "server.js"

B. Running the server locally (pre-testing)

  1. Installation of the dependancy 'npm' on 'bash' terminal using the below command: 'npm install'
  2. Starting the server: 'node server.js'
  3. 'Flight path tracker listening on port 8080' appears as follows: local_output

API Calculating Flight Path

API Endpoint: '/calculate'

Method: 'POST'

Request Format:

  • Content Type: 'application/json'
  • Body: 'Flights' contains an array of records as pair(s) in IATA format

Response Format:

  • Content Type: 'application/json'
  • Body: A JSON array with sorted, and compact flight path (as tested and shown below in 'Testing' section)

Error Response: 400 Bad Request

Checked for various invalid formats, i.e., 'flights' should be of two elements, start and end.

  • Sample error message: 'Invalid input format. Expected an array of flight records.'

Testing of API : Postman

Checked the performance of API on Postman locally and it worked as expected for different use cases and scenarios: flightpathapi

Airports and cities I typically stepped in taking multiple flights: It worked amazingly as expected! flight path api 2

  1. On Postman, locally installed: name the project or request to be made

  2. 'New' > Select 'POST' > Enter URL 'http://localhost:8080/calculate'

  3. 'Body' > 'raw' & 'JSON'

    { "flights": [ ["ATL", "EWR"], ["SFO", "ATL"] ] }

With various use cases, this JSON format changes.

  1. Clicking the 'send' outputs the following, as expected: ["SFO", "EWR"]

Tested for various use cases, for example: the direct, multiple, and complex flights.


References and required links: 1 2 3 4 5 6

Footnotes

  1. JavaScript Map Documentation

  2. Express/Node API Documentation

  3. Repo Documentation

  4. JIRA Dashboard

  5. Problem Assignment

  6. YouTube, ChatGpt, WWW

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published