From b2dcaeeb2db1314becddd1c7636c6ecbb9c23cdd Mon Sep 17 00:00:00 2001
From: Emmanuel Raviart <emmanuel@raviart.com>
Date: Wed, 13 Sep 2023 13:32:26 +0200
Subject: [PATCH] WIP

---
 example.env                       |  3 ++-
 src/lib/server/auditors/config.ts | 11 +++--------
 src/lib/server/config.ts          |  2 ++
 3 files changed, 7 insertions(+), 9 deletions(-)

diff --git a/example.env b/example.env
index 4d1de3e19..422403a34 100644
--- a/example.env
+++ b/example.env
@@ -17,7 +17,8 @@ BASE_URL="http://localhost:5173"
 # Private (for connected users) HTTP(S) URL of LexImpact Socio-Fiscal Budget server
 # BUDGET_API_URL="https://SECRET.DOMAIN.NAME/state_simulation"
 
-# Public HTTP(S) URL of LexImpact Socio-Fiscal Budget server
+# URL of GitLab pipeline to run when a non-authentication user requests a budget simulation
+# BUDGET_DEMAND_PIPELINE_URL="https://GITLAB.DOMAIN.NAME/api/v4/projects/PROJECT_ID/pipeline?ref=main"
 
 # Secret key used to sign JSON web tokens sent to Budget API
 # BUDGET_JWT_SECRET="SECRET"
diff --git a/src/lib/server/auditors/config.ts b/src/lib/server/auditors/config.ts
index 4603fec64..913dca17a 100644
--- a/src/lib/server/auditors/config.ts
+++ b/src/lib/server/auditors/config.ts
@@ -65,14 +65,9 @@ export function auditConfig(
       auditRequire,
     )
   }
-  audit.attribute(
-    data,
-    "budgetApiUrl",
-    true,
-    errors,
-    remainingKeys,
-    auditHttpUrl,
-  )
+  for (const key of ["budgetApiUrl", "budgetDemandPipelineUrl"]) {
+    audit.attribute(data, key, true, errors, remainingKeys, auditHttpUrl)
+  }
   for (const key of [
     "childrenKey",
     "familyEntityKey",
diff --git a/src/lib/server/config.ts b/src/lib/server/config.ts
index 2abbd37ae..c23d480b0 100644
--- a/src/lib/server/config.ts
+++ b/src/lib/server/config.ts
@@ -10,6 +10,7 @@ export interface Config {
   apiWebSocketBaseUrls: string[]
   baseUrl: string
   budgetApiUrl?: string
+  budgetDemandPipelineUrl?: string
   budgetJwtSecret?: string
   childrenKey: string
   familyEntityKey: string
@@ -48,6 +49,7 @@ const [validConfig, error] = validateConfig({
   apiBaseUrls: process.env["API_BASE_URLS"],
   baseUrl: process.env["BASE_URL"],
   budgetApiUrl: process.env["BUDGET_API_URL"],
+  budgetDemandPipelineUrl: process.env["BUDGET_DEMAND_PIPELINE_URL"],
   budgetJwtSecret: process.env["BUDGET_JWT_SECRET"],
   childrenKey: process.env["CHILDREN_KEY"],
   familyEntityKey: process.env["FAMILY_KEY"],
-- 
GitLab