2017-11-04 21:07:20 +01:00
|
|
|
'use strict'
|
|
|
|
|
2018-02-25 00:03:42 +01:00
|
|
|
let raw = require('db-stations/full.json')
|
|
|
|
|
|
|
|
let data = {}
|
|
|
|
for (let key in raw) {
|
|
|
|
if (!Object.prototype.hasOwnProperty.call(raw, key)) continue
|
|
|
|
const station = Object.assign({}, raw[key]) // clone
|
|
|
|
|
|
|
|
// todo: remove this remapping (breaking change!)
|
|
|
|
station.coordinates = station.location
|
|
|
|
delete station.location
|
|
|
|
|
|
|
|
data[station.id] = station
|
|
|
|
}
|
|
|
|
data = JSON.stringify(data) + '\n'
|
|
|
|
raw = null
|
2017-11-04 21:07:20 +01:00
|
|
|
|
|
|
|
const allStations = (req, res, next) => {
|
2018-02-25 00:03:42 +01:00
|
|
|
// res.sendFile(rawPath, {
|
|
|
|
// maxAge: 10 * 24 * 3600 * 1000 // 10 days
|
|
|
|
// }, next)
|
|
|
|
res.set('content-type', 'application/json')
|
|
|
|
res.send(data)
|
2017-11-04 21:07:20 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = allStations
|