all stations route

This commit is contained in:
Jannis R 2017-11-04 21:07:20 +01:00
parent f8d59fa5ac
commit 9c1d930a6a
No known key found for this signature in database
GPG key ID: 0FE83946296A88A5
4 changed files with 19 additions and 3 deletions

2
api.js
View file

@ -11,6 +11,7 @@ const nocache = require('nocache')
const pkg = require('./package.json') const pkg = require('./package.json')
const departures = require('./lib/departures') const departures = require('./lib/departures')
const journeys = require('./lib/journeys') const journeys = require('./lib/journeys')
const allStations = require('./lib/all-stations')
@ -39,6 +40,7 @@ const noCache = nocache()
api.get('/stations/:id/departures', noCache, departures) api.get('/stations/:id/departures', noCache, departures)
api.get('/journeys', noCache, journeys) api.get('/journeys', noCache, journeys)
api.get('/stations/all', allStations)

11
lib/all-stations.js Normal file
View file

@ -0,0 +1,11 @@
'use strict'
const file = require.resolve('db-stations/full.ndjson')
const allStations = (req, res, next) => {
res.sendFile(file, {
maxAge: 10 * 24 * 3600 * 1000 // 10 days
}, next)
}
module.exports = allStations

View file

@ -1,7 +1,7 @@
{ {
"private": true, "private": true,
"name": "db-rest", "name": "db-rest",
"description": "Work in progress.", "description": "A clean REST API wrapping around the Deutsche Bahn API.",
"version": "0.1.0", "version": "0.1.0",
"main": "index.js", "main": "index.js",
"files": [ "files": [
@ -19,7 +19,9 @@
"transport", "transport",
"api", "api",
"http", "http",
"rest" "rest",
"deutsche bahn",
"db"
], ],
"engines": { "engines": {
"node": ">=6" "node": ">=6"
@ -29,6 +31,7 @@
"compression": "^1.7.1", "compression": "^1.7.1",
"corser": "^2.0.1", "corser": "^2.0.1",
"db-hafas": "^1.1.0", "db-hafas": "^1.1.0",
"db-stations": "^1.22.0",
"express": "^4.16.2", "express": "^4.16.2",
"hafas-departures-in-direction": "^0.1.0", "hafas-departures-in-direction": "^0.1.0",
"hsts": "^2.1.0", "hsts": "^2.1.0",

View file

@ -1,6 +1,6 @@
# db-rest # db-rest
Work in progress. **A clean REST API wrapping around the [Deutsche Bahn](https://en.wikipedia.org/wiki/Deutsche_Bahn) API.**
[![dependency status](https://img.shields.io/david/derhuerst/db-rest.svg)](https://david-dm.org/derhuerst/db-rest) [![dependency status](https://img.shields.io/david/derhuerst/db-rest.svg)](https://david-dm.org/derhuerst/db-rest)
![ISC-licensed](https://img.shields.io/github/license/derhuerst/db-rest.svg) ![ISC-licensed](https://img.shields.io/github/license/derhuerst/db-rest.svg)