Giter Site home page Giter Site logo

schlpbch / bookingapi Goto Github PK

View Code? Open in Web Editor NEW
15.0 17.0 7.0 1.42 MB

A simple API to book tickets for public transport in Switzerland.

License: Apache License 2.0

JavaScript 72.44% HTML 24.18% CSS 2.79% Dockerfile 0.59%
booking public-transportation api switzerland sbb

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...

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!

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 run the App, do:

  npm run dev

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>

bookingapi's People

Contributors

blasersi avatar codepfleger avatar dependabot[bot] avatar jlupi avatar kreuzerk avatar nebucaz avatar schlpbch avatar timetable2014 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bookingapi's Issues

Login with Popup

Description
In the top right corner of the toolbar we want to have a login icon. By clicking on this icon a login form shows up in a popup. The user can now enter his credentials and login via Basic Auth. The goal of this task is to take the existing login mechanism and show it inside of a popup.

Background Infromation
The whole basic auth login mechanism is already implemented. At the moment a not logged in user arrives on the login page. The goal is that the user always arrives on the main page and can then design to login. As long as he is not logged in the user can still use the Booking API with the mock. As soon as he is logged in we will call the WSG.

npm run serve - reverse proxy not working

wanted to use npm run serve while developing. Expecting it will not minify source and watch for changes. queries will not be answered. It is annoying to use npm run dev while developing - am I wrong?

screen shot 2017-05-23 at 06 23 54

Size of bundle is too big

The size of the bundle is more than 6 MB, which takes to long to load on a mobile link. Please reduce significantly​.

About & Settings

By clicking on the right button a popup with the following informations should appear.

  • About / List of Contributors
  • Settings / Switch between Mock and Test BE
  • Copyrighty / Displays the Copyright and the link to the Github Repo

/trip documentation not complete

The documentation of the /trip service is not complete. Documentation at http://booking.sbb.ch/docs/#!/default/trips
is
[ { "tripId": "string", "trips": [ { "origin": { "id": "8507785", "name": "Bern", "date": "2017-01-14", "time": "20:14" }, "destination": { "id": "8507785", "name": "Bern", "date": "2017-01-14", "time": "20:14" } } ], "_links": [ { "rel": "string", "href": "string" } ] } ]

The actual response reads
[{"tripId":"trip-rec-context1","segments":[{"origin":{"id":"8507000","name":"Bern","date":"2017-06-14","time":"20:04"},"destination":{"id":"8507100","name":"Thun","date":"2017-06-14","time":"20:22"}}],"_links":{"self":{"href":"trips/trip-rec-context1"},"prices":{"title":"Request the cheapest prices for a trip.","href":"api/prices/trip-rec-context1"},"offers":{"title":"Request offers for a trip.","href":"api/offers?originId=8507000&destinationId=8503000&date=2017-06-14&time=20:04"},"link2WebshopB2C":{"title":"Link into Webshop B2C.","href":"https://www.sbb.ch/en/buying/pages/fahrplan/fahrplan.xhtml?suche=true&ab=tr…PreviewMode=active&von=Thun&nach=Bern&datum=Sun%2C+14.06.2017&zeit=20%3A04"},"link2MobileB2C":{"title":"Link into Mobile App B2C.","href":"https://apptest.sbbmobile.ch/trip/offer?recon=T$A=1@O=Bern@L=8507000@a=128@$A=1@O=Thun@L=8507100@a=128@$201706142004$201706142156$&date=2017-06-14"}}},{"tripId":"trip-rec-context2","segments":[{"origin":{"id":"8507000","name":"Bern","date":"2017-06-14","time":"20:34"},"destination":{"id":"8507100","name":"Thun","date":"2017-06-14","time":"20:52"}}],"_links":{"self":{"href":"trips/trip-rec-context2"},"prices":{"title":"Request the cheapest prices for a trip.","href":"api/prices/trip-rec-context2"},"offers":{"title":"Request offers for a trip.","href":"api/offers?originId=8507000&destinationId=8503000&date=2017-06-14&time=20:34"},"deeplinkWebshopB2C":{"title":"Link into Webshop B2C.","href":"https://www.sbb.ch/en/buying/pages/fahrplan/fahrplan.xhtml?suche=true&ab=tr…PreviewMode=active&von=Thun&nach=Bern&datum=Sun%2C+14.06.2017&zeit=20%3A34"},"deeplinkMobileB2C":{"title":"Link into Mobile App B2C.","href":"https://apptest.sbbmobile.ch/trip/offer?recon=T$A=1@O=Genève@L=8501008@a=128@$A=1@O=Bern@L=8507000@a=128@$201605161012$201605161156$IR 2517$&date=2017-06-14"}}}]

Correlation ID needed

Any thoughts about a correlation ID yet?
Do we already need it as a header-parameter?

Fix command pattern in /bookings

The pattern should be:

  • /bookings/{bookingId}/fulfil
  • /bookings/{bookingId}/cancel

This allows us to scale commands on a resource more easily.

Prices-link in trip-response wrong

Link to prices endpoint in trip-response is
"prices":{"title":"Request the cheapest prices for a trip.","href":"api/prices/trip-rec-context1"}

Documentation expects url-parameters like so:
"prices":{"title":"Request the cheapest prices for a trip.","href":"api/prices?tripId=trip-rec-context1"}

Review 01.03.2017

Rename:

  • books --> bookings
  • prebooks -> prebookings
  • personen -> persons
  • cancel -> cancellations
  • German function in app/controllers/app.js

Same for tests.

Fix:

  • modularize app.js into different controllers

Pricing Api

es soll ein sehr einfaches Preisauskunfts API geben, welches den billigsten Preis gibt. Basis ist ein 1/2 Abo für einen Erwachsenen

Get the link concept of webshopB2C fixed

// TODO: Get the link concept of webshopB2C fixed
// - use UIC Codes instead of station names
// - strange mix of English and German
// - add referrerId and app tags

Get the link concept of Mobile fixed

// TODO: Get the link concept of Mobile fixed
// - don't use the hafas reconstruction context, makes us stick to Hafas sessions
// - Add time to query
// - change fare to reduction concept

Error Log

In the client we want to log all errors in the error log.

acceptance criteria:

  • Errors are logged with the corresponding error code and error message
  • The error log pops up when an error occures
  • The errors can be copied

Operation ID bei Links

Brauchen wir eigentlich nicht sowas wie eine operationId für die Linkliste?
Wie kann man sonst identifizieren ob ein Link zum Drucken oder Annullieren ist?

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.