GithubHelp home page GithubHelp logo

airportapi's Introduction

This project is a simple airport API application based on Qantas API.

Run npm install to install dependencies.

Start Server

Run npm start to start server, then go to http://localhost:3000/ to get the API specification shown as below.

{
  "API Specification": {
    "/": "Show API Specification",
    "/api": "Show API Specification",
    "/api/v1": "Show API Specification",
    "/api/v1/airports?code={code}&country_code={country_code}&international_airport={true|false}&regional_airport={true|false}": "Return airport by filtered by request parameters (optional). Return all airports if there is no parameter",
    "/api/v1/airports/code/:code": "Return airports by filtering airport code",
    "/api/v1/airports/country/:countryCode": "Return airports by filtering country code",
    "/api/v1/airports/international/:internationalFlag": "Return airports by filtering international_airport flag",
    "/api/v1/airports/regional/:regionalFlag": "Return airports by filtering regional_airport flag"
  }
}

The API supports paths including both single parameter only and multiple parameters.

Filtered by multiple parameters (optional):

All parameters are optional. It will return all if there is no parameter.

http://localhost:3000/api/v1/airports?code=CAN&country_code=CN&international_airport=true&regional_airport=false

Filtered by single parameter:

  • Get Airport list by filtering airport code[CAN] only.
http://localhost:3000/api/v1/airports/code/CAN
  • Get Airport list by filtering country code[CN] only.
http://localhost:3000/api/v1/airports/country/CN
  • Get Airport list by filtering international_airport[true] only.
http://localhost:3000/api/v1/airports/international/true
  • Get Airport list by filtering regional_airport[true] only.
http://localhost:3000/api/v1/airports/regional/true

Unit Test (Jasmine)

Rum npm test to start unit test, you can check the test result on console log.

  1 Test controller/airportFilter.js
    ✓ Should return airport data while calling AirportFilter.filterByQuery with airport code[CAN], country_code[CN], international_airport[true], regional_airport[false] (5 secs)
.    ✓ Should return no data while calling AirportFilter.filterByQuery with invalid airport code[XXXX] (4 secs)
.    ✓ Should return data while calling AirportFilter.filterByCode with airport code[CAD] (4 secs)
.    ✓ Should return InvalidParameterError while calling AirportFilter.filterByCode without airport code (0.001 sec)

airportapi's People

Contributors

jonathanfu avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.