From 4e8ff4d8a35172c70e0301ba1f4711d39fdb74ed Mon Sep 17 00:00:00 2001 From: Martin Berka Date: Tue, 13 Jun 2023 22:30:55 +0200 Subject: [PATCH] =?UTF-8?q?Podpora=20na=C4=8D=C3=ADt=C3=A1n=C3=AD=20.env?= =?UTF-8?q?=20na=20serveru=20dle=20prost=C5=99ed=C3=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/src/notifikace.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/server/src/notifikace.ts b/server/src/notifikace.ts index d2546f7..efd984b 100644 --- a/server/src/notifikace.ts +++ b/server/src/notifikace.ts @@ -2,9 +2,14 @@ import axios, {AxiosError, AxiosResponse} from 'axios'; import {GotifyServer, NotififaceInput, NotifikaceData, UdalostEnum} from "./types"; import dotenv from 'dotenv'; -dotenv.config() +import path from 'path'; + +const ENVIRONMENT = process.env.NODE_ENV || 'production' +dotenv.config({ path: path.resolve(__dirname, `../.env.${ENVIRONMENT}`) }); + const gotifyDataRaw = process.env.GOTIFY_SERVERS_AND_KEYS || "{}"; const gotifyData: GotifyServer[] = JSON.parse(gotifyDataRaw); + export const gotifyCall = async (data: NotififaceInput, gotifyServers: GotifyServer[]): Promise => { const urls = gotifyServers.flatMap(gotifyServer => gotifyServer.api_keys.map(apiKey => `${gotifyServer.server}/message?token=${apiKey}`));