diff --git a/example.js b/example.js index eba3ac4..8c21d7a 100644 --- a/example.js +++ b/example.js @@ -1,3 +1,33 @@ 'use strict' -// todo +const createHafas = require('.') + +const jungfernheide = '900000020201' +const tempelhof = '900000068201' + +const hafas = createHafas('bvg-hafas example') + +hafas.journeys(jungfernheide, tempelhof, {results: 1}) +// .then(([journey]) => { +// const leg = journey.legs[0] +// return hafas.journeyLeg(leg.id, leg.line.name) +// }) + +// hafas.departures(jungfernheide, { duration: 5 }) +// hafas.locations('friedrichstr', {results: 2}) +// hafas.locations('mauerpark', {results: 2}) +// hafas.location(jungfernheide) +// hafas.nearby({ +// type: 'location', +// latitude: 52.5137344, +// longitude: 13.4744798 +// }, {distance: 200}) +// hafas.radar({ +// north: 52.52411, +// west: 13.41002, +// south: 52.51942, +// east: 13.41709 +// }, {results: 10}) + +.then(console.log) +.catch(console.error) diff --git a/index.js b/index.js index eba3ac4..fff5bc1 100644 --- a/index.js +++ b/index.js @@ -1,3 +1,10 @@ 'use strict' -// todo +const createHafasClient = require('hafas-client') +const bvgProfile = require('hafas-client/p/bvg') + +const createClient = (userAgent) => { + return createHafasClient(bvgProfile, userAgent) +} + +module.exports = createClient diff --git a/package.json b/package.json index cf83670..0c5473e 100644 --- a/package.json +++ b/package.json @@ -26,5 +26,6 @@ "node": ">=6" }, "dependencies": { + "hafas-client": "^3.0.0-alpha.21" } } diff --git a/throttle.js b/throttle.js index eba3ac4..7b22bae 100644 --- a/throttle.js +++ b/throttle.js @@ -1,3 +1,10 @@ 'use strict' -// todo +const createThrottledClient = require('hafas-client/throttle') +const bvgProfile = require('hafas-client/p/bvg') + +const throttle = (limit = 5, interval = 1000) => { + return createThrottledClient(bvgProfile, limit, interval) +} + +module.exports = throttle