-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
example.js
34 lines (27 loc) · 860 Bytes
/
example.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
'use strict'
const createHafas = require('db-hafas')
const generateLink = require('.')
const when = require('./test/when') // Monday in a week, 10am
const berlin = '8011160'
const hamburg = '8096009'
// const passau = '8000298'
// const paris = '8796001'
const hafas = createHafas('generate-db-shop-urls example')
;(async () => {
// Berlin -> Hamburg, Hamburg -> Berlin
const outbound = await hafas.journeys(berlin, hamburg, {
departure: when.outbound, results: 1
})
const returning = await hafas.journeys(hamburg, berlin, {
departure: when.returning, results: 1
})
const link = await generateLink(outbound.journeys[0], {
returning: returning.journeys[0],
})
console.log('open the following link in a *private* browsing session (without bahn.de cookies):')
console.log(link)
})()
.catch((err) => {
console.error(err)
process.exit(1)
})