aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2022-10-29 23:54:47 +0300
committerGravatar Vitaly Takmazov2023-01-13 10:37:58 +0300
commit3df035b7ddc002bf5c758419a33f5c2f369716bd (patch)
tree37a6af6c9fdf4887b15181de4256fa646fae5223
parent47218df561e877265c739ffab59b760318ea3143 (diff)
Use config settings
-rw-r--r--vnext/package-lock.json20
-rw-r--r--vnext/package.json1
-rw-r--r--vnext/server/sender.js18
3 files changed, 33 insertions, 6 deletions
diff --git a/vnext/package-lock.json b/vnext/package-lock.json
index d5f4a897..abd6c896 100644
--- a/vnext/package-lock.json
+++ b/vnext/package-lock.json
@@ -12,6 +12,7 @@
"@babel/register": "^7.18.9",
"axios": "^1.1.3",
"axios-cache-interceptor": "^0.10.7",
+ "config": "^3.3.8",
"core-js": "^3.26.0",
"cors": "^2.8.5",
"evil-icons": "^1.10.1",
@@ -5512,6 +5513,17 @@
"integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=",
"dev": true
},
+ "node_modules/config": {
+ "version": "3.3.8",
+ "resolved": "https://registry.npmjs.org/config/-/config-3.3.8.tgz",
+ "integrity": "sha512-rFzF6VESOdp7wAXFlB9IOZI4ouL05g3A03v2eRcTHj2JBQaTNJ40zhAUl5wRbWHqLZ+uqp/7OE0BWWtAVgrong==",
+ "dependencies": {
+ "json5": "^2.2.1"
+ },
+ "engines": {
+ "node": ">= 10.0.0"
+ }
+ },
"node_modules/connect-history-api-fallback": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/connect-history-api-fallback/-/connect-history-api-fallback-2.0.0.tgz",
@@ -21547,6 +21559,14 @@
"integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=",
"dev": true
},
+ "config": {
+ "version": "3.3.8",
+ "resolved": "https://registry.npmjs.org/config/-/config-3.3.8.tgz",
+ "integrity": "sha512-rFzF6VESOdp7wAXFlB9IOZI4ouL05g3A03v2eRcTHj2JBQaTNJ40zhAUl5wRbWHqLZ+uqp/7OE0BWWtAVgrong==",
+ "requires": {
+ "json5": "^2.2.1"
+ }
+ },
"connect-history-api-fallback": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/connect-history-api-fallback/-/connect-history-api-fallback-2.0.0.tgz",
diff --git a/vnext/package.json b/vnext/package.json
index afa50bbd..41e26972 100644
--- a/vnext/package.json
+++ b/vnext/package.json
@@ -78,6 +78,7 @@
"@babel/register": "^7.18.9",
"axios": "^1.1.3",
"axios-cache-interceptor": "^0.10.7",
+ "config": "^3.3.8",
"core-js": "^3.26.0",
"cors": "^2.8.5",
"evil-icons": "^1.10.1",
diff --git a/vnext/server/sender.js b/vnext/server/sender.js
index 6d88c4c0..6ece8eaa 100644
--- a/vnext/server/sender.js
+++ b/vnext/server/sender.js
@@ -2,34 +2,40 @@ import PushNotifications from 'node-pushnotifications';
var debug = require('debug')('sender');
import { deleteSubscribers } from './http';
import { formatMessage, formatTitle, formatQuote } from './common/MessageUtils';
+import config from 'config';
+
+let cfg = /** @type { import('node-pushnotifications').Settings } */ (config);
const apnConfig = (production = true) => {
const apn = {
+ ...cfg.apn,
token: {
- key: process.env.JUICK_APN_KEY,
- keyId: process.env.JUICK_APN_KEY_ID,
- teamId: process.env.JUICK_APN_TEAM_ID
+ key: cfg.apn?.token?.key || process.env.JUICK_APN_KEY,
+ keyId: cfg.apn?.token?.keyId || process.env.JUICK_APN_KEY_ID,
+ teamId: cfg.apn?.token?.teamId || process.env.JUICK_APN_TEAM_ID
},
production: production
};
return apn;
};
const gcmConfig = {
- id: process.env.JUICK_GCM_ID
+ ...cfg.gcm,
+ id: cfg.gcm?.id || process.env.JUICK_GCM_ID
};
const push = new PushNotifications({
+ ...config,
apn: apnConfig(true),
gcm: gcmConfig,
});
const sandbox = new PushNotifications({
+ ...config,
apn: apnConfig(false),
gcm: gcmConfig
});
/** @type {string} */
-const application = process.env.JUICK_APN_APPLICATION || '';
-
+const application = config.get('service.application') || process.env.JUICK_APN_APPLICATION || '';
/**
* send notification