4f838d99c1
Build and Deploy / Build & Push (push) Successful in 3m7s
Adds a cron-driven sampler that snapshots Queue-Times waits and Six Flags Fast Lane data every 5 minutes into a new ride_wait_samples table, and a clickable per-ride detail page at /park/[id]/ride/[slug] with Today / 7d / 30d Recharts views plus a 30d uptime pill. Rides are keyed by Queue-Times' stable qt_ride_id so renames don't fragment history. Samples store pre-bucketed local_date and local_time in the park's IANA timezone so aggregations are pure SQL and DST-safe. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
41 lines
1.1 KiB
TypeScript
41 lines
1.1 KiB
TypeScript
import { Hono } from "hono";
|
|
import { serve } from "@hono/node-server";
|
|
import { cors } from "hono/cors";
|
|
import { logger } from "hono/logger";
|
|
|
|
import { getDb } from "./db/index";
|
|
import { startScheduler } from "./services/scheduler";
|
|
|
|
import calendarRoutes from "./routes/calendar";
|
|
import parksRoutes from "./routes/parks";
|
|
import ridesRoutes from "./routes/rides";
|
|
import rideHistoryRoutes from "./routes/ride-history";
|
|
import statusRoutes from "./routes/status";
|
|
import scrapeRoutes from "./routes/scrape";
|
|
|
|
const PORT = parseInt(process.env.PORT ?? "3001", 10);
|
|
|
|
const app = new Hono();
|
|
|
|
app.use("*", logger());
|
|
app.use("*", cors());
|
|
|
|
app.route("/api/calendar", calendarRoutes);
|
|
app.route("/api/parks", parksRoutes);
|
|
app.route("/api/parks", ridesRoutes);
|
|
app.route("/api/parks", rideHistoryRoutes);
|
|
app.route("/api/status", statusRoutes);
|
|
app.route("/api/scrape", scrapeRoutes);
|
|
|
|
// Initialize database on startup
|
|
getDb();
|
|
console.log("[backend] database initialized");
|
|
|
|
// Start cron scheduler
|
|
startScheduler();
|
|
|
|
// Start HTTP server
|
|
serve({ fetch: app.fetch, port: PORT }, (info) => {
|
|
console.log(`[backend] listening on http://localhost:${info.port}`);
|
|
});
|