adapt to latest hafas-rest-api
This commit is contained in:
parent
83a7482767
commit
de11857a7e
1 changed files with 7 additions and 11 deletions
18
index.js
18
index.js
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
const hafas = require('db-hafas')
|
const hafas = require('db-hafas')
|
||||||
const createApi = require('hafas-rest-api')
|
const createApi = require('hafas-rest-api')
|
||||||
const createLogging = require('hafas-rest-api/logging')
|
|
||||||
const hsts = require('hsts')
|
const hsts = require('hsts')
|
||||||
|
|
||||||
const pkg = require('./package.json')
|
const pkg = require('./package.json')
|
||||||
|
@ -10,20 +9,17 @@ const stations = require('./lib/stations')
|
||||||
const allStations = require('./lib/all-stations')
|
const allStations = require('./lib/all-stations')
|
||||||
|
|
||||||
const config = {
|
const config = {
|
||||||
hostname: process.env.HOSTNAME || '1.db.transport.rest',
|
hostname: process.env.HOSTNAME || '2.db.transport.rest',
|
||||||
port: process.env.PORT || 3000,
|
port: process.env.PORT || 3000,
|
||||||
name: pkg.name,
|
name: pkg.name,
|
||||||
homepage: pkg.homepage
|
homepage: pkg.homepage,
|
||||||
|
logging: true
|
||||||
}
|
}
|
||||||
|
|
||||||
const api = createApi(hafas, config)
|
const api = createApi(hafas, config, (api) => {
|
||||||
|
api.get('/stations', stations)
|
||||||
api.use(createLogging())
|
api.get('/stations/all', allStations)
|
||||||
|
})
|
||||||
api.get('/stations', stations)
|
|
||||||
api.get('/stations/all', allStations)
|
|
||||||
|
|
||||||
module.exports = api
|
|
||||||
|
|
||||||
api.listen(config.port, (err) => {
|
api.listen(config.port, (err) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
|
Loading…
Reference in a new issue