diff --git a/api.js b/api.js index 9d91814..91dbf86 100644 --- a/api.js +++ b/api.js @@ -11,6 +11,7 @@ const nocache = require('nocache') const pkg = require('./package.json') const departures = require('./lib/departures') 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('/journeys', noCache, journeys) +api.get('/stations/all', allStations) diff --git a/lib/all-stations.js b/lib/all-stations.js new file mode 100644 index 0000000..209bf35 --- /dev/null +++ b/lib/all-stations.js @@ -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 diff --git a/package.json b/package.json index 87ce6d5..d4205f9 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "private": true, "name": "db-rest", - "description": "Work in progress.", + "description": "A clean REST API wrapping around the Deutsche Bahn API.", "version": "0.1.0", "main": "index.js", "files": [ @@ -19,7 +19,9 @@ "transport", "api", "http", - "rest" + "rest", + "deutsche bahn", + "db" ], "engines": { "node": ">=6" @@ -29,6 +31,7 @@ "compression": "^1.7.1", "corser": "^2.0.1", "db-hafas": "^1.1.0", + "db-stations": "^1.22.0", "express": "^4.16.2", "hafas-departures-in-direction": "^0.1.0", "hsts": "^2.1.0", diff --git a/readme.md b/readme.md index 577d9cf..30a0085 100644 --- a/readme.md +++ b/readme.md @@ -1,6 +1,6 @@ # 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) ![ISC-licensed](https://img.shields.io/github/license/derhuerst/db-rest.svg)