-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
get the environment variables at runtime as opposed to build time
- Loading branch information
Showing
3 changed files
with
19 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,11 @@ | ||
import * as OneSignal from "@onesignal/node-onesignal"; | ||
|
||
export const ONESIGNAL_APP_ID = process.env.ONESIGNAL_APP_ID!; | ||
const ONESIGNAL_USER_AUTH_KEY = process.env.ONESIGNAL_USER_AUTH_KEY!; | ||
export const ONESIGNAL_API_KEY = process.env.ONESIGNAL_API_KEY!; | ||
|
||
if (!ONESIGNAL_API_KEY || !ONESIGNAL_APP_ID || !ONESIGNAL_USER_AUTH_KEY) { | ||
throw new Error("OneSignal environment variables not found"); | ||
// get the environment variables at runtime as opposed to build time | ||
export default function getOneSignalClient() { | ||
const oneSignalConfiguration = OneSignal.createConfiguration({ | ||
userAuthKey: process.env.ONESIGNAL_USER_AUTH_KEY!, | ||
restApiKey: process.env.ONESIGNAL_API_KEY!, | ||
}); | ||
|
||
return new OneSignal.DefaultApi(oneSignalConfiguration); | ||
} | ||
|
||
const oneSignalConfiguration = OneSignal.createConfiguration({ | ||
userAuthKey: ONESIGNAL_USER_AUTH_KEY, | ||
restApiKey: ONESIGNAL_API_KEY, | ||
}); | ||
|
||
export const oneSignalClient = new OneSignal.DefaultApi(oneSignalConfiguration); |