Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

oebb.transport.rest #28

Open
nocontent06 opened this issue Sep 18, 2024 · 13 comments
Open

oebb.transport.rest #28

nocontent06 opened this issue Sep 18, 2024 · 13 comments
Labels
enhancement New feature or request ops operations

Comments

@nocontent06
Copy link

How about implementing the OEBB to transport.rest?

@derhuerst
Copy link
Member

Hey,
you're welcome to host an instance! I can then direct oebb.transport.rest to you.

@nocontent06
Copy link
Author

I'd love to do so. But I didn't manage to authorise at the OEBB's mgate.exe... do you know how to do that?

@derhuerst
Copy link
Member

[…] I didn't manage to authorise at the OEBB's mgate.exe... do you know how to do that?

hafas-client's ÖBB profile shows how to do it.

It will be the most straightforward for you to pass it into hafas-rest-api@5, this is how v6.bvg.transport.rest (a.k.a. bvg-rest@6), v6.db.transport.rest (a.k.a. db-rest@6) & v6.vbb.transport.rest (a.k.a. vbb-rest@6) do it too.

@nocontent06
Copy link
Author

Ah i see what you mean...

I created a repo running on oebb.transport.rest

@derhuerst
Copy link
Member

I recommend you to use hafas-rest-api@5 to build the API, both to save time and to get an API that behaves like v6.{bvg,db,vbb}.transport.rest.

@nocontent06
Copy link
Author

Okay sure...

The API is running on https://oebb.macistry.com temporarily if you wanna try it out.

e.g. https://oebb.macistry.com/journeys?from=8100085&to=8100147

@derhuerst
Copy link
Member

The API is running on https://oebb.macistry.com temporarily if you wanna try it out.

Do you want me to configure a subdomain v6.oebb.transport.rest?

@nocontent06
Copy link
Author

Oh that'd be perfect!

I'll update the code that it uses hafas-rest-api soon

@derhuerst
Copy link
Member

https://github.com/nocontent06/oebb.transport.rest/blob/e9e94df0f61c04b5cde51beca29af4ef6f648343/src/createHafasClient.js#L5

Please adapt this so something meaningful! From the hafas-client readme:

Because the operators of the HAFAS endpoint should be able to contact you about excessive traffic, please pass a link to your project/program (or an email address) into createClient():

@derhuerst
Copy link
Member

v6.oebb.transport.rest is now a CNAME for oebb.macistry.com.

@nocontent06
Copy link
Author

Perfect!

I've updated my repo so far, that everything is ready for transition.

I just have to write a documentation.

The index page is currently oebb.macistry.com and the API chills on oebb.macistry.com/api

So basically... what do we need more?

Test: https://oebb.macistry.com/api/journeys?from=8100085&to=8100147

@nocontent06
Copy link
Author

image

It's running :)

@derhuerst
Copy link
Member

I just have to write a documentation.

I highly recommend using hafas-rest-api@5. You will get a generated API documentation as well as an OpenAPI spec out-of-the-box. Both of them are generated from the parameters metadata in each route (e.g. here for /stops/:id/departures).

You will also get built-in:

  • ETag-based caching & client-side caching headers
  • compression (Accept-Encoding) support
  • CORS, if you want it
  • HSTS header
  • Link headers that tell clients how to fetch earlier/later results
  • Server Timing API, so that the duration of the underlying HAFAS request shows up in the browser dev tools
  • a health check route

The index page is currently oebb.macistry.com and the API chills on oebb.macistry.com/api

I recommend you to prefix/namespace your entire API with the version, e.g. $version.oebb.transport.rest or oebb.transport.rest/$version. Another option is using content negotiation for that, but it's easier to mess up.

Over time, I've had to make breaking changes with my *.transport.rest APIs several times. (You will have to make such breaking changes too, given that you use hafas-client, which will eventually change its response format.)

Having the v6 prefix with my *.transport.rest APIs really helps with deprecating the old one and deploying the new one next to it.

So basically... what do we need more?

You should configure your server to serve requests under v6.oebb.transport.rest.

@derhuerst derhuerst added the enhancement New feature or request label Oct 1, 2024
@derhuerst derhuerst added the ops operations label Nov 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request ops operations
Development

No branches or pull requests

2 participants