File tree Expand file tree Collapse file tree
app/api/calculate-leaderboard Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ GITHUB_DISCUSSION_COUNT=10
1212
1313# Leaderboard source data
1414LEADERBOARD_SOURCE_URL_TEMPLATE = https://raw.githubusercontent.com/ashkulz/committers.top/gh-pages/_data/locations/{country}.yml
15+ DISABLE_CALCULATE_LEADERBOARD_ENDPOINT = false
1516
1617# Redis caching (optional — strongly recommended for leaderboard performance)
1718# Use either redis://localhost:6379 or include password if enabled: redis://:password@localhost:6379
@@ -24,4 +25,4 @@ REDIS_CONNECT_TIMEOUT_MS=1500
2425
2526# ── PostgreSQL (local development) ─────────────────
2627DATABASE_URL = postgresql://devimpact:devimpact@localhost:5432/devimpact?sslmode=disable
27- POSTGRES_PASSWORD = CHANGE_THIS_TO_A_LONG_RANDOM_PASSWORD
28+ POSTGRES_PASSWORD = CHANGE_THIS_TO_A_LONG_RANDOM_PASSWORD
Original file line number Diff line number Diff line change @@ -3,7 +3,20 @@ import { calculateLeaderboard } from "@/lib/calculate-leaderboard";
33
44export const runtime = "nodejs" ;
55
6+ function isCalculateLeaderboardDisabled ( ) : boolean {
7+ const raw =
8+ process . env . DISABLE_CALCULATE_LEADERBOARD_ENDPOINT ?. trim ( ) . toLowerCase ( ) ;
9+ return raw === "true" || raw === "1" || raw === "yes" ;
10+ }
11+
612export async function POST ( request : Request ) {
13+ if ( isCalculateLeaderboardDisabled ( ) ) {
14+ return NextResponse . json (
15+ { success : false , error : "Not found" } ,
16+ { status : 404 } ,
17+ ) ;
18+ }
19+
720 const { searchParams } = new URL ( request . url ) ;
821 const country = searchParams . get ( "country" ) ?. trim ( ) ;
922
@@ -26,4 +39,4 @@ export async function POST(request: Request) {
2639 { status : 502 } ,
2740 ) ;
2841 }
29- }
42+ }
You can’t perform that action at this time.
0 commit comments