A high-performance Koa server that returns direct and 1-transfer train schedules between two stations. Data is loaded once at startup from the provided JSON files and kept in memory.
- Koa + TypeScript, fast in-memory lookups
- Reads
SingleCityTrack.jsonand all{cityTrackId}.jsonfiles once at startup - Supports direct trains and single-transfer solutions
- Sorts by total travel time (shortest first)
- Mobile-friendly UI with Tailwind CSS (via CDN)
- Node.js 18+
- yarn
For live-reload development:
# Start in dev mode (ts-node-dev)
yarn run devTo update the data files, replace the existing JSON files in the data/ directory with the new versions. Ensure that the filenames remain the same:
SingleCityTrack.json{cityTrackId}.json(e.g.,239.json,240.json, etc.)
yarn run update-data# From the project root (the folder containing package.json)
# 1) Install dependencies
yarn install
# 2) Build TypeScript
yarn run build
# 3) Start the server
yarn startThe server will start at:
http://localhost:3000
- Endpoint:
GET /train-schedule?start=起点站&end=终点站 - Example:
http://localhost:3000/train-schedule?start=惠州北&end=肇庆
If any validation fails:
- Same station for start/end:
Start and end stations cannot be the same. - Station not found:
One or both stations not found in the system.
- Data files expected under
data/at project root:data/SingleCityTrack.jsondata/239.json,data/240.json,data/241.json,data/242.json,data/243.json,data/244.json
- Time calculations assume same-day service; if an arrival/departure crosses midnight, the next-day wrap is handled simply by adding 24h when needed.
- One transfer is supported. If no matching timing is found, you may see only direct results or none.
- Tailwind CSS is included via CDN and does not require a build step.
- 小金口 to 科韵路 departing at 12:40
- 樟木头东 to 科韵路 departing at 07:30
- 科韵路 to 清城 departing at 07:30
- 小金口 to 白云机场南 departing at 07:00
- 小金口 to 白云机场北 departing at 12:30 // 先反方向中转,再上快车
- 竹料 to 科韵路 departing at 07:20

