Code Monkey home page Code Monkey logo

bookingapi's Introduction

Build Status dependencies Status

About

This a simple Node.js based mock server to test the bookingAPI. The mock implementation is intended for fast protoyping and to get the API right (Getting APIs right is hard).

To get the API right, a small web application is provided (we are drinking our own champagne).

Once the API is right, the API will be implemented of SBB's distribution system and provided by a simple to access API Management tool. Here is an example of how it might look like:

More to come...

Here you can find a initial functional road map.

Installing

The easiest way is to pull the docker image:

docker pull schlpbch/bookingapi

The latest docker image is always available at https://hub.docker.com/r/schlpbch/bookingapi/.

Running the Mock Server

The easiest way is to run the docker image:

  docker pull schlpbch/bookingapi
  docker run -d -p 80:8080 --name bookingapi-mock schlpbch/bookingapi

or start with

  node app.js

The web app and the API are then running at http://localhost/

Running the Mock Server with NGINX Firewall

Using docker-compose a software defined firewall (see NGINX) is added in front of the mocked server and is linked to the mock server using a software defined network. This allows us to test authentication methods using JSON Web Tokens (JWT) later.

See docker-compose.yml for details.

To start simply use

  docker-compose up

The server uses self signed certificates, they must be replaced with real ones for production!

Live App and Documentation

The Web App is available at:

Thanks to SwaggerUI the up-to-date documentation is always available at:

and the latest JSON can be accessed at:

Developing First, Nodejs and npm which comes with it is needed. Then to install all the modules, simply run:

  npm install

This will install the package defined in package.json file.

To edit the API interactively, do:

  swagger project edit

The browser will then provide you with tab to edit the specification.

To run Swagger in mock mode, start with:

  swagger project start -m

To run the tests:

  swagger project test

To run the mock server, do:

  swagger project start

or more simple:

  npm run dev

npm run dev runs the the express app. It also creates a bundle for the front-end part. This bundle includes source maps for debugging.

To run the app in production please run the following command

  npm run prod

which minifies the bundle and excludes source maps as we do not want to deliver our code in plain text.

To run the mock server as docker container, do:

  docker build .
  docker run -d -p 8080:8080 --name api-mock-srv <containerId>

ToDo

  • Integrate Swagger Middleware to easily pre-populate data
  • Get the API right
  • Expose journey planning as a route of its own
  • Setup API Management
  • Setup Security (JSON Web Token)
  • Products API
  • Cache-Control
  • SuperSaver Prices
  • Validity-Information for Prebookings (20 min offers 30 min prebookings)

Done

  • Clarify legalese
  • Align with FSM specification
  • Complete wiring Wep App with API
  • Translate API to English
  • Write a client to verify the usability of the API (APIs are UIs for developers).
  • Align with Fahrplan team
  • Align with Open Data (better Open API) team

bookingapi's People

Contributors

blasersi avatar codepfleger avatar jlupi avatar kreuzerk avatar nebucaz avatar schlpbch avatar timetable2014 avatar

Watchers

 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.