Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: Build

on:
push:
branches: ['*']
branches: ["*"]
pull_request:
branches: ['*']
branches: ["*"]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand All @@ -23,7 +23,7 @@ jobs:
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'npm'
cache: "npm"

- name: Install dependencies
run: npm ci
Expand All @@ -35,7 +35,6 @@ jobs:
CLOUDINARY_API_SECRET: ${{ secrets.CLOUDINARY_API_SECRET }}
CLOUDINARY_CLOUD_NAME: ${{ secrets.CLOUDINARY_CLOUD_NAME }}
EVALUATOR_CODE: ${{ secrets.EVALUATOR_CODE }}
METRICS_API_TOKEN: ${{ secrets.METRICS_API_TOKEN }}
MONGODB_URI: ${{ secrets.MONGODB_URI }}
NEXT_PUBLIC_FIREBASE_API_KEY: ${{ secrets.NEXT_PUBLIC_FIREBASE_API_KEY }}
NEXT_PUBLIC_FIREBASE_APP_ID: ${{ secrets.NEXT_PUBLIC_FIREBASE_APP_ID }}
Expand Down
177 changes: 0 additions & 177 deletions app/api/auth/login/route.ts

This file was deleted.

45 changes: 0 additions & 45 deletions app/api/cron/analytics-update/route.ts

This file was deleted.

27 changes: 14 additions & 13 deletions app/api/me/bootstrap/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,21 @@ import crypto from "crypto";
export const dynamic = "force-dynamic";
export const runtime = "nodejs";

const FLAG_SECRET = process.env.FLAG_SECRET || "pbctf_default_secret_key_2026";
const FLAG_PREFIX = "pbctf";

function generateFlag(sessionId: string): string {
if (!process.env.FLAG_SECRET) {
throw new Error("FLAG_SECRET is not configured");
}
const hmac = crypto
.createHmac("sha256", FLAG_SECRET)
.createHmac("sha256", process.env.FLAG_SECRET)
.update(sessionId)
.digest("hex");
return `${FLAG_PREFIX}{${hmac.slice(0, 24)}}`;
}

function isoIfDate(v: any) {
return v instanceof Date ? v.toISOString() : v ?? null;
return v instanceof Date ? v.toISOString() : (v ?? null);
}

export async function GET(request: NextRequest) {
Expand Down Expand Up @@ -66,14 +68,16 @@ export async function GET(request: NextRequest) {
]);

if (!user) {
return NextResponse.json(
{ message: "User not found" },
{ status: 404 },
);
return NextResponse.json({ message: "User not found" }, { status: 404 });
}

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

// Phase 2: anything that depends on the user's teamCode.
let team: any = null;
Expand Down Expand Up @@ -254,9 +258,6 @@ export async function GET(request: NextRequest) {
});
} catch (error: any) {
console.error("bootstrap error:", error);
return NextResponse.json(
{ message: "Server error" },
{ status: 500 },
);
return NextResponse.json({ message: "Server error" }, { status: 500 });
}
}
Loading
Loading