mirror of
https://github.com/mudabbir-ahmad/peworkshop.git
synced 2026-10-07 19:50:20 +00:00
Refactor database schema; add hunts and team_clues tables, update clues structure, and improve error handling in routes
This commit is contained in:
1 parent
4f7fdc6ad2
commit
77e83dc21c
13 files changed
+136
-111
No files matched your search
@@ -2,7 +2,8 @@ import { query, queryOne } from "@/lib/db";
|
||||
import { getServerSession } from "next-auth/next";
|
||||
import { authOptions } from "../../auth/[...nextauth]/route";
|
||||
|
||||
export async function GET(request, context) {
|
||||
export async function GET(_, context) {
|
||||
// Changed 'request' to '_' to indicate unused parameter
|
||||
const session = await getServerSession(authOptions);
|
||||
|
||||
if (!session) {
|
||||
@@ -11,7 +12,7 @@ export async function GET(request, context) {
|
||||
|
||||
try {
|
||||
const teamId = context.params.teamId;
|
||||
|
||||
|
||||
// Validate teamId
|
||||
if (!teamId || isNaN(parseInt(teamId, 10))) {
|
||||
return Response.json({ error: "Invalid team ID" }, { status: 400 });
|
||||
@@ -24,16 +25,18 @@ export async function GET(request, context) {
|
||||
}
|
||||
|
||||
const members = await query(
|
||||
"SELECT id, username FROM users WHERE team_id = ?",
|
||||
"SELECT id, username FROM users WHERE team_id = ?",
|
||||
[teamId]
|
||||
);
|
||||
|
||||
return Response.json({
|
||||
success: true,
|
||||
team,
|
||||
members
|
||||
}, { status: 200 });
|
||||
|
||||
return Response.json(
|
||||
{
|
||||
success: true,
|
||||
team,
|
||||
members,
|
||||
},
|
||||
{ status: 200 }
|
||||
);
|
||||
} catch (error) {
|
||||
console.error("Team fetch error:", error);
|
||||
return Response.json(
|
||||
|
||||
Reference in new issue
Block a user