Skip to content

Commit e7800d5

Browse files
committed
remove unused api routes, code
1 parent 7f78bd0 commit e7800d5

8 files changed

Lines changed: 59 additions & 601 deletions

File tree

app/api/auth/login/route.ts

Lines changed: 0 additions & 177 deletions
This file was deleted.

app/api/cron/analytics-update/route.ts

Lines changed: 0 additions & 45 deletions
This file was deleted.

app/api/me/bootstrap/route.ts

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,21 @@ import crypto from "crypto";
2626
export const dynamic = "force-dynamic";
2727
export const runtime = "nodejs";
2828

29-
const FLAG_SECRET = process.env.FLAG_SECRET || "pbctf_default_secret_key_2026";
3029
const FLAG_PREFIX = "pbctf";
3130

3231
function generateFlag(sessionId: string): string {
32+
if (!process.env.FLAG_SECRET) {
33+
throw new Error("FLAG_SECRET is not configured");
34+
}
3335
const hmac = crypto
34-
.createHmac("sha256", FLAG_SECRET)
36+
.createHmac("sha256", process.env.FLAG_SECRET)
3537
.update(sessionId)
3638
.digest("hex");
3739
return `${FLAG_PREFIX}{${hmac.slice(0, 24)}}`;
3840
}
3941

4042
function isoIfDate(v: any) {
41-
return v instanceof Date ? v.toISOString() : v ?? null;
43+
return v instanceof Date ? v.toISOString() : (v ?? null);
4244
}
4345

4446
export async function GET(request: NextRequest) {
@@ -66,14 +68,16 @@ export async function GET(request: NextRequest) {
6668
]);
6769

6870
if (!user) {
69-
return NextResponse.json(
70-
{ message: "User not found" },
71-
{ status: 404 },
72-
);
71+
return NextResponse.json({ message: "User not found" }, { status: 404 });
7372
}
7473

75-
// Pre-compute the warm-up flag in parallel with everything else.
76-
const flag = generateFlag(uid);
74+
// Pre-compute the warm-up flag in parallel with everything else. If
75+
let flag: string | null = null;
76+
try {
77+
flag = generateFlag(uid);
78+
} catch (flagError) {
79+
console.error("bootstrap flag generation skipped:", flagError);
80+
}
7781

7882
// Phase 2: anything that depends on the user's teamCode.
7983
let team: any = null;
@@ -254,9 +258,6 @@ export async function GET(request: NextRequest) {
254258
});
255259
} catch (error: any) {
256260
console.error("bootstrap error:", error);
257-
return NextResponse.json(
258-
{ message: "Server error" },
259-
{ status: 500 },
260-
);
261+
return NextResponse.json({ message: "Server error" }, { status: 500 });
261262
}
262263
}

0 commit comments

Comments
 (0)