From 7f3a70c396b498a8b10553d11cf78c3ea9a872b1 Mon Sep 17 00:00:00 2001 From: Jan Tuomi Date: Mon, 19 Apr 2021 14:51:34 +0300 Subject: Should be ready now --- src/config.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/config.ts') diff --git a/src/config.ts b/src/config.ts index 962fd49..8766db9 100644 --- a/src/config.ts +++ b/src/config.ts @@ -1,4 +1,6 @@ import dotenv from "dotenv"; +import fs from "fs"; +import path from "path"; if (!process.env.SKIP_DOTENV) { dotenv.config(); @@ -36,6 +38,17 @@ if (!pgConnectionUri) { throw new ConfigError("Missing env var PG_CONNECTION_URI"); } +const googleSaJsonB64 = process.env.G_SA_JSON_B64 || null; +if (!googleSaJsonB64) { + throw new ConfigError("Missing env var G_SA_JSON_B64"); +} + +const googleSaJsonBuff = Buffer.from(googleSaJsonB64, "base64"); +const googleSaJsonUtf8 = googleSaJsonBuff.toString("utf-8"); +const googleSaJson: Record = JSON.parse(googleSaJsonUtf8); +const googleSaJsonPath = path.join("sa_key.json"); +fs.writeFileSync(googleSaJsonPath, googleSaJsonUtf8); + const config = { port: process.env.PORT ? Number(process.env.PORT) : 3000, tgWebhookUrl, @@ -43,6 +56,8 @@ const config = { sheetsSpreadsheetId, sheetsRange, pgConnectionUri, + googleSaJson, + googleSaJsonPath, }; export default config; -- cgit v1.3