From a1d48ceb64e1afdd98c922e188183108befbaec0 Mon Sep 17 00:00:00 2001 From: KKlochko Date: Thu, 18 Apr 2024 15:09:12 +0300 Subject: [PATCH] Add a function to get the SECRET enviroment variable. --- src/main/blog/env.cljs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/main/blog/env.cljs b/src/main/blog/env.cljs index f29856e..bddf7d4 100644 --- a/src/main/blog/env.cljs +++ b/src/main/blog/env.cljs @@ -7,6 +7,15 @@ (.-PORT)) "3000")) +(defn get-secret + "Gets the environment variable SECRET. If no variable, then the server will be crashed." + [] + (or (-> (.-env js/process) + (.-SECRET)) + (do + (js/console.log "[ERROR] Set enviroment variable SECRET!!!") + (js/process.exit 1)))) + (defn get-database-credentials "Gets the postgres credentials. Defaults: host - postgres, port - 5432, database - postgres, user - postgres, password - 'changeme!!!'." []