Phase 0: scaffold Next.js, Tailwind tokens, Supabase clients, env validation

Next.js 16 App Router with strict TypeScript, Tailwind 4 theme tokens from
docs/UI.md, Vitest, and the three Supabase clients. Env vars are validated
with zod in next.config.ts so dev and build fail fast with a readable error.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-03 12:27:11 +02:00
co-authored by Claude Opus 5.5
commit c89a82295b
29 changed files with 9107 additions and 0 deletions
+15
View File
@@ -0,0 +1,15 @@
import "server-only";
import { createClient } from "@supabase/supabase-js";
import { serverEnv } from "@/lib/env.server";
/**
* Service-role client. Bypasses RLS, so only call it from route handlers
* AFTER the scoreboard/judge token has been validated, and scope every query by that token.
*/
export function createAdminClient() {
return createClient(serverEnv.NEXT_PUBLIC_SUPABASE_URL, serverEnv.SUPABASE_SERVICE_ROLE_KEY, {
auth: { persistSession: false, autoRefreshToken: false },
});
}
+11
View File
@@ -0,0 +1,11 @@
import { createBrowserClient } from "@supabase/ssr";
import { publicEnv } from "@/lib/env.public";
/** Anon-key client for the browser: Realtime subscriptions + the admin auth session. */
export function createClient() {
return createBrowserClient(
publicEnv.NEXT_PUBLIC_SUPABASE_URL,
publicEnv.NEXT_PUBLIC_SUPABASE_ANON_KEY,
);
}
+33
View File
@@ -0,0 +1,33 @@
import "server-only";
import { createServerClient } from "@supabase/ssr";
import { cookies } from "next/headers";
import { publicEnv } from "@/lib/env.public";
/** Cookie-based client for admin server components/actions. RLS applies as the signed-in admin. */
export async function createClient() {
const cookieStore = await cookies();
return createServerClient(
publicEnv.NEXT_PUBLIC_SUPABASE_URL,
publicEnv.NEXT_PUBLIC_SUPABASE_ANON_KEY,
{
cookies: {
getAll() {
return cookieStore.getAll();
},
setAll(cookiesToSet) {
try {
cookiesToSet.forEach(({ name, value, options }) =>
cookieStore.set(name, value, options),
);
} catch {
// Server Components can't write cookies. Safe to ignore: the proxy
// refreshes the session cookie on every request.
}
},
},
},
);
}