Giter Site home page Giter Site logo

pmg's Introduction

Trains API

This repository contains a REST API for querying information about train compositions. It uses internally the digitraffic API available at https://rata.digitraffic.fi/ .

The app is deployed in heroku at https://intense-oasis-92112.herokuapp.com/api-docs/ .

Usage locally

Use npm install to install the required dependencies.

Use node server to start up the server.

API

The Main API is available as POST endpoint at http://localhost:3000/train-composition. Its required parameters are specified in JSON body, e.g.:

{ 
  stationShortCode: SLO,  // Specifies the station short code
  trainNumber: 197,194    // Specifies the numbers of the trains to retrieve
}

More detailed REST API documentation is hosted by the node app itself using Swagger UI. When running locally, it is hosted at http://localhost:3000/api-docs/ .

Information about the implementation

To reach production quality, the following should still be done:

  1. Add automatic/unit tests
  2. Better error management (messages, error codes)
  3. Host the API using HTTPS instead of HTTP
  4. Limit the amount of operations done to digitraffic API. Now the implementation starts several composition queries in parallel which might end up returning errors or timeouting due to limits in the digitraffic API implementation.
  5. Add validation for the input parameters
  6. Support also GET operation
  7. Support for form parameters
  8. Clean up the debug logging
  9. Consider sorting the response in the same order as the trainNumber list from user
  10. Consider making parameters optional
  11. Consider splitting the implementation to couple modules instead of single server.js file

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.