This commit is contained in:
bobbert committed 2025-03-16 21:11:23 +00:00
1 parent d675b228c6
commit c5f2c0a98a
4 files changed
+189 -230

No files matched your search

+40
View File
@@ -0,0 +1,40 @@
import { queryOne } from "@/lib/db";
import { getToken } from "next-auth/jwt";
export const dynamic = "force-dynamic"; // No caching
export async function GET(request) {
try {
// Verify token
const token = await getToken({
req: request,
secret:
process.env.NEXTAUTH_SECRET ||
"your-fallback-secret-should-be-at-least-32-chars",
});
if (!token) {
return Response.json({ error: "Unauthorized access" }, { status: 401 });
}
// Get the total count of clues
const result = await queryOne("SELECT COUNT(*) as count FROM clues");
if (!result) {
return Response.json({ error: "Failed to count clues" }, { status: 500 });
}
return Response.json(
{ count: result.count },
{
headers: {
"Cache-Control": "no-store, no-cache, must-revalidate",
Pragma: "no-cache",
},
}
);
} catch (error) {
console.error("Error counting clues:", error);
return Response.json({ error: "Server error" }, { status: 500 });
}
}