From 35d78dc61750b1b33d3e895021abb491b763864f Mon Sep 17 00:00:00 2001 From: Liam Date: Mon, 20 Nov 2023 15:15:07 +0000 Subject: [PATCH] use environment when fetching infisical tokens --- src/secrets/secrets.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/secrets/secrets.ts b/src/secrets/secrets.ts index aa6a771..dec8b66 100644 --- a/src/secrets/secrets.ts +++ b/src/secrets/secrets.ts @@ -1,3 +1,4 @@ +import { GetOptions } from "infisical-node/src/types/InfisicalClient"; import { InfisicalClient } from ".."; let MONGO_URI: string; @@ -6,10 +7,18 @@ let MONGO_URI: string; * Initialize the secrets */ export async function initSecrets() { - const mongoUri = (await InfisicalClient.getSecret("MONGO_URI")).secretValue; + const options: GetOptions = { + environment: process.env.NODE_ENV === "production" ? "main" : "dev", + path: "/", + type: "shared", + }; + + const mongoUri = (await InfisicalClient.getSecret("MONGO_URI", options)) + .secretValue; if (!mongoUri) { - throw new Error("MONGO_URI not set in secrets"); + console.log("MONGO_URI not set in secrets"); + process.exit(1); } MONGO_URI = mongoUri;