first commit
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
import { NextRequest, NextResponse } from "next/server";
|
||||
import { isCardType } from "@/lib/cards";
|
||||
import { generateCard } from "@/lib/card-generator";
|
||||
|
||||
export async function GET(
|
||||
request: NextRequest,
|
||||
{ params }: { params: Promise<{ type: string }> },
|
||||
) {
|
||||
const { type } = await params;
|
||||
const movieId = Number(request.nextUrl.searchParams.get("movieId"));
|
||||
|
||||
if (!isCardType(type)) {
|
||||
return NextResponse.json({ error: "Unknown card type" }, { status: 400 });
|
||||
}
|
||||
|
||||
if (!Number.isFinite(movieId) || movieId <= 0) {
|
||||
return NextResponse.json({ error: "Invalid movie ID" }, { status: 400 });
|
||||
}
|
||||
|
||||
try {
|
||||
const result = await generateCard(movieId, type);
|
||||
return NextResponse.json(result);
|
||||
} catch (error) {
|
||||
console.error(`Card generation failed (${type}):`, error);
|
||||
return NextResponse.json(
|
||||
{ error: "Something went wrong. Try again." },
|
||||
{ status: 500 },
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
import { NextResponse } from "next/server";
|
||||
import { checkDbConnection } from "@/lib/db";
|
||||
|
||||
export async function GET() {
|
||||
const dbHealthy = await checkDbConnection();
|
||||
|
||||
return NextResponse.json(
|
||||
{
|
||||
status: dbHealthy ? "ok" : "degraded",
|
||||
db: dbHealthy ? "connected" : "unavailable",
|
||||
},
|
||||
{ status: dbHealthy ? 200 : 503 },
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
import { NextRequest, NextResponse } from "next/server";
|
||||
import { searchMovies } from "@/lib/tmdb";
|
||||
|
||||
export async function GET(request: NextRequest) {
|
||||
const query = request.nextUrl.searchParams.get("q") ?? "";
|
||||
|
||||
if (!query.trim()) {
|
||||
return NextResponse.json({ results: [] });
|
||||
}
|
||||
|
||||
try {
|
||||
const results = await searchMovies(query);
|
||||
return NextResponse.json({ results });
|
||||
} catch (error) {
|
||||
console.error("Search failed:", error);
|
||||
return NextResponse.json(
|
||||
{ error: "Something went wrong. Try again." },
|
||||
{ status: 500 },
|
||||
);
|
||||
}
|
||||
}
|
||||
+7
-10
@@ -1,8 +1,8 @@
|
||||
@import "tailwindcss";
|
||||
|
||||
:root {
|
||||
--background: #ffffff;
|
||||
--foreground: #171717;
|
||||
--background: #020617;
|
||||
--foreground: #f8fafc;
|
||||
}
|
||||
|
||||
@theme inline {
|
||||
@@ -12,15 +12,12 @@
|
||||
--font-mono: var(--font-geist-mono);
|
||||
}
|
||||
|
||||
@media (prefers-color-scheme: dark) {
|
||||
:root {
|
||||
--background: #0a0a0a;
|
||||
--foreground: #ededed;
|
||||
}
|
||||
}
|
||||
|
||||
body {
|
||||
background: var(--background);
|
||||
color: var(--foreground);
|
||||
font-family: Arial, Helvetica, sans-serif;
|
||||
font-family: var(--font-geist-sans), system-ui, sans-serif;
|
||||
}
|
||||
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
+6
-4
@@ -13,8 +13,8 @@ const geistMono = Geist_Mono({
|
||||
});
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: "Create Next App",
|
||||
description: "Generated by create next app",
|
||||
title: "Film Intel",
|
||||
description: "Advanced movie insight you won't find in one click",
|
||||
};
|
||||
|
||||
export default function RootLayout({
|
||||
@@ -27,7 +27,9 @@ export default function RootLayout({
|
||||
lang="en"
|
||||
className={`${geistSans.variable} ${geistMono.variable} h-full antialiased`}
|
||||
>
|
||||
<body className="min-h-full flex flex-col">{children}</body>
|
||||
<body className="min-h-full flex flex-col bg-slate-950 text-slate-100">
|
||||
{children}
|
||||
</body>
|
||||
</html>
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
import { notFound } from "next/navigation";
|
||||
import { MovieHeader } from "@/components/MovieHeader";
|
||||
import { MovieInsightPanel } from "@/components/MovieInsightPanel";
|
||||
import { getMovieDetails } from "@/lib/tmdb";
|
||||
|
||||
export default async function MoviePage({
|
||||
params,
|
||||
}: {
|
||||
params: Promise<{ id: string }>;
|
||||
}) {
|
||||
const { id } = await params;
|
||||
const movieId = Number(id);
|
||||
|
||||
if (!Number.isFinite(movieId) || movieId <= 0) {
|
||||
notFound();
|
||||
}
|
||||
|
||||
let movie;
|
||||
try {
|
||||
movie = await getMovieDetails(movieId);
|
||||
} catch {
|
||||
notFound();
|
||||
}
|
||||
|
||||
return (
|
||||
<main className="mx-auto min-h-screen w-full max-w-6xl px-6 py-10">
|
||||
<div className="space-y-10">
|
||||
<MovieHeader movie={movie} />
|
||||
<MovieInsightPanel
|
||||
movieId={movie.id}
|
||||
genres={movie.genres.map((genre) => genre.name)}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<footer className="mt-16 border-t border-white/10 pt-6 text-center text-xs text-slate-500">
|
||||
AI-generated content for informational purposes. Verify timestamps on
|
||||
your copy.
|
||||
</footer>
|
||||
</main>
|
||||
);
|
||||
}
|
||||
+23
-59
@@ -1,65 +1,29 @@
|
||||
import Image from "next/image";
|
||||
import { SearchBar } from "@/components/SearchBar";
|
||||
|
||||
export default function Home() {
|
||||
export default function HomePage() {
|
||||
return (
|
||||
<div className="flex flex-col flex-1 items-center justify-center bg-zinc-50 font-sans dark:bg-black">
|
||||
<main className="flex flex-1 w-full max-w-3xl flex-col items-center justify-between py-32 px-16 bg-white dark:bg-black sm:items-start">
|
||||
<Image
|
||||
className="dark:invert"
|
||||
src="/next.svg"
|
||||
alt="Next.js logo"
|
||||
width={100}
|
||||
height={20}
|
||||
priority
|
||||
/>
|
||||
<div className="flex flex-col items-center gap-6 text-center sm:items-start sm:text-left">
|
||||
<h1 className="max-w-xs text-3xl font-semibold leading-10 tracking-tight text-black dark:text-zinc-50">
|
||||
To get started, edit the page.tsx file.
|
||||
<main className="mx-auto flex min-h-screen w-full max-w-5xl flex-col items-center justify-center px-6 py-16">
|
||||
<div className="relative z-10 w-full max-w-2xl space-y-8 text-center">
|
||||
<div className="space-y-3">
|
||||
<p className="text-sm font-medium uppercase tracking-[0.2em] text-amber-300/80">
|
||||
Film Intel
|
||||
</p>
|
||||
<h1 className="text-4xl font-semibold tracking-tight text-white md:text-5xl">
|
||||
Movie insight you won't find in one click
|
||||
</h1>
|
||||
<p className="max-w-md text-lg leading-8 text-zinc-600 dark:text-zinc-400">
|
||||
Looking for a starting point or more instructions? Head over to{" "}
|
||||
<a
|
||||
href="https://vercel.com/templates?framework=next.js&utm_source=create-next-app&utm_medium=appdir-template-tw&utm_campaign=create-next-app"
|
||||
className="font-medium text-zinc-950 dark:text-zinc-50"
|
||||
>
|
||||
Templates
|
||||
</a>{" "}
|
||||
or the{" "}
|
||||
<a
|
||||
href="https://nextjs.org/learn?utm_source=create-next-app&utm_medium=appdir-template-tw&utm_campaign=create-next-app"
|
||||
className="font-medium text-zinc-950 dark:text-zinc-50"
|
||||
>
|
||||
Learning
|
||||
</a>{" "}
|
||||
center.
|
||||
<p className="text-slate-400">
|
||||
Ratings explained, skip guides, sensitivity warnings, and deep
|
||||
production context for any film.
|
||||
</p>
|
||||
</div>
|
||||
<div className="flex flex-col gap-4 text-base font-medium sm:flex-row">
|
||||
<a
|
||||
className="flex h-12 w-full items-center justify-center gap-2 rounded-full bg-foreground px-5 text-background transition-colors hover:bg-[#383838] dark:hover:bg-[#ccc] md:w-[158px]"
|
||||
href="https://vercel.com/new?utm_source=create-next-app&utm_medium=appdir-template-tw&utm_campaign=create-next-app"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
<Image
|
||||
className="dark:invert"
|
||||
src="/vercel.svg"
|
||||
alt="Vercel logomark"
|
||||
width={16}
|
||||
height={16}
|
||||
/>
|
||||
Deploy Now
|
||||
</a>
|
||||
<a
|
||||
className="flex h-12 w-full items-center justify-center rounded-full border border-solid border-black/[.08] px-5 transition-colors hover:border-transparent hover:bg-black/[.04] dark:border-white/[.145] dark:hover:bg-[#1a1a1a] md:w-[158px]"
|
||||
href="https://nextjs.org/docs?utm_source=create-next-app&utm_medium=appdir-template-tw&utm_campaign=create-next-app"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
Documentation
|
||||
</a>
|
||||
</div>
|
||||
</main>
|
||||
</div>
|
||||
|
||||
<SearchBar autoFocus />
|
||||
</div>
|
||||
|
||||
<footer className="mt-auto pt-16 text-center text-xs text-slate-500">
|
||||
AI-generated content for informational purposes. Verify timestamps on
|
||||
your copy.
|
||||
</footer>
|
||||
</main>
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user