feat: initial project scaffold with CI/CD and Docker deployment

Next.js 15 + Tailwind CSS v4 week calendar showing Six Flags park hours.
Scrapes the internal CloudFront API, stores results in SQLite.
Includes Dockerfile (Debian/Playwright-compatible), docker-compose, and
Gitea Actions pipeline that builds and pushes to the container registry.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-04 00:48:09 -04:00
parent af6aa29474
commit 548c7ae09e
26 changed files with 9602 additions and 0 deletions

59
app/api/parks/route.ts Normal file
View File

@@ -0,0 +1,59 @@
import { NextRequest, NextResponse } from "next/server";
import { PARKS } from "@/lib/parks";
import { openDb, getMonthCalendar } from "@/lib/db";
import type { Park } from "@/lib/scrapers/types";
export interface ParksApiResponse {
parks: Park[];
calendar: Record<string, boolean[]>;
month: string;
daysInMonth: number;
}
function getDaysInMonth(year: number, month: number): number {
return new Date(year, month, 0).getDate();
}
function parseMonthParam(
monthParam: string | null
): { year: number; month: number } | null {
if (!monthParam) return null;
const match = monthParam.match(/^(\d{4})-(\d{2})$/);
if (!match) return null;
const year = parseInt(match[1], 10);
const month = parseInt(match[2], 10);
if (month < 1 || month > 12) return null;
return { year, month };
}
export async function GET(request: NextRequest): Promise<NextResponse> {
const monthParam = request.nextUrl.searchParams.get("month");
const parsed = parseMonthParam(monthParam);
if (!parsed) {
return NextResponse.json(
{ error: "Invalid or missing ?month=YYYY-MM parameter" },
{ status: 400 }
);
}
const { year, month } = parsed;
const daysInMonth = getDaysInMonth(year, month);
const db = openDb();
const calendar = getMonthCalendar(db, year, month);
db.close();
const response: ParksApiResponse = {
parks: PARKS,
calendar,
month: `${year}-${String(month).padStart(2, "0")}`,
daysInMonth,
};
return NextResponse.json(response, {
headers: {
"Cache-Control": "public, s-maxage=3600, stale-while-revalidate=86400",
},
});
}

46
app/globals.css Normal file
View File

@@ -0,0 +1,46 @@
@import "tailwindcss";
@theme {
--color-bg: #0a0f1e;
--color-surface: #111827;
--color-surface-2: #1a2235;
--color-border: #1f2d45;
--color-text: #f1f5f9;
--color-text-muted: #64748b;
--color-text-dim: #334155;
--color-open-bg: #052e16;
--color-open-border: #166534;
--color-open-text: #4ade80;
--color-open-hours: #bbf7d0;
--color-today-bg: #0c1a3d;
--color-today-border: #2563eb;
--color-today-text: #93c5fd;
--color-weekend-header: #141f35;
}
:root {
background-color: var(--color-bg);
color: var(--color-text);
font-family: ui-sans-serif, system-ui, -apple-system, sans-serif;
}
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
::-webkit-scrollbar {
width: 6px;
height: 6px;
}
::-webkit-scrollbar-track {
background: var(--color-bg);
}
::-webkit-scrollbar-thumb {
background: var(--color-border);
border-radius: 3px;
}

15
app/layout.tsx Normal file
View File

@@ -0,0 +1,15 @@
import type { Metadata } from "next";
import "./globals.css";
export const metadata: Metadata = {
title: "Six Flags Calendar",
description: "Theme park operating calendars at a glance",
};
export default function RootLayout({ children }: { children: React.ReactNode }) {
return (
<html lang="en">
<body>{children}</body>
</html>
);
}

137
app/page.tsx Normal file
View File

