mirror of
https://github.com/mudabbir-ahmad/peworkshop.git
synced 2026-10-07 19:50:20 +00:00
map WIP
This commit is contained in:
1 parent
d675b228c6
commit
c5f2c0a98a
4 files changed
+189
-230
No files matched your search
@@ -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 });
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user