Back-office (roadmap V1 step 7): - server: token-protected HTTP API under /api/admin (ADMIN_TOKEN), Drizzle-backed CRUD for manual questions — list, create (mcq/truefalse/free, category upsert, dedup on prompt, validation), delete; 401/503 when unauthorized/unconfigured - client: /admin page with token login + TanStack Query (list/create/delete), format-aware form (QCM / vrai-faux / réponse libre) - env: ADMIN_TOKEN README: replace the shadcn template with a real NerdWare overview (stack, structure, getting started, scripts, game modes, back-office). Verified against real Postgres: auth (401), create (201), dedup (409), validation (400), list, delete (200/404). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
24 lines
955 B
TypeScript
24 lines
955 B
TypeScript
// Configuration lue depuis l'environnement. Bun charge .env automatiquement.
|
|
// Secrets (YouTube, DB) viendront s'ajouter ici — jamais en dur.
|
|
|
|
function num(value: string | undefined, fallback: number): number {
|
|
const parsed = Number(value)
|
|
return Number.isFinite(parsed) ? parsed : fallback
|
|
}
|
|
|
|
export const env = {
|
|
nodeEnv: process.env.NODE_ENV ?? "development",
|
|
host: process.env.HOST ?? "0.0.0.0",
|
|
port: num(process.env.PORT, 3001),
|
|
/** Connexion PostgreSQL. Vide → pas de DB, fallback banque en dur. */
|
|
databaseUrl: process.env.DATABASE_URL ?? "",
|
|
/** Jeton du back-office quiz. Vide → back-office désactivé. */
|
|
adminToken: process.env.ADMIN_TOKEN ?? "",
|
|
/** Origines autorisées pour CORS / Socket.IO (séparées par des virgules). */
|
|
corsOrigins: (process.env.CORS_ORIGINS ?? "http://localhost:5173")
|
|
.split(",")
|
|
.map((o) => o.trim())
|
|
.filter(Boolean),
|
|
}
|
|
|
|
export const isDev = env.nodeEnv !== "production"
|