prepare for v6 📝💚

This commit is contained in:
Jannis R 2022-12-19 13:18:25 +01:00
parent 9e6cc8ed6b
commit 4b333ea9be
No known key found for this signature in database
GPG key ID: 0FE83946296A88A5
9 changed files with 44 additions and 44 deletions

View file

@ -2,7 +2,7 @@ name: build & publish Docker image
on:
push:
branches:
- 5
- 6
jobs:
lint-test:
name: lint & test
@ -35,7 +35,7 @@ jobs:
with:
push: true
tags: |
derhuerst/db-rest:5
derhuerst/db-rest:6
derhuerst/db-rest:latest
# this is for the public-transport/infrastructure cluster
@ -55,4 +55,4 @@ jobs:
uses: docker/build-push-action@v2
with:
push: true
tags: ghcr.io/${{github.repository}}:v5_${{steps.hash.outputs.hash}}_${{steps.datetime.outputs.datetime}}
tags: ghcr.io/${{github.repository}}:v6_${{steps.hash.outputs.hash}}_${{steps.datetime.outputs.datetime}}

View file

@ -16,9 +16,9 @@ FROM node:alpine
LABEL org.opencontainers.image.title="db-rest"
LABEL org.opencontainers.image.description="A clean REST API wrapping around the Deutsche Bahn API."
LABEL org.opencontainers.image.authors="Jannis R <mail@jannisr.de>"
LABEL org.opencontainers.image.documentation="https://github.com/derhuerst/db-rest/tree/5"
LABEL org.opencontainers.image.documentation="https://github.com/derhuerst/db-rest/tree/6"
LABEL org.opencontainers.image.source="https://github.com/derhuerst/db-rest"
LABEL org.opencontainers.image.revision="5"
LABEL org.opencontainers.image.revision="6"
LABEL org.opencontainers.image.licenses="ISC"
WORKDIR /app
@ -32,7 +32,7 @@ COPY --from=builder /app/docs ./docs
EXPOSE 3000
ENV HOSTNAME v5.db.transport.rest
ENV HOSTNAME v6.db.transport.rest
ENV PORT 3000
CMD ["node", "index.js"]

View file

