Skip to content
Snippets Groups Projects
Select Git revision
  • dedf48141291fa3e997e1b8632c75342cb14b2c6
  • master default protected
  • 365-ouvrir-l-onglet-employeur-ou-taxes-carburant-quand-c-est-le-cas-pour-un-dispositif
  • 381-pb-affichage-labels-des-parametres-sur-plus-de-3-lignes
  • ajoute-duplicate-aide-logement
  • poc_castype_ia
  • parametres-editables-budget
  • ui-parametres
  • 366-signe-a-cote-du-droit-en-vigueur-sur-l-ui-pour-indiquer-que-la-reforme-a-eu-lieu-mais-qu-elle-n
  • 355-les-dispositifs-prestations-sociales-du-graphique-se-cachent-montrent-en-meme-temps-2
  • 358-les-variables-dont-le-montant-est-nul-apparaissent-en-bleu-et-non-cliquables
  • 356-ajuster-la-largeur-sur-les-graphiques-budgetaires
  • incoherence_cas_type_0
  • fix-ui-suppression-tranches-baremes
  • ajout-agregat-cehr-version-plf
  • impact_carbone
  • xlsx
  • header_revamp
  • 270-concevoir-la-page-d-accueil-leximpact
  • 219-conversion-des-montants-min-et-max-de-l-axe-des-x-en-smic
  • 294-afficher-le-salaire-des-cas-types-en-nombre-de-smic
  • 0.0.1124
  • 0.0.1123
  • 0.0.1122
  • 0.0.1121
  • 0.0.1120
  • 0.0.1119
  • 0.0.1118
  • 0.0.1117
  • 0.0.1116
  • 0.0.1115
  • 0.0.1114
  • 0.0.1113
  • 0.0.1112
  • 0.0.1111
  • 0.0.1110
  • 0.0.1109
  • 0.0.1108
  • 0.0.1107
  • 0.0.1106
  • 0.0.1105
41 results

hooks.server.ts

Blame
  • server_config.ts 1.73 KiB
    import {
      ALLOW_ROBOTS,
      BUDGET_API_URL,
      BUDGET_DEMAND_PIPELINE_URL,
      BUDGET_DEMAND_PIPELINE_TOKEN,
      BUDGET_JWT_SECRET,
      GITHUB_PERSONAL_ACCESS_TOKEN,
      JWT_SECRET,
      OPENID_CONNECT_CLIENT_ID,
      OPENID_CONNECT_CLIENT_SECRET,
      OPENID_CONNECT_ISSUER_URL,
      SIMULATIONS_BUDGET_DIR,
      SIMULATIONS_TEST_CASES_DIR,
    } from "$env/static/private"
    import { validateServerConfig } from "$lib/server/auditors/server_config"
    
    export interface ServerConfig {
      allowRobots: boolean
      budgetApiUrl?: string
      budgetDemandPipelineUrl?: string
      budgetDemandPipelineToken?: string
      budgetJwtSecret?: string
      githubPersonalAccessToken?: string
      jwtSecret: string
      openIdConnect?: {
        clientId: string
        clientSecret: string
        issuerUrl: string
      }
      simulationsBudgetDir: string
      simulationsTestCasesDir: string
    }
    
    const [validConfig, error] = validateServerConfig({
      allowRobots: ALLOW_ROBOTS,
      budgetApiUrl: BUDGET_API_URL,
      budgetDemandPipelineUrl: BUDGET_DEMAND_PIPELINE_URL,
      budgetDemandPipelineToken: BUDGET_DEMAND_PIPELINE_TOKEN,
      budgetJwtSecret: BUDGET_JWT_SECRET,
      githubPersonalAccessToken: GITHUB_PERSONAL_ACCESS_TOKEN,
      jwtSecret: JWT_SECRET,
      openIdConnect: OPENID_CONNECT_CLIENT_ID
        ? {
            clientId: OPENID_CONNECT_CLIENT_ID,
            clientSecret: OPENID_CONNECT_CLIENT_SECRET,
            issuerUrl: OPENID_CONNECT_ISSUER_URL,
          }
        : null,
      simulationsBudgetDir: SIMULATIONS_BUDGET_DIR,
      simulationsTestCasesDir: SIMULATIONS_TEST_CASES_DIR,
    }) as [ServerConfig, unknown]
    if (error !== null) {
      console.error(
        `Error in configuration:\n${JSON.stringify(
          validConfig,
          null,
          2,
        )}\nError:\n${JSON.stringify(error, null, 2)}`,
      )
      process.exit(-1)
    }
    const serverConfig = validConfig
    
    export default serverConfig