first commit

This commit is contained in:
2026-06-10 18:30:46 +02:00
parent 3e7b0ae2e0
commit cabd4803a4
39 changed files with 3635 additions and 81 deletions
+30
View File
@@ -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 },
);
}
}
+14
View File
@@ -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 },
);
}
+21
View File
@@ -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 },
);
}
}