@ -4,13 +4,13 @@ const generateApiDocs = require('hafas-rest-api/tools/generate-docs')
const {api} = require('./api')
const HEAD = `\
# \`v5.db.transport.rest\` API documentation
# \`v6.db.transport.rest\` API documentation
[\`v5.db.transport.rest\`](https://v5.db.transport.rest/) is a [REST API](https://restfulapi.net). Data is being returned as [JSON](https://www.json.org/).
[\`v6.db.transport.rest\`](https://v6.db.transport.rest/) is a [REST API](https://restfulapi.net). Data is being returned as [JSON](https://www.json.org/).
You can just use the API without authentication. There's a [rate limit](https://apisyouwonthate.com/blog/what-is-api-rate-limiting-all-about) of 100 request/minute (burst 200 requests/minute) set up.
[OpenAPI playground](https://petstore.swagger.io/?url=https%3A%2F%2Fv5.db.transport.rest%2F.well-known%2Fservice-desc%0A)
[OpenAPI playground](https://petstore.swagger.io/?url=https%3A%2F%2Fv6.db.transport.rest%2F.well-known%2Fservice-desc%0A)
*Note:* The examples snippets in this documentation uses the \`url-encode\` CLI tool of the [\`url-decode-encode-cli\` package](https://www.npmjs.com/package/url-decode-encode-cli) for [URL-encoding](https://de.wikipedia.org/wiki/URL-Encoding).
`
@ -92,7 +92,7 @@ const examples = {
### Example
\`\`\`shell
curl 'https://v5.db.transport.rest/locations?query=halle&results=1' -s | jq
curl 'https://v6.db.transport.rest/locations?query=halle&results=1' -s | jq
\`\`\`
\`\`\`js
@ -120,7 +120,7 @@ curl 'https://v5.db.transport.rest/locations?query=halle&results=1' -s | jq
### Example
\`\`\`shell
curl 'https://v5.db.transport.rest/stops/nearby?latitude=53.5711&longitude=10.0015' -s | jq
curl 'https://v6.db.transport.rest/stops/nearby?latitude=53.5711&longitude=10.0015' -s | jq
\`\`\`
\`\`\`js
@ -160,7 +160,7 @@ curl 'https://v5.db.transport.rest/stops/nearby?latitude=53.5711&longitude=10.00
### Example
\`\`\`shell
curl 'https://v5.db.transport.rest/stops/reachable-from?latitude=53.553766&longitude=9.977514&address=Hamburg,+Holstenwall+9' -s | jq
curl 'https://v6.db.transport.rest/stops/reachable-from?latitude=53.553766&longitude=9.977514&address=Hamburg,+Holstenwall+9' -s | jq
\`\`\`
\`\`\`js
@ -200,7 +200,7 @@ curl 'https://v5.db.transport.rest/stops/reachable-from?latitude=53.553766&longi
### Example
\`\`\`shell
curl 'https://v5.db.transport.rest/stops/8010159' -s | jq
curl 'https://v6.db.transport.rest/stops/8010159' -s | jq
\`\`\`
\`\`\`js
@ -229,7 +229,7 @@ curl 'https://v5.db.transport.rest/stops/8010159' -s | jq
\`\`\`shell
# autocomplete using db-stations-autocomplete
curl 'https://v5.db.transport.rest/stations?query=dammt' -s | jq
curl 'https://v6.db.transport.rest/stations?query=dammt' -s | jq
\`\`\`
\`\`\`js
@ -265,7 +265,7 @@ curl 'https://v5.db.transport.rest/stations?query=dammt' -s | jq
\`\`\`shell
# filter db-stations by \`hasParking\` property
curl 'https://v5.db.transport.rest/stations?hasParking=true' -s | jq
curl 'https://v6.db.transport.rest/stations?hasParking=true' -s | jq
\`\`\`
\`\`\`js
@ -287,7 +287,7 @@ curl 'https://v5.db.transport.rest/stations?hasParking=true' -s | jq
\`\`\`shell
# filter db-stations by \`hasDBLounge\` property, get newline-delimited JSON
curl 'https://v5.db.transport.rest/stations?hasDBLounge=true' -H 'accept: application/x-ndjson' -s | jq
curl 'https://v6.db.transport.rest/stations?hasDBLounge=true' -H 'accept: application/x-ndjson' -s | jq
\`\`\`
`,
'/stations/:id': `\
@ -295,9 +295,9 @@ curl 'https://v5.db.transport.rest/stations?hasDBLounge=true' -H 'accept: applic
\`\`\`shell
# lookup Halle (Saale) Hbf
curl 'https://v5.db.transport.rest/stations/8010159' -s | jq
curl 'https://v5.db.transport.rest/stations/LH' -s | jq # RIL100/DS100
curl 'https://v5.db.transport.rest/stations/LHG' -s | jq # RIL100/DS100
curl 'https://v6.db.transport.rest/stations/8010159' -s | jq
curl 'https://v6.db.transport.rest/stations/LH' -s | jq # RIL100/DS100
curl 'https://v6.db.transport.rest/stations/LHG' -s | jq # RIL100/DS100
\`\`\`
\`\`\`js
@ -328,7 +328,7 @@ curl 'https://v5.db.transport.rest/stations/LHG' -s | jq # RIL100/DS100
\`\`\`shell
# at Halle (Saale) Hbf, in direction Berlin Südkreuz
curl 'https://v5.db.transport.rest/stops/8010159/departures?direction=8011113&duration=120' -s | jq
curl 'https://v6.db.transport.rest/stops/8010159/departures?direction=8011113&duration=120' -s | jq
\`\`\`
\`\`\`js
@ -370,7 +370,7 @@ curl 'https://v5.db.transport.rest/stops/8010159/departures?direction=8011113&du
\`\`\`shell
# at Halle (Saale) Hbf, 10 minutes
curl 'https://v5.db.transport.rest/stops/8010159/arrivals?duration=10' -s | jq
curl 'https://v6.db.transport.rest/stops/8010159/arrivals?duration=10' -s | jq
\`\`\`
`,
'/journeys': `\
@ -378,9 +378,9 @@ curl 'https://v5.db.transport.rest/stops/8010159/arrivals?duration=10' -s | jq
\`\`\`shell
# stop/station to POI
curl 'https://v5.db.transport.rest/journeys?from=8010159&to.id=991561765&to.latitude=51.483641&to.longitude=11.980841' -s | jq
curl 'https://v6.db.transport.rest/journeys?from=8010159&to.id=991561765&to.latitude=51.483641&to.longitude=11.980841' -s | jq
# without buses, with ticket info
curl 'https://v5.db.transport.rest/journeys?from=…&to=…&bus=false&tickets=true' -s | jq
curl 'https://v6.db.transport.rest/journeys?from=…&to=…&bus=false&tickets=true' -s | jq
\`\`\`
`,
'/journeys/:ref': `\
@ -388,11 +388,11 @@ curl 'https://v5.db.transport.rest/journeys?from=…&to=…&bus=false&tickets=tr
\`\`\`shell
# get the refreshToken of a journey
journey=$(curl 'https://v5.db.transport.rest/journeys?from=…&to=…&results=1' -s | jq '.journeys[0]')
journey=$(curl 'https://v6.db.transport.rest/journeys?from=…&to=…&results=1' -s | jq '.journeys[0]')
refresh_token=$(echo $journey | jq -r '.refreshToken')
# refresh the journey
curl "https://v5.db.transport.rest/journeys/$(echo $refresh_token | url-encode)" -s | jq
curl "https://v6.db.transport.rest/journeys/$(echo $refresh_token | url-encode)" -s | jq
\`\`\`
`,
'/trips/:id': `\
@ -400,12 +400,12 @@ curl "https://v5.db.transport.rest/journeys/$(echo $refresh_token | url-encode)"
\`\`\`shell
# get the trip ID of a journey leg
journey=$(curl 'https://v5.db.transport.rest/journeys?from=…&to=…&results=1' -s | jq '.journeys[0]')
journey=$(curl 'https://v6.db.transport.rest/journeys?from=…&to=…&results=1' -s | jq '.journeys[0]')
journey_leg=$(echo $journey | jq -r '.legs[0]')
trip_id=$(echo $journey_leg | jq -r '.tripId')
# fetch the trip
curl "https://v5.db.transport.rest/trips/$(echo $trip_id | url-encode)" -s | jq
curl "https://v6.db.transport.rest/trips/$(echo $trip_id | url-encode)" -s | jq
\`\`\`
`,
'/radar': `\
@ -413,7 +413,7 @@ curl "https://v5.db.transport.rest/trips/$(echo $trip_id | url-encode)" -s | jq
\`\`\`shell
bbox='north=53.555&west=9.989&south=53.55&east=10.001'
curl "https://v5.db.transport.rest/radar?$bbox&results=10" -s | jq
curl "https://v6.db.transport.rest/radar?$bbox&results=10" -s | jq
\`\`\`
`,
}

