mirror of
https://github.com/privacy-scaling-explorations/pse.dev.git
synced 2026-01-08 21:58:05 -05:00
31 lines
1.0 KiB
TypeScript
31 lines
1.0 KiB
TypeScript
import { getProjects } from "@/lib/content"
|
|
import { NextRequest, NextResponse } from "next/server"
|
|
|
|
// Cache control - Extended for better performance
|
|
export const revalidate = 1800 // Revalidate cache after 30 minutes
|
|
export const dynamic = "force-dynamic" // Ensure the route is always evaluated
|
|
|
|
export async function GET(request: NextRequest) {
|
|
const { searchParams } = new URL(request.url)
|
|
const tag = searchParams.get("tag") || undefined
|
|
const limit = searchParams.get("limit")
|
|
? parseInt(searchParams.get("limit") as string, 10)
|
|
: undefined
|
|
const status = searchParams.get("status") || undefined
|
|
|
|
try {
|
|
const projects = getProjects({ tag, limit, status })
|
|
return NextResponse.json(projects ?? [], {
|
|
headers: {
|
|
"Cache-Control": "public, s-maxage=1800, stale-while-revalidate=3600",
|
|
},
|
|
})
|
|
} catch (error) {
|
|
console.error("Error fetching projects:", error)
|
|
return NextResponse.json(
|
|
{ error: "Failed to fetch projects", success: false },
|
|
{ status: 500 }
|
|
)
|
|
}
|
|
}
|