Skip to content

Commit

Permalink
Update source domain & prepare for gmb differentiation
Browse files Browse the repository at this point in the history
  • Loading branch information
chunlaw committed Dec 10, 2023
1 parent ddd3c01 commit d59a94a
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 9 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "hk-bus-eta",
"version": "3.1.0",
"version": "3.1.1",
"description": "Query the ETA (Estimated Time of Arrival) of HK Bus/Minibus/MTR/Lightrail",
"main": "dist/index.js",
"module": "esm/index.js",
Expand Down Expand Up @@ -40,7 +40,7 @@
"bugs": {
"url": "https://github.com/hkbus/hk-bus-eta/issues"
},
"homepage": "https://hk-bus-eta.chunlaw.io/",
"homepage": "https://hk-bus-eta.hkbus.app/",
"devDependencies": {
"@types/jest": "^29.5.4",
"jest": "^29.6.4",
Expand Down
33 changes: 31 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,33 @@ export async function fetchEtas({
bound: bound.mtr,
}),
);
} else if (company_id === "gmbHki" && stops.gmbHki) {
_etas = _etas.concat(
await gmb({
stopId: stops.gmbHki[seq],
gtfsId,
seq,
bound: bound.gmbHki,
}),
);
} else if (company_id === "gmbKln" && stops.gmbKln) {
_etas = _etas.concat(
await gmb({
stopId: stops.gmbKln[seq],
gtfsId,
seq,
bound: bound.gmbKln,
}),
);
} else if (company_id === "gmbNt" && stops.gmbNt) {
_etas = _etas.concat(
await gmb({
stopId: stops.gmbNt[seq],
gtfsId,
seq,
bound: bound.gmbNt,
}),
);
}
}

Expand All @@ -84,13 +111,15 @@ export async function fetchEtas({

export async function fetchEtaDb(): Promise<EtaDb> {
return fetch(
"https://hkbus.github.io/hk-bus-crawling/routeFareList.min.json",
"https://data.hkbus.app/routeFareList.min.json",
// or https://hkbus.github.io/hk-bus-crawling/routeFareList.min.json
).then((r) => r.json());
}

export async function fetchEtaDbMd5(): Promise<string> {
return fetch(
"https://hkbus.github.io/hk-bus-crawling/routeFareList.md5",
"https://data.hkbus.app/routeFareList.md5",
// or https://hkbus.github.io/hk-bus-crawling/routeFareList.md5
).then((r) => r.text());
}

Expand Down
4 changes: 2 additions & 2 deletions src/lightRail.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ export default function fetchEtas({
.join("")}`,
},
dest: {
zh: '',
en: '',
zh: "",
en: "",
},
co: "lightRail",
};
Expand Down
4 changes: 2 additions & 2 deletions src/lrtfeeder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ export default function fetchEtas({
: ""),
},
dest: {
zh: '',
en: '',
zh: "",
en: "",
},
co: "lrtfeeder",
},
Expand Down
5 changes: 4 additions & 1 deletion src/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ export type Company =
| "lrtfeeder"
| "gmb"
| "lightRail"
| "mtr";
| "mtr"
| "gmbHki"
| "gmbKln"
| "gmbNt";

export type Terminal = {
en: string;
Expand Down

0 comments on commit d59a94a

Please sign in to comment.