hafas-rest-api
Advanced tools
Comparing version 3.3.0 to 3.3.1
{ | ||
"name": "hafas-rest-api", | ||
"description": "Expose a HAFAS client via an HTTP REST API.", | ||
"version": "3.3.0", | ||
"version": "3.3.1", | ||
"main": "index.js", | ||
@@ -38,2 +38,3 @@ "files": [ | ||
"express-pino-logger": "^4.0.0", | ||
"github-slugger": "^1.3.0", | ||
"hsts": "^2.1.0", | ||
@@ -40,0 +41,0 @@ "http-link-header": "^1.0.2", |
'use strict' | ||
const {inspect} = require('util') | ||
const Slugger = require('github-slugger') | ||
@@ -42,21 +43,2 @@ const generateRouteDoc = (path, route) => { | ||
// todo: filter based on `routes` | ||
const listOfRoutes = `\ | ||
## Routes | ||
*Note:* These routes only wrap [\`hafas-client@5\` methods](https://github.com/public-transport/hafas-client/blob/5/docs/readme.md), check their docs for more details. | ||
- [\`GET /locations\`](#get-locations) | ||
- [\`GET /stops/nearby\`](#get-stopsnearby) | ||
- [\`GET /stops/reachable-from\`](#get-stopsreachable-from) | ||
- [\`GET /stops/:id\`](#get-stopsid) | ||
- [\`GET /stops/:id/departures\`](#get-stopsiddepartures) | ||
- [\`GET /stops/:id/arrivals\`](#get-stopsidarrivals) | ||
- [\`GET /journeys\`](#get-journeys) | ||
- [\`GET /journeys/:ref\`](#get-journeysref) | ||
- [\`GET /trips/:id\`](#get-tripsid) | ||
- [\`GET /radar\`](#get-radar) | ||
- [date/time parameters](#datetime-parameters) | ||
` | ||
const tail = `\ | ||
@@ -72,7 +54,23 @@ ## Date/Time Parameters | ||
const slugger = new Slugger() | ||
const generateApiDocs = (routes) => { | ||
const r = Object.create(null) | ||
let listOfRoutes = `\ | ||
## Routes | ||
*Note:* These routes only wrap [\`hafas-client@5\` methods](https://github.com/public-transport/hafas-client/blob/5/docs/readme.md), check their docs for more details. | ||
` | ||
for (const [path, route] of Object.entries(routes)) { | ||
r[path] = generateRouteDoc(path, route) | ||
const spec = `GET ${path}` | ||
listOfRoutes += ` | ||
- [\`${spec}\`](#${slugger.slug(spec)})` | ||
} | ||
listOfRoutes += ` | ||
- [date/time parameters](#datetime-parameters) | ||
` | ||
return { | ||
@@ -79,0 +77,0 @@ listOfRoutes, |
42282
16
1440
+ Addedgithub-slugger@^1.3.0
+ Addedgithub-slugger@1.5.0(transitive)