All Projects → brakmic → Openlok

brakmic / Openlok

Licence: mit
🚈 React.js app to access the Deutsche Bahn API (German Railway Corporation)

Projects that are alternatives of or similar to Openlok

hapi-sequelizejs
A hapi.js plugin to connect with Sequelize ORM
Stars: ✭ 56 (+273.33%)
Mutual labels:  hapi
disinfect
Request query, payload, and params sanitization for Hapi
Stars: ✭ 20 (+33.33%)
Mutual labels:  hapi
Vudash
Powerful, Flexible, Open Source dashboards for anything
Stars: ✭ 363 (+2320%)
Mutual labels:  hapi
joi-to-typescript
Convert Joi Schemas to TypeScript interfaces
Stars: ✭ 73 (+386.67%)
Mutual labels:  hapi
hapi-cron
🕰️ Cron jobs for internal hapi.js routes
Stars: ✭ 41 (+173.33%)
Mutual labels:  hapi
good-influx
InfluxDB broadcasting for Good process monitor
Stars: ✭ 15 (+0%)
Mutual labels:  hapi
Crashlyzer
Crash viewer web application for displaying the crashes reported by rn-crash-reporter components from React Native mobile applications.
Stars: ✭ 59 (+293.33%)
Mutual labels:  hapi
Joi2gql
Conversion of Joi schemas into GraphQL data types
Stars: ✭ 11 (-26.67%)
Mutual labels:  hapi
graphql-tutorial
Tutorial for GraphQL
Stars: ✭ 24 (+60%)
Mutual labels:  hapi
Joi
The most powerful data validation library for JS
Stars: ✭ 17,989 (+119826.67%)
Mutual labels:  hapi
hapi-imagemin-proxy
Hapi proxy for serving optimized images
Stars: ✭ 30 (+100%)
Mutual labels:  hapi
hapi-dev-errors
A hapi plugin to return better error details and skip the look at command line to catch the issue.
Stars: ✭ 58 (+286.67%)
Mutual labels:  hapi
Takeoff
A rapid development environment using docker for convenience.
Stars: ✭ 271 (+1706.67%)
Mutual labels:  hapi
paydash
Worker payments dashboard for MGNREGA
Stars: ✭ 44 (+193.33%)
Mutual labels:  hapi
Frame
💡 A user system API starter
Stars: ✭ 741 (+4840%)
Mutual labels:  hapi
exiting
Safely shutdown http://hapijs.com servers.
Stars: ✭ 23 (+53.33%)
Mutual labels:  hapi
shariff-backend-node
Node.js (hapi) backend for Shariff. Shariff enables website users to share their favorite content without compromising their privacy.
Stars: ✭ 17 (+13.33%)
Mutual labels:  hapi
Typescript Seed
Typescript Seed Project (Angular, Hapi, Cookie Auth, TypeORM, Postgres)
Stars: ✭ 12 (-20%)
Mutual labels:  hapi
Plugo
Dynamically expose modules to hapi plugins
Stars: ✭ 5 (-66.67%)
Mutual labels:  hapi
Grant
OAuth Proxy
Stars: ✭ 3,509 (+23293.33%)
Mutual labels:  hapi

OpenLok 🚋

alt text


A small project utilizing the Deutsche Bahn API

Wikipedia entry on DB (German Railway Corporation)

Deutsche Bahn opened some of their APIs for public consumption and this project should serve as an API-playground.

For more detailed info on the API itself read this article (in German)

The Homepage of the API is located here.

The API Descriptions can be found here (pdf, in German)

Structure

The Frontend is built with React.js and supports hot-reloading via WebPack. More info regarding hot-reloading of React components can be found here.

The Backend is based on Hapi.js which is my favorite node web server. The Frontend uses this backend to avoid problems with CORS. Therefore, the App executes no direct calls against the real DB-API but instead against Hapi.js that is configured to accept CORS.

There's a special class called BahnService* that's being used by both client and server to make API calls. BahnService runs either in local or remote mode. The Client runs on local to dispatch the API calls to the local Hapi.js instance which in turn uses the remote instance of BahnService to access the real DB API.

This may sound unnecessarily complex but the strategy is rather simple: a Client only wants to have a direct access to 'some API' without fiddling around with CORS etc. Therefore, Hapi.js takes care of providing us an easy to use, RESTful API that returns plain JSONs.

The advantage is obvious: you can mock and test your API without dealing with CORS or any other implementation details.

For example, the client could send a GET request querying the location 'Cologne':

http://localhost:3000/locations/Cologne

which on Hapi.js side would then be translated into a server-side GET request:

https://open-api.bahn.de/bin/rest.exe/location.name?authKey=YOUR_AUTH_KEY&lang=de&input=Cologne&format=json

Finally, you'd receive a plain JSON-structure containing the location data. The JSON-structure remains unchanged as Hapi.js only forwards the responses back to the client.

Client
Local API Server
Current Status

The Client is rather primitive as it only contains a very bare-bones React component and a few Bootstrap elements (button, input, panel etc.).

The Calendar Widgets are from React Widgets Project.

The Server implements only the Location.name API but soon they'll be more of them.

Building & Running

Prerequisites

npm install

Client

npm run client

Client is located at http://localhost:8080

Local API

npm run api

API-Server listens on http://localhost:3000

Testing

Mocha & Chai with ES6.

More info on testing ES6 code with Mocha can be found here.

npm test
FAQ
  • What do 'BahnService' and 'OpenLok' mean?

Bahn is a German word and heavily context-dependent. In this case it means 'Train'.

However, you can find it in a number of different locations, for example:

  • Autobahn = motorway
  • Flugbahn = trajectory
  • Straßenbahn = tram (Br.), streetcar (Am.)

and many others.

Lok is an abbreviation of 'Lokomotive' which means locomotive.

There's also a similar English abbreviation loco.

Building compound words is very easy in German. 💬

You can learn it here 😄

  • Where to get the API-Key?

To access the DB-API you'll need an API-Key. To get one use this email: dbopendata @ deutschebahn.com

Then put it into authKey in BahnService.js

License

MIT

Deutsche Bahn® is a registered trademark of Deutsche Bahn AG in Germany and/or other countries.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].