2
api.js
View file

@ -70,7 +70,7 @@ const config = {
description: pkg.description,
homepage: pkg.homepage,
version: pkg.version,
docsLink: 'https://github.com/derhuerst/db-rest/blob/5/docs/readme.md',
docsLink: 'https://github.com/derhuerst/db-rest/blob/6/docs/readme.md',
openapiSpec: true,
logging: true,
aboutPage: false,

View file

@ -42,7 +42,7 @@
<rect class="box" x="0" y="0" width="100" height="41" />
<text class="monospace-text" x="26.2" y="13">db-rest</text>
<text class="normal-text small-text" x="4" y="26">deployed at</text>
<text class="monospace-text small-text" x="4" y="36">v5.db.transport.rest</text>
<text class="monospace-text small-text" x="4" y="36">v6.db.transport.rest</text>
</g>
<g transform="translate(269, 14)">
<path class="arrow" d="M0,14 L50,14" />

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 2.6 KiB

View file

@ -1,4 +1,4 @@
# Getting Started with `v5.db.transport.rest`
# Getting Started with `v6.db.transport.rest`
Let's walk through the **requests that are necessary to implement a typical basic transit app**.
@ -11,7 +11,7 @@ The following code snippets use [`curl`](https://curl.haxx.se) (a versatile comm
The `/locations?query=…` route allows you to query stops, points of interest (POIs) & addresses. We're only interested in stops though, so we filter using `poi=false&addresses=false`:
```shell
curl 'https://v5.db.transport.rest/locations?poi=false&addresses=false&query=südkreuz' -s | jq
curl 'https://v6.db.transport.rest/locations?poi=false&addresses=false&query=südkreuz' -s | jq
```
```js
@ -78,7 +78,7 @@ curl 'https://v5.db.transport.rest/locations?poi=false&addresses=false&query=sü
Let's fetch 5 of the next departures at *Berlin Südkreuz* (which has the ID `8011113`):
```shell
curl 'https://v5.db.transport.rest/stops/8011113/departures?results=5' -s | jq
curl 'https://v6.db.transport.rest/stops/8011113/departures?results=5' -s | jq
```
```js
@ -160,7 +160,7 @@ We call a connection from A to B at a specific date & time, made up of secti
Let's fetch 2 journeys from `8011113` (*Berlin Südkreuz*) to `8010159` (*Halle (Saale)Hbf*), departing tomorrow at 2pm (at the time of writing this).
```shell
curl 'https://v5.db.transport.rest/journeys?from=8011113&to=8010159&departure=tomorrow+2pm&results=2' -s | jq
curl 'https://v6.db.transport.rest/journeys?from=8011113&to=8010159&departure=tomorrow+2pm&results=2' -s | jq
```
```js
@ -316,4 +316,4 @@ Note that `departure` includes the `departureDelay`, and `arrival` includes the
### 4. more features
These are the basics. Check the full [API docs](api.md) for all features or use the [OpenAPI playground](https://petstore.swagger.io/?url=https%3A%2F%2Fv5.db.transport.rest%2F.well-known%2Fservice-desc%0A) or explore the API!
These are the basics. Check the full [API docs](api.md) for all features or use the [OpenAPI playground](https://petstore.swagger.io/?url=https%3A%2F%2Fv6.db.transport.rest%2F.well-known%2Fservice-desc%0A) or explore the API!

View file

@ -1,6 +1,6 @@
# `v5.db.transport.rest` documentation
# `v6.db.transport.rest` documentation
[`v5.db.transport.rest`](https://v5.db.transport.rest/) is a [REST API](https://restfulapi.net) for the public transportation system in Germany.
[`v6.db.transport.rest`](https://v6.db.transport.rest/) is a [REST API](https://restfulapi.net) for the public transportation system in Germany.
[![API status](https://badgen.net/uptime-robot/status/m784879516-8a977fa91b975fc3884a9857)](https://stats.uptimerobot.com/57wNLs39M/784879516)
@ -8,7 +8,7 @@ Because it wraps [an API](https://github.com/public-transport/hafas-client/blob/
- [Getting Started](getting-started.md)
- [API documentation](api.md)
- [OpenAPI playground](https://petstore.swagger.io/?url=https%3A%2F%2Fv5.db.transport.rest%2F.well-known%2Fservice-desc%0A)
- [OpenAPI playground](https://petstore.swagger.io/?url=https%3A%2F%2Fv6.db.transport.rest%2F.well-known%2Fservice-desc%0A)
## Why use this API?

View file

@ -5,7 +5,7 @@
"version": "5.0.2",
"main": "index.js",
"author": "Jannis R <mail@jannisr.de>",
"homepage": "https://github.com/derhuerst/db-rest/tree/5",
"homepage": "https://github.com/derhuerst/db-rest/tree/6",
"repository": "derhuerst/db-rest",
"bugs": "https://github.com/derhuerst/db-rest/issues",
"license": "ISC",

View file

@ -1,12 +1,12 @@
# db-rest
**A clean REST API wrapping around the [Deutsche Bahn HAFAS API](https://github.com/public-transport/db-hafas#db-hafas).** It is deployed at [`v5.db.transport.rest`](https://v5.db.transport.rest/).
**A clean REST API wrapping around the [Deutsche Bahn HAFAS API](https://github.com/public-transport/db-hafas#db-hafas).** It is deployed at [`v6.db.transport.rest`](https://v6.db.transport.rest/).
[**API Documentation**](docs/readme.md)
![db-rest architecture diagram](architecture.svg)
[![API status](https://badgen.net/uptime-robot/status/m784879516-8a977fa91b975fc3884a9857)](https://stats.uptimerobot.com/57wNLs39M/784879516)
[![API status](https://badgen.net/uptime-robot/status/m793274556-25c5e9bbab0297d91cda7134)](https://stats.uptimerobot.com/57wNLs39M/793274556)
[![dependency status](https://img.shields.io/david/derhuerst/db-rest.svg)](https://david-dm.org/derhuerst/db-rest)
![ISC-licensed](https://img.shields.io/github/license/derhuerst/db-rest.svg)
[![support me via GitHub Sponsors](https://img.shields.io/badge/support%20me-donate-fa7664.svg)](https://github.com/sponsors/derhuerst)
@ -19,10 +19,10 @@
### via Docker
A Docker image [is available as `derhuerst/db-rest:5`](https://hub.docker.com/r/derhuerst/db-rest:5).
A Docker image [is available as `derhuerst/db-rest:6`](https://hub.docker.com/r/derhuerst/db-rest:6).
```shell
docker run -d -p 3000:3000 derhuerst/db-rest:5
docker run -d -p 3000:3000 derhuerst/db-rest:6
```
*Note:* The Docker image does not contain the Redis server.
@ -32,7 +32,7 @@ docker run -d -p 3000:3000 derhuerst/db-rest:5
```shell
git clone https://github.com/derhuerst/db-rest.git
cd db-rest
git checkout 5
git checkout 6
npm install --production
redis-server &