@tiledesk/tiledesk-server 2.7.0 → 2.7.1
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +5 -1
- package/config/labels/widget.json +257 -252
- package/deploy.sh +1 -1
- package/middleware/fetchLabels.js +23 -13
- package/package.json +1 -1
package/deploy.sh
CHANGED
@@ -4,20 +4,30 @@ var path = require('path');
|
|
4
4
|
var winston = require('../config/winston');
|
5
5
|
|
6
6
|
|
7
|
-
var labelsDir = __dirname+"/../config/labels/";
|
7
|
+
var labelsDir = __dirname + "/../config/labels/";
|
8
8
|
winston.debug('labelsDir: ' + labelsDir);
|
9
9
|
|
10
10
|
|
11
|
-
module.exports = function(req, res, next) {
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
11
|
+
module.exports = function (req, res, next) {
|
12
|
+
var filePath = path.join(labelsDir, 'widget.json');
|
13
|
+
|
14
|
+
fs.readFile(filePath, { encoding: 'utf-8' }, function (err, data) {
|
15
|
+
if (err) {
|
16
|
+
winston.error('Error getting labels', err);
|
17
|
+
return res.status(500).send({ success: false, msg: 'Error reading object.' });
|
18
|
+
}
|
19
|
+
winston.debug('label fetched', data);
|
20
|
+
|
21
|
+
// Replace {{ BRAND_NAME }} with process.env.BRAND_NAME value (default value "Tiledesk")
|
22
|
+
let brand_name = process.env.BRAND_NAME;
|
23
|
+
|
24
|
+
if (brand_name) {
|
25
|
+
data = data.replaceAll("Tiledesk", brand_name);
|
26
|
+
data = data.replaceAll("tiledesk", brand_name.toLowerCase());
|
27
|
+
|
28
|
+
}
|
29
|
+
|
30
|
+
req.labels = JSON.parse(data);
|
31
|
+
next();
|
32
|
+
});
|
23
33
|
}
|