-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.js
53 lines (49 loc) · 1.56 KB
/
index.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import {createNearbyRoute as nearby} from './nearby.js'
import {createStopRoute as stop} from './stop.js'
import {createDeparturesRoute as departures} from './departures.js'
import {createArrivalsRoute as arrivals} from './arrivals.js'
import {createJourneysRoute as journeys} from './journeys.js'
import {createLocationsRoute as locations} from './locations.js'
const getAllRoutes = async (hafas, config) => {
const routes = Object.create(null)
if (hafas.reachableFrom) {
const {
createReachableFromRoute: reachableFrom,
} = await import('./reachable-from.js')
routes['/stops/reachable-from'] = reachableFrom(hafas, config)
}
routes['/stops/:id'] = stop(hafas, config)
routes['/stops/:id/departures'] = departures(hafas, config)
routes['/stops/:id/arrivals'] = arrivals(hafas, config)
routes['/journeys'] = journeys(hafas, config)
if (hafas.trip) {
const {
createTripRoute: trip,
} = await import('./trip.js')
routes['/trips/:id'] = trip(hafas, config)
}
if (hafas.tripsByName) {
const {
createTripsRoute: trips,
} = await import('./trips.js')
routes['/trips'] = trips(hafas, config)
}
routes['/locations/nearby'] = nearby(hafas, config)
routes['/locations'] = locations(hafas, config)
if (hafas.radar) {
const {
createRadarRoute: radar,
} = await import('./radar.js')
routes['/radar'] = radar(hafas, config)
}
if (hafas.refreshJourney) {
const {
createRefreshJourneyRoute: refreshJourney,
} = await import('./refresh-journey.js')
routes['/journeys/:ref'] = refreshJourney(hafas, config)
}
return routes
}
export {
getAllRoutes,
}