From 6c2d2c90f2569c1ed1f0a9a23822aaca0deaf041 Mon Sep 17 00:00:00 2001 From: Jannis R Date: Mon, 4 Feb 2019 16:09:30 +0100 Subject: [PATCH] serve docs via HTTP :memo: --- docs/index.md | 2 +- index.js | 9 +++++++-- package.json | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/docs/index.md b/docs/index.md index bb1c8bb..be2ff67 100644 --- a/docs/index.md +++ b/docs/index.md @@ -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). -*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 diff --git a/index.js b/index.js index 4e8f4a1..0983c9b 100644 --- a/index.js +++ b/index.js @@ -1,5 +1,7 @@ 'use strict' +const {readFileSync} = require('fs') +const {join} = require('path') const createHafas = require('db-hafas') const createApi = require('hafas-rest-api') const createHealthCheck = require('hafas-client-health-check') @@ -9,6 +11,8 @@ const stations = require('./lib/stations') const allStations = require('./lib/all-stations') const station = require('./lib/station') +const docsAsMarkdown = readFileSync(join(__dirname, 'docs', 'index.md'), {encoding: 'utf8'}) + const hafas = createHafas(pkg.name) const berlinHbf = '8011160' @@ -21,10 +25,11 @@ const config = { description: pkg.description, homepage: pkg.homepage, version: pkg.version, - docsLink: 'https://github.com/derhuerst/db-rest/blob/2/docs/index.md', + docsLink: '/docs', logging: true, healthCheck, - aboutPage: true + aboutPage: true, + docsAsMarkdown } const attachAdditionalHandlers = (api) => { diff --git a/package.json b/package.json index fe20f83..f2dcfaa 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ "db-stations": "^2.4.0", "db-stations-autocomplete": "^2.1.0", "hafas-client-health-check": "^1.0.1", - "hafas-rest-api": "^1.1.0", + "hafas-rest-api": "^1.2.1", "ndjson": "^1.5.0" }, "scripts": {