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}`));