Skip to content

Commit a91a94a

Browse files
authored
Remove Unused Routes (#30)
* feat(auth): implement Google sign-in and linking with password accounts * Change Contact Mail ID * use request-ip * remove unused api routes, code * Fix data not getting re-rendered
1 parent 23e1331 commit a91a94a

11 files changed

Lines changed: 86 additions & 609 deletions

File tree

.github/workflows/build.yaml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ name: Build
22

33
on:
44
push:
5-
branches: ['*']
5+
branches: ["*"]
66
pull_request:
7-
branches: ['*']
7+
branches: ["*"]
88

99
concurrency:
1010
group: ${{ github.workflow }}-${{ github.ref }}
@@ -23,7 +23,7 @@ jobs:
2323
uses: actions/setup-node@v4
2424
with:
2525
node-version: 20
26-
cache: 'npm'
26+
cache: "npm"
2727

2828
- name: Install dependencies
2929
run: npm ci
@@ -35,7 +35,6 @@ jobs:
3535
CLOUDINARY_API_SECRET: ${{ secrets.CLOUDINARY_API_SECRET }}
3636
CLOUDINARY_CLOUD_NAME: ${{ secrets.CLOUDINARY_CLOUD_NAME }}
3737
EVALUATOR_CODE: ${{ secrets.EVALUATOR_CODE }}
38-
METRICS_API_TOKEN: ${{ secrets.METRICS_API_TOKEN }}
3938
MONGODB_URI: ${{ secrets.MONGODB_URI }}
4039
NEXT_PUBLIC_FIREBASE_API_KEY: ${{ secrets.NEXT_PUBLIC_FIREBASE_API_KEY }}
4140
NEXT_PUBLIC_FIREBASE_APP_ID: ${{ secrets.NEXT_PUBLIC_FIREBASE_APP_ID }}

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)