Skip to content

webcubed/react-countdown-clock

Repository files navigation

Countdown clock

An overhaul of the STUA's countdown clock in react


Architecture Overview

  • Static GTFS feeds (subway, supplemented subway, LIRR) are fetched and parsed by the cron-triggered API route /api/admin/refresh-static-gtfs every 12 hours (see vercel.json).
  • Results (raw zip + parsed JSON bundle) are written to Vercel Blob under gtfs/<mode>.zip and gtfs/<mode>.json.
  • The consumer endpoint /api/mta/static/[mode] reads exclusively from Blob (no local filesystem copies).
  • Realtime feeds handled in src/utils/mta/realtime.ts using gtfs-realtime-bindings (no protobuf.js needed).
  • Feed URL constants are in src/utils/mta/feeds.ts.

Required enviornment variables:

  • BLOB_BASE_URL (public blob base, e.g. https://example.public.blob.vercel-storage.com)
  • BLOB_READ_WRITE_TOKEN (read/write bearer token used by refresh route uploads)

APIs

  • /api/mta/realtime/[feed]
    • Subway realtime protobuf feed decoded and serialized.
  • /api/mta/static/[mode]
    • Static GTFS JSON bundle for "subway", "subway_supplemented", "lirr".
  • /api/mta/bus/stops?lat=40.7178&lon=-74.0131&radius=400
    • Nearby bus stops (defaults to Stuyvesant HS coordinates if omitted).
  • /api/mta/bus/arrivals/[stopId]
    • SIRI Stop Monitoring (version 2, minimum detail) arrivals for given stop ID.

Bus API env variable (optional, fallback to public key if missing):

  • BUSTIME_KEY (MTA Bustime api key)

TODO

  • Implement bus API (nearby stops + arrivals)

Getting Started

First, run the development server:

npm run dev
# or
yarn dev
# or
pnpm dev
# or
bun dev

Open http://localhost:3000 with your browser to see the result.

About

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages