serve docs via HTTP 📝
This commit is contained in:
parent
ef058bdeba
commit
6c2d2c90f2
3 changed files with 9 additions and 4 deletions
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
**The public endpoint is [`2.db.transport.rest`](`https://2.db.transport.rest`).** This API returns data in the [*Friendly Public Transport Format* `1.2.0`](https://github.com/public-transport/friendly-public-transport-format/blob/1.2.0/spec/readme.md).
|
**The public endpoint is [`2.db.transport.rest`](`https://2.db.transport.rest`).** This API returns data in the [*Friendly Public Transport Format* `1.2.0`](https://github.com/public-transport/friendly-public-transport-format/blob/1.2.0/spec/readme.md).
|
||||||
|
|
||||||
*Note:* In order to improve this API, I would to know which software projects use it. Please send an **`X-Identifier` header (e.g. `my-awesome-tool`) to let me know who you are**. I you don't provide it, a hash of the client IP will be logged.
|
*Note:* In order to improve this API, I would like to know which software projects use it. Please send an **`X-Identifier` header (e.g. `my-awesome-tool`) to let me know who you are**. I you don't provide it, a hash of the client IP will be logged.
|
||||||
|
|
||||||
## all routes
|
## all routes
|
||||||
|
|
||||||
|
|
9
index.js
9
index.js
|
@ -1,5 +1,7 @@
|
||||||
'use strict'
|
'use strict'
|
||||||
|
|
||||||
|
const {readFileSync} = require('fs')
|
||||||
|
const {join} = require('path')
|
||||||
const createHafas = require('db-hafas')
|
const createHafas = require('db-hafas')
|
||||||
const createApi = require('hafas-rest-api')
|
const createApi = require('hafas-rest-api')
|
||||||
const createHealthCheck = require('hafas-client-health-check')
|
const createHealthCheck = require('hafas-client-health-check')
|
||||||
|
@ -9,6 +11,8 @@ const stations = require('./lib/stations')
|
||||||
const allStations = require('./lib/all-stations')
|
const allStations = require('./lib/all-stations')
|
||||||
const station = require('./lib/station')
|
const station = require('./lib/station')
|
||||||
|
|
||||||
|
const docsAsMarkdown = readFileSync(join(__dirname, 'docs', 'index.md'), {encoding: 'utf8'})
|
||||||
|
|
||||||
const hafas = createHafas(pkg.name)
|
const hafas = createHafas(pkg.name)
|
||||||
|
|
||||||
const berlinHbf = '8011160'
|
const berlinHbf = '8011160'
|
||||||
|
@ -21,10 +25,11 @@ const config = {
|
||||||
description: pkg.description,
|
description: pkg.description,
|
||||||
homepage: pkg.homepage,
|
homepage: pkg.homepage,
|
||||||
version: pkg.version,
|
version: pkg.version,
|
||||||
docsLink: 'https://github.com/derhuerst/db-rest/blob/2/docs/index.md',
|
docsLink: '/docs',
|
||||||
logging: true,
|
logging: true,
|
||||||
healthCheck,
|
healthCheck,
|
||||||
aboutPage: true
|
aboutPage: true,
|
||||||
|
docsAsMarkdown
|
||||||
}
|
}
|
||||||
|
|
||||||
const attachAdditionalHandlers = (api) => {
|
const attachAdditionalHandlers = (api) => {
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
"db-stations": "^2.4.0",
|
"db-stations": "^2.4.0",
|
||||||
"db-stations-autocomplete": "^2.1.0",
|
"db-stations-autocomplete": "^2.1.0",
|
||||||
"hafas-client-health-check": "^1.0.1",
|
"hafas-client-health-check": "^1.0.1",
|
||||||
"hafas-rest-api": "^1.1.0",
|
"hafas-rest-api": "^1.2.1",
|
||||||
"ndjson": "^1.5.0"
|
"ndjson": "^1.5.0"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|
Loading…
Reference in a new issue