diff --git a/.gitignore b/.gitignore index 33a78ae..bf8d34f 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,6 @@ npm-debug.log /package-lock.json /dump.rdb + +/docs/*.html +/docs/syntax.css diff --git a/api.js b/api.js index fba85df..14cd5bd 100644 --- a/api.js +++ b/api.js @@ -6,11 +6,14 @@ const createHealthCheck = require('hafas-client-health-check') const {createClient: createRedis} = require('redis') const withCache = require('cached-hafas-client') const redisStore = require('cached-hafas-client/stores/redis') - +const {join: pathJoin} = require('path') +const serveStatic = require('serve-static') const pkg = require('./package.json') const stations = require('./routes/stations') const station = require('./routes/station') +const docsRoot = pathJoin(__dirname, 'docs') + const berlinHbf = '8011160' let hafas = createHafas(pkg.name) @@ -54,13 +57,18 @@ const config = { version: pkg.version, docsLink: 'https://github.com/derhuerst/db-rest/blob/5/docs/readme.md', logging: true, - aboutPage: true, + aboutPage: false, etags: 'strong', + csp: `default-src 'none' style-src 'self' 'unsafe-inline'`, healthCheck, modifyRoutes, } -const api = createApi(hafas, config, () => {}) +const api = createApi(hafas, config, (api) => { + api.use('/', serveStatic(docsRoot, { + extensions: ['html', 'htm'], + })) +}) module.exports = { config, diff --git a/package.json b/package.json index 9ae1e6c..9546aa9 100644 --- a/package.json +++ b/package.json @@ -31,13 +31,15 @@ "hafas-client-health-check": "^2.1.1", "hafas-rest-api": "^3.3.0", "redis": "^3.0.2", - "serve-buffer": "^2.0.0" + "serve-buffer": "^2.0.0", + "serve-static": "^1.14.1" }, "devDependencies": { + "@derhuerst/technical-docs-cli": "^1.1.0", "pino-pretty": "^4.0.0" }, "scripts": { - "docs": "node api-docs.js >docs/api.md", + "docs": "node api-docs.js >docs/api.md && build-technical-doc --syntax-stylesheet-url /syntax.css docs/index.html && build-technical-doc --syntax-stylesheet-url /syntax.css docs/getting-started.html && build-technical-doc --syntax-stylesheet-url /syntax.css docs/why.html && build-technical-doc --syntax-stylesheet-url /syntax.css docs/api.html && build-technical-doc --syntax-stylesheet github >docs/syntax.css", "build": "npm run docs", "start": "node index.js" }