All checks were successful
Build and Push Docker Image / build-and-push (push) Successful in 28s
26 lines
839 B
TypeScript
26 lines
839 B
TypeScript
import { NextResponse } from "next/server";
|
|
import { getAllPosts } from "@/lib/blog";
|
|
|
|
export const dynamic = "force-dynamic";
|
|
|
|
export async function GET(request: Request) {
|
|
console.log("[API] 🌐 GET /api/blog - Request received");
|
|
try {
|
|
const { searchParams } = new URL(request.url);
|
|
const category = searchParams.get("category") as "case-study" | "blog" | null;
|
|
console.log("[API] 📋 Parameters:", { category });
|
|
|
|
const posts = await getAllPosts(category || undefined);
|
|
console.log("[API] ✅ Response ready:", { count: posts.length });
|
|
|
|
return NextResponse.json({
|
|
success: true,
|
|
posts,
|
|
count: posts.length,
|
|
});
|
|
} catch (error) {
|
|
console.error("[API] ❌ Error:", error);
|
|
return NextResponse.json({ success: false, error: "Failed to fetch posts" }, { status: 500 });
|
|
}
|
|
}
|