SPB Git

Repository Public

config.ts 3.8 KB 83 lines typescript

1/**2 * =============================================================================3 *                  SP BOUCHER | SOFTWARE & RESEARCH4 *             ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING5 * =============================================================================6 *7 * Project          : UQO Éval — Le Grand Défi Immobilier8 * File             : apps/api/src/config.ts9 * Module           : api10 * Repository       : https://git.spboucher.ai/uqo-eval-jeux11 * Project Website  : https://jeux.uqo-eval.app12 * Created          : 2026-11-2513 * Last Modified    : 2026-11-2514 *15 * Author           : Simon-Pierre Boucher16 * Position         : Professor of Finance17 * Institution      : Université du Québec en Outaouais (UQO)18 * Organization     : SP Boucher19 * Website          : https://spboucher.ai20 * Git              : https://git.spboucher.ai21 *22 * Preferred Contact: contact@spboucher.ai23 * Development      : dev@spboucher.ai24 * Support          : support@spboucher.ai25 * Security/Admin   : admin@spboucher.ai26 *27 * Copyright (c) 202628 * Simon-Pierre Boucher29 * All rights reserved where applicable. This file is governed by the30 * applicable project license, copyright notices and relevant law.31 * Existing third-party rights and notices remain unaffected.32 *33 * License          : None specified (no license file in this repository)34 *35 * Do not embed credentials, private keys, access tokens,36 * certificates or confidential personal information.37 *38 * =============================================================================39 * END OF SP BOUCHER SOURCE HEADER40 * =============================================================================41 */4243/** Configuration lue dans l'environnement. Aucun secret n'est transmis à l'interface. */44import path from "node:path";4546function required(name: string, fallback?: string): string {47  const value = process.env[name] || fallback;48  if (value === undefined || value === "") throw new Error(`Variable d'environnement manquante : ${name}`);49  return value;50}5152const isProduction = process.env.NODE_ENV === "production";53const root = path.resolve(import.meta.dirname, "../../..");5455export const config = {56  isProduction,57  root,58  appName: process.env.APP_NAME ?? "UQO ÉVAL — Le Grand Défi Immobilier",59  appUrl: process.env.APP_URL ?? "http://localhost:8080",60  host: process.env.HOST ?? "0.0.0.0",61  port: Number(process.env.PORT ?? 8080),62  databaseUrl: required("DATABASE_URL", isProduction ? undefined : "postgres://localhost/uqo_jeux_dev"),63  /** Base d'inscriptions immobilières, ouverte en lecture seule. */64  listingsDbPath: process.env.LISTINGS_DB_PATH ?? path.join(root, "data/dev/listings.db"),65  imageStoragePath: process.env.IMAGE_STORAGE_PATH ?? path.join(root, "data/images"),66  backupPath: process.env.BACKUP_PATH ?? path.join(root, "data/backups"),67  webDist: process.env.WEB_DIST ?? path.join(root, "apps/web/dist"),68  /** Clé de hachage des jetons, des codes de reprise et des adresses IP. */69  sessionSecret: required("SESSION_SECRET", isProduction ? undefined : "dev-secret-ne-pas-utiliser-en-production"),70  /** Clé du lien d'administration. Vide = administration ouverte (développement seulement). */71  adminKey: process.env.ADMIN_KEY ?? "",72  publicLeaderboard: (process.env.PUBLIC_LEADERBOARD_ENABLED ?? "true") !== "false",73  defaultCompetitionSize: Number(process.env.DEFAULT_COMPETITION_SIZE ?? 100),74  /** Durée de conservation des renseignements personnels, en jours (0 = illimitée). */75  retentionDays: Number.isFinite(Number(process.env.RETENTION_DAYS ?? 400)) ? Number(process.env.RETENTION_DAYS ?? 400) : 400,76  noticeVersion: "2026-11",77  logLevel: process.env.LOG_LEVEL ?? "info",78};7980if (isProduction && !config.adminKey) {81  throw new Error("ADMIN_KEY est obligatoire en production : l'administration contient des renseignements personnels.");82}83
Files main
Menu

Theme