hk-bus-eta 1.2.1 → 1.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Ctb.js +8 -2
- package/Kmb.js +6 -2
- package/Nlb.js +6 -3
- package/Nwfb.js +8 -2
- package/package.json +1 -1
- package/utils.js +3 -0
package/Ctb.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
|
+
const utils = require('./utils')
|
|
2
|
+
|
|
1
3
|
module.exports = {
|
|
2
4
|
co: 'ctb',
|
|
3
5
|
fetchEtas: ({stopId, route, bound }) => (
|
|
4
|
-
fetch(`https://rt.data.gov.hk//v1/transport/citybus-nwfb/eta/CTB/${stopId}/${route}`, {
|
|
6
|
+
fetch(`https://rt.data.gov.hk//v1/transport/citybus-nwfb/eta/CTB/${stopId}/${route}`, {
|
|
7
|
+
cache: utils.isSafari ? 'default' : 'no-store'
|
|
8
|
+
}).then(
|
|
5
9
|
response => response.json()
|
|
6
10
|
).then(({data}) => data.filter(eta => eta.eta && eta.dir === bound).map(e => ({
|
|
7
11
|
eta: e.eta,
|
|
@@ -14,7 +18,9 @@ module.exports = {
|
|
|
14
18
|
)
|
|
15
19
|
),
|
|
16
20
|
fetchStopEtas: ( stopId ) => (
|
|
17
|
-
fetch(`https://rt.data.gov.hk/v1/transport/batch/stop-eta/CTB/${stopId}`, {
|
|
21
|
+
fetch(`https://rt.data.gov.hk/v1/transport/batch/stop-eta/CTB/${stopId}`, {
|
|
22
|
+
cache: utils.isSafari ? 'default' : 'no-store'
|
|
23
|
+
}).then(
|
|
18
24
|
response => response.json()
|
|
19
25
|
).then(({data}) => data.map( e => ({
|
|
20
26
|
route: e.route,
|
package/Kmb.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
const utils = require('./utils')
|
|
2
|
+
|
|
1
3
|
module.exports = {
|
|
2
4
|
co: 'kmb',
|
|
3
5
|
fetchEtas: ({stopId, route, seq, serviceType, bound}) => (
|
|
4
6
|
fetch(
|
|
5
7
|
`https://data.etabus.gov.hk/v1/transport/kmb/eta/${stopId}/${route}/${serviceType}`,
|
|
6
|
-
{ cache:
|
|
8
|
+
{ cache: utils.isSafari ? 'default' : 'no-store' }
|
|
7
9
|
).then( response => response.json() )
|
|
8
10
|
.then(({data}) => data.filter(e =>
|
|
9
11
|
e.dir === bound
|
|
@@ -19,7 +21,9 @@ module.exports = {
|
|
|
19
21
|
)
|
|
20
22
|
),
|
|
21
23
|
fetchStopEtas: ( stopId ) => (
|
|
22
|
-
fetch(`https://data.etabus.gov.hk/v1/transport/kmb/stop-eta/${stopId}`, {
|
|
24
|
+
fetch(`https://data.etabus.gov.hk/v1/transport/kmb/stop-eta/${stopId}`, {
|
|
25
|
+
cache: utils.isSafari ? 'default' : 'no-store'
|
|
26
|
+
})
|
|
23
27
|
.then(response => response.json())
|
|
24
28
|
.then(({data}) => data.map( e => ({
|
|
25
29
|
route: e.route,
|
package/Nlb.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
const utils = require('./utils')
|
|
2
|
+
|
|
1
3
|
module.exports = {
|
|
2
4
|
co: 'nlb',
|
|
3
5
|
fetchEtas: ({stopId, nlbId }) => (
|
|
@@ -11,7 +13,7 @@ module.exports = {
|
|
|
11
13
|
"Content-Type": "text/plain"
|
|
12
14
|
},
|
|
13
15
|
method: "POST",
|
|
14
|
-
cache: 'no-store'
|
|
16
|
+
cache: utils.isSafari ? 'default' : 'no-store'
|
|
15
17
|
}).then(
|
|
16
18
|
response => response.json()
|
|
17
19
|
).then(({estimatedArrivals}) => {
|
|
@@ -27,8 +29,9 @@ module.exports = {
|
|
|
27
29
|
})
|
|
28
30
|
),
|
|
29
31
|
fetchStopEtas: ( stopId ) => (
|
|
30
|
-
fetch(`https://rt.data.gov.hk/v1/transport/batch/stop-eta/NLB/${stopId}`, {
|
|
31
|
-
|
|
32
|
+
fetch(`https://rt.data.gov.hk/v1/transport/batch/stop-eta/NLB/${stopId}`, {
|
|
33
|
+
cache: utils.isSafari ? 'default' : 'no-store'
|
|
34
|
+
}).then( response => {
|
|
32
35
|
if (response.ok)
|
|
33
36
|
return response.json()
|
|
34
37
|
// special handle for NLB API
|
package/Nwfb.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
|
+
const utils = require('./utils')
|
|
2
|
+
|
|
1
3
|
module.exports = {
|
|
2
4
|
co: 'nwfb',
|
|
3
5
|
fetchEtas: ({stopId, route, bound }) => (
|
|
4
|
-
fetch(`https://rt.data.gov.hk//v1/transport/citybus-nwfb/eta/NWFB/${stopId}/${route}`, {
|
|
6
|
+
fetch(`https://rt.data.gov.hk//v1/transport/citybus-nwfb/eta/NWFB/${stopId}/${route}`, {
|
|
7
|
+
cache: utils.isSafari ? 'default' : 'no-store'
|
|
8
|
+
}).then(
|
|
5
9
|
response => response.json()
|
|
6
10
|
).then(({data}) => data.filter(eta => eta.eta && eta.dir === bound).map(e => ({
|
|
7
11
|
eta: e.eta,
|
|
@@ -14,7 +18,9 @@ module.exports = {
|
|
|
14
18
|
)
|
|
15
19
|
),
|
|
16
20
|
fetchStopEtas: ( stopId ) => (
|
|
17
|
-
fetch(`https://rt.data.gov.hk/v1/transport/batch/stop-eta/NWFB/${stopId}`, {
|
|
21
|
+
fetch(`https://rt.data.gov.hk/v1/transport/batch/stop-eta/NWFB/${stopId}`, {
|
|
22
|
+
cache: utils.isSafari ? 'default' : 'no-store'
|
|
23
|
+
}).then(
|
|
18
24
|
response => response.json()
|
|
19
25
|
).then(({data}) => data.map( e => ({
|
|
20
26
|
route: e.route,
|
package/package.json
CHANGED
package/utils.js
ADDED