Refactor database schema; add hunts and team_clues tables, update clues structure, and improve error handling in routes

This commit is contained in:
bobbert committed 2025-03-12 16:16:42 +00:00
1 parent 4f7fdc6ad2
commit 77e83dc21c
13 files changed
+136 -111

No files matched your search

+7 -5
View File
@@ -2,7 +2,8 @@ import { getServerSession } from "next-auth/next";
import { authOptions } from "../auth/[...nextauth]/route";
import { run } from "@/lib/db";
export async function POST(request) {
export async function POST() {
// Removed unused 'request' parameter
const session = await getServerSession(authOptions);
if (!session || session.user.role !== "admin") {
return new Response(JSON.stringify({ error: "Unauthorized" }), {
@@ -12,12 +13,13 @@ export async function POST(request) {
try {
// Add a WHERE clause or provide an ID if you're updating a specific hunt record
await run("UPDATE hunts SET active = 1, start_time = NOW() WHERE id = ?", [1]);
// Or if you just have one hunt record: "UPDATE hunts SET active = 1, start_time = NOW()"
await run("UPDATE hunts SET active = 1, start_time = NOW() WHERE id = ?", [
1,
]);
return new Response(JSON.stringify({ success: true }), { status: 200 });
} catch (err) {
console.error("Hunt start error:", err); // Add logging for better debugging
console.error("Hunt start error:", err);
return new Response(JSON.stringify({ error: err.message }), {
status: 500,
});