@@ -0,0 +1,137 @@
import { WeekCalendar } from "@/components/WeekCalendar";
import { WeekNav } from "@/components/WeekNav";
import { PARKS } from "@/lib/parks";
import { openDb, getDateRange } from "@/lib/db";
interface PageProps {
searchParams: Promise<{ week?: string }>;
}
function getWeekStart(param: string | undefined): string {
if (param && /^\d{4}-\d{2}-\d{2}$/.test(param)) {
const d = new Date(param + "T00:00:00");
if (!isNaN(d.getTime())) {
// Snap to Sunday
d.setDate(d.getDate() - d.getDay());
return d.toISOString().slice(0, 10);
}
}
const today = new Date();
today.setDate(today.getDate() - today.getDay());
return today.toISOString().slice(0, 10);
}
function getWeekDates(sundayIso: string): string[] {
return Array.from({ length: 7 }, (_, i) => {
const d = new Date(sundayIso + "T00:00:00");
d.setDate(d.getDate() + i);
return d.toISOString().slice(0, 10);
});
}
export default async function HomePage({ searchParams }: PageProps) {
const params = await searchParams;
const weekStart = getWeekStart(params.week);
const weekDates = getWeekDates(weekStart);
const endDate = weekDates[6];
const db = openDb();
const data = getDateRange(db, weekStart, endDate);
db.close();
// Count how many days have any scraped data (to show empty state)
const scrapedCount = Object.values(data).reduce(
(sum, parkData) => sum + Object.keys(parkData).length,
0
);
return (
<div style={{ minHeight: "100vh", background: "var(--color-bg)" }}>
{/* Header */}
<header style={{
borderBottom: "1px solid var(--color-border)",
padding: "16px 24px",
display: "flex",
alignItems: "center",
justifyContent: "space-between",
gap: 16,
position: "sticky",
top: 0,
zIndex: 20,
background: "var(--color-bg)",
}}>
<div style={{ display: "flex", alignItems: "baseline", gap: 10 }}>
<span style={{ fontSize: "1rem", fontWeight: 700, color: "var(--color-text)", letterSpacing: "-0.02em" }}>
Six Flags Calendar
</span>
<span style={{ fontSize: "0.75rem", color: "var(--color-text-muted)" }}>
{PARKS.length} parks
</span>
</div>
<WeekNav weekStart={weekStart} weekDates={weekDates} />
<Legend />
</header>
{/* Calendar */}
<main style={{ padding: "0 24px 40px" }}>
{scrapedCount === 0 ? (
<EmptyState />
) : (
<WeekCalendar parks={PARKS} weekDates={weekDates} data={data} />
)}
</main>
</div>
);
}
function Legend() {
return (
<div style={{ display: "flex", alignItems: "center", gap: 16, fontSize: "0.72rem", color: "var(--color-text-muted)" }}>
<span style={{ display: "flex", alignItems: "center", gap: 5 }}>
<span style={{
display: "inline-block", width: 28, height: 14, borderRadius: 3,
background: "var(--color-open-bg)", border: "1px solid var(--color-open-border)",
}} />
Open
</span>
<span style={{ display: "flex", alignItems: "center", gap: 5 }}>
<span style={{ color: "var(--color-text-dim)" }}>Closed</span>
<span style={{ color: "var(--color-border)" }}>·</span>
<span style={{ color: "var(--color-text-dim)" }}> no data</span>
</span>
</div>
);
}
function EmptyState() {
return (
<div style={{
display: "flex",
flexDirection: "column",
alignItems: "center",
justifyContent: "center",
padding: "80px 24px",
gap: 12,
color: "var(--color-text-muted)",
}}>
<div style={{ fontSize: "2rem" }}>📅</div>
<div style={{ fontSize: "1rem", fontWeight: 600, color: "var(--color-text)" }}>No data scraped yet</div>
<div style={{ fontSize: "0.85rem", textAlign: "center", lineHeight: 1.6 }}>
Run the following to populate the calendar:
</div>
<pre style={{
background: "var(--color-surface)",
border: "1px solid var(--color-border)",
borderRadius: 8,
padding: "12px 20px",
fontSize: "0.8rem",
color: "var(--color-text)",
lineHeight: 1.8,
}}>
npm run discover{"\n"}npm run scrape
</pre>
</div>
);
}