render & serve API docs
This commit is contained in:
parent
2eb74c000b
commit
013a56ba26
3 changed files with 18 additions and 5 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -7,3 +7,6 @@ npm-debug.log
|
|||
|
||||
/package-lock.json
|
||||
/dump.rdb
|
||||
|
||||
/docs/*.html
|
||||
/docs/syntax.css
|
||||
|
|
14
api.js
14
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,
|
||||
|
|
|
@ -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/readme.md >docs/index.html && build-technical-doc --syntax-stylesheet-url /syntax.css <docs/getting-started.md >docs/getting-started.html && build-technical-doc --syntax-stylesheet-url /syntax.css <docs/why.md >docs/why.html && build-technical-doc --syntax-stylesheet-url /syntax.css <docs/api.md >docs/api.html && build-technical-doc --syntax-stylesheet github >docs/syntax.css",
|
||||
"build": "npm run docs",
|
||||
"start": "node index.js"
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue