cloudcms-server 0.9.253 → 0.9.256

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,7 @@
1
1
  var path = require("path");
2
2
  var redis = require("redis");
3
3
  var logFactory = require("../../util/logger");
4
+ var redisHelper = require("../../util/redis");
4
5
 
5
6
  /**
6
7
  * Redis lock service.
@@ -38,31 +39,9 @@ exports = module.exports = function(locksConfig)
38
39
 
39
40
  r.init = function(callback)
40
41
  {
41
- var redisPort = locksConfig.port;
42
- if (typeof(redisPort) === "undefined" || !redisPort)
43
- {
44
- redisPort = process.env.CLOUDCMS_LOCKS_REDIS_PORT;
45
- }
46
- if (typeof(redisPort) === "undefined" || !redisPort)
47
- {
48
- redisPort = process.env.CLOUDCMS_REDIS_PORT;
49
- }
50
-
51
- var redisEndpoint = locksConfig.endpoint;
52
- if (typeof(redisEndpoint) === "undefined" || !redisEndpoint)
53
- {
54
- redisEndpoint = process.env.CLOUDCMS_LOCKS_REDIS_ENDPOINT;
55
- }
56
- if (typeof(redisEndpoint) === "undefined" || !redisEndpoint)
57
- {
58
- redisEndpoint = process.env.CLOUDCMS_REDIS_ENDPOINT;
59
- }
60
-
61
- var redisOptions = {};
62
-
63
- //redis.debug_mode = true;
64
-
65
- client = redis.createClient(redisPort, redisEndpoint, redisOptions);
42
+ var redisOptions = redisHelper.redisOptions(locksConfig, "CLOUDCMS_LOCKS");
43
+
44
+ client = redis.createClient(redisOptions);
66
45
 
67
46
  callback();
68
47
  };
@@ -4,6 +4,7 @@ var redis = require("redis");
4
4
  var async = require("async");
5
5
 
6
6
  var logFactory = require("../../../util/logger");
7
+ var redisHelper = require("../../../util/redis");
7
8
 
8
9
  class RedisProvider extends AbstractAsyncProvider
9
10
  {
@@ -30,30 +31,10 @@ class RedisProvider extends AbstractAsyncProvider
30
31
  init(callback)
31
32
  {
32
33
  var self = this;
34
+
35
+ var redisOptions = redisHelper.redisOptions(this.config, "CLOUDCMS_AWARENESS");
33
36
 
34
- var redisPort = this.config.port;
35
- if (typeof(redisPort) === "undefined" || !redisPort)
36
- {
37
- redisPort = process.env.CLOUDCMS_AWARENESS_REDIS_PORT;
38
- }
39
- if (typeof(redisPort) === "undefined" || !redisPort)
40
- {
41
- redisPort = process.env.CLOUDCMS_REDIS_PORT;
42
- }
43
-
44
- var redisHost = this.config.host;
45
- if (typeof(redisHost) === "undefined" || !redisHost)
46
- {
47
- redisHost = process.env.CLOUDCMS_AWARENESS_REDIS_ENDPOINT;
48
- }
49
- if (typeof(redisHost) === "undefined" || !redisHost)
50
- {
51
- redisHost = process.env.CLOUDCMS_REDIS_ENDPOINT;
52
- }
53
-
54
- var redisOptions = {};
55
-
56
- this.client = redis.createClient(redisPort, redisHost, redisOptions);
37
+ this.client = redis.createClient(redisOptions);
57
38
 
58
39
  callback();
59
40
  }
@@ -2,6 +2,7 @@ var path = require("path");
2
2
 
3
3
  var redis = require("redis");
4
4
  var logFactory = require("../../../util/logger");
5
+ const redisHelper = require("../../../util/redis");
5
6
 
6
7
  /**
7
8
  * Redis distributed cache.
@@ -29,32 +30,12 @@ exports = module.exports = function(cacheConfig)
29
30
 
30
31
  r.init = function(callback)
31
32
  {
32
- var redisPort = cacheConfig.port;
33
- if (typeof(redisPort) === "undefined" || !redisPort)
34
- {
35
- redisPort = process.env.CLOUDCMS_CACHE_REDIS_PORT;
36
- }
37
- if (typeof(redisPort) === "undefined" || !redisPort)
38
- {
39
- redisPort = process.env.CLOUDCMS_REDIS_PORT;
40
- }
41
-
42
- var redisEndpoint = cacheConfig.endpoint;
43
- if (typeof(redisEndpoint) === "undefined" || !redisEndpoint)
44
- {
45
- redisEndpoint = process.env.CLOUDCMS_CACHE_REDIS_ENDPOINT;
46
- }
47
- if (typeof(redisEndpoint) === "undefined" || !redisEndpoint)
48
- {
49
- redisEndpoint = process.env.CLOUDCMS_REDIS_ENDPOINT;
50
- }
51
-
52
- var redisOptions = {};
53
-
54
- //redis.debug_mode = true;
55
-
56
- client = redis.createClient(redisPort, redisEndpoint, redisOptions);
33
+ var self = this;
34
+
35
+ var redisOptions = redisHelper.redisOptions(cacheConfig, "CLOUDCMS_CACHE");
57
36
 
37
+ client = redis.createClient(redisOptions);
38
+
58
39
  callback();
59
40
  };
60
41
 
package/package.json CHANGED
@@ -6,7 +6,7 @@
6
6
  },
7
7
  "name": "cloudcms-server",
8
8
  "description": "Cloud CMS Application Server Module",
9
- "version": "0.9.253",
9
+ "version": "0.9.256",
10
10
  "repository": {
11
11
  "type": "git",
12
12
  "url": "git://github.com/gitana/cloudcms-server.git"
@@ -16,7 +16,7 @@
16
16
  "agentkeepalive": "^4.1.3",
17
17
  "alpaca": "^1.5.27",
18
18
  "archiver": "^1.3.0",
19
- "async": "^1.5.2",
19
+ "async": "^3.2.3",
20
20
  "aws-sdk": "^2.544.0",
21
21
  "basic-auth": "^1.1.0",
22
22
  "body-parser": "^1.19.0",
@@ -25,12 +25,12 @@
25
25
  "clone": "^2.1.2",
26
26
  "connect-flash": "^0.1.1",
27
27
  "connect-multiparty": "^2.2.0",
28
- "connect-redis": "^3.4.2",
28
+ "connect-redis": "^6.1.3",
29
29
  "consolidate": "^0.14.5",
30
30
  "cookie-parser": "^1.4.4",
31
31
  "debug": "^2.6.9",
32
- "dustjs-helpers": "^1.7.4",
33
- "dustjs-linkedin": "^2.7.5",
32
+ "dustjs-helpers": "^1.6.3",
33
+ "dustjs-linkedin": "^3.0.1",
34
34
  "errorhandler": "^1.5.1",
35
35
  "express": "^4.17.1",
36
36
  "express-session": "^1.16.2",
@@ -45,13 +45,13 @@
45
45
  "jsonwebtoken": "^8.5.1",
46
46
  "klaw": "^1.3.1",
47
47
  "lru-cache": "^4.1.5",
48
- "marked": "^1.2.8",
48
+ "marked": "^4.0.14",
49
49
  "memorystore": "^1.6.1",
50
50
  "mime": "^1.6.0",
51
51
  "mkdirp": "^0.5.1",
52
52
  "moment": "^2.24.0",
53
53
  "morgan": "^1.9.1",
54
- "node-redis-pubsub": "^1.0.3",
54
+ "node-redis-pubsub": "^5.0.0",
55
55
  "object-hash": "^1.3.1",
56
56
  "object-merge": "^2.5.1",
57
57
  "on-headers": "^1.0.2",
@@ -63,13 +63,13 @@
63
63
  "passport-linkedin": "^1.0.0",
64
64
  "passport-local": "^1.0.0",
65
65
  "passport-oauth": "^1.0.0",
66
- "passport-saml": "^2.0.4",
67
- "passport-twitter": "^1.0.4",
66
+ "passport-saml": "^3.2.1",
67
+ "passport-twitter": "^0.1.5",
68
68
  "pkginfo": "^0.4.1",
69
69
  "q": "^1.5.1",
70
70
  "random-js": "^1.0.8",
71
71
  "recursive-readdir": "^2.2.2",
72
- "redis": "^2.8.0",
72
+ "redis": "^4.0.6",
73
73
  "redislock": "^1.3.0",
74
74
  "request": "^2.88.0",
75
75
  "request-param": "^1.0.1",
@@ -79,7 +79,7 @@
79
79
  "serve-favicon": "^2.5.0",
80
80
  "session-file-store": "^0.2.2",
81
81
  "sha1": "^1.1.1",
82
- "socket.io": "2.0.3",
82
+ "socket.io": "^4.4.1",
83
83
  "ssl-root-cas": "^1.3.1",
84
84
  "sticky-session": "^1.1.2",
85
85
  "stomp-client": "^0.9.0",
@@ -88,7 +88,7 @@
88
88
  "toobusy-js": "^0.5.1",
89
89
  "uuid": "^3.3.2",
90
90
  "vm2": "^3.8.4",
91
- "watch": "^1.0.2",
91
+ "watch": "^0.13.0",
92
92
  "winston": "^3.3.3"
93
93
  },
94
94
  "contributors": [
package/server/index.js CHANGED
@@ -23,6 +23,7 @@ const connectRedis = require('connect-redis');
23
23
  var Passport = require("passport").Passport;
24
24
 
25
25
  var util = require("../util/util");
26
+ var redisHelper = require("../util/redis");
26
27
 
27
28
  var launchPad = require("../launchpad/index");
28
29
  var cluster = require("cluster");
@@ -313,12 +314,12 @@ var SETTINGS = {
313
314
  process.env.PORT = process.env.PORT || 2999;
314
315
 
315
316
  // allows for specification of alternative transports
316
- SETTINGS.socketTransports = [
317
- 'websocket',
318
- 'xhr-polling',
319
- 'jsonp-polling',
320
- 'polling'
321
- ];
317
+ // SETTINGS.socketTransports = [
318
+ // 'websocket',
319
+ // 'xhr-polling',
320
+ // 'jsonp-polling',
321
+ // 'polling'
322
+ // ];
322
323
 
323
324
  var exports = module.exports;
324
325
 
@@ -683,8 +684,8 @@ var startSlave = function(config, afterStartFn)
683
684
  }
684
685
  else
685
686
  {
686
- var redisOptions = {};
687
- var redisClient = redis.createClient(redisPort, redisHost, redisOptions);
687
+ var redisOptions = redisHelper.redisOptions();
688
+ var redisClient = redis.createClient(redisOptions);
688
689
 
689
690
  var RedisStore = connectRedis(session);
690
691
  sessionConfig.store = new RedisStore({ client: redisClient });
@@ -1118,15 +1119,15 @@ var startSlave = function(config, afterStartFn)
1118
1119
 
1119
1120
 
1120
1121
  // create the server (either HTTP or HTTPS)
1121
- var server = null;
1122
+ var httpServer = null;
1122
1123
  if (process.configuration.https) {
1123
1124
  // configure helmet to support auto-upgrade of http->https
1124
1125
  app.use(helmet());
1125
1126
  // create https server
1126
- server = https.createServer(process.configuration.https, app);
1127
+ httpServer = https.createServer(process.configuration.https, app);
1127
1128
  } else {
1128
1129
  // legacy
1129
- server = http.Server(app);
1130
+ httpServer = http.Server(app);
1130
1131
  }
1131
1132
 
1132
1133
  // request timeout
@@ -1135,14 +1136,15 @@ var startSlave = function(config, afterStartFn)
1135
1136
  {
1136
1137
  requestTimeout = process.configuration.timeout;
1137
1138
  }
1138
- server.setTimeout(requestTimeout);
1139
+ httpServer.setTimeout(requestTimeout);
1139
1140
 
1140
1141
  // socket
1141
- server.on("connection", function (socket) {
1142
+ httpServer.on("connection", function (socket) {
1142
1143
  socket.setNoDelay(true);
1143
1144
  });
1144
- var io = process.IO = require("socket.io")(server);
1145
- io.set('transports', config.socketTransports);
1145
+ const { Server } = require("socket.io");
1146
+ var io = process.IO = new Server(httpServer);
1147
+ //io.set('transports', config.socketTransports);
1146
1148
  io.use(function (socket, next) {
1147
1149
 
1148
1150
  // console.log("New socket being initialized");
@@ -1234,7 +1236,7 @@ var startSlave = function(config, afterStartFn)
1234
1236
  // APPLY SERVER BEFORE START FUNCTIONS
1235
1237
  runFunctions(config.beforeFunctions, [app], function (err) {
1236
1238
 
1237
- server._listenPort = app.get("port");
1239
+ httpServer._listenPort = app.get("port");
1238
1240
 
1239
1241
  // AFTER SERVER START
1240
1242
  runFunctions(config.afterFunctions, [app], function (err) {
@@ -1254,7 +1256,7 @@ var startSlave = function(config, afterStartFn)
1254
1256
 
1255
1257
  try
1256
1258
  {
1257
- server.close();
1259
+ httpServer.close();
1258
1260
  }
1259
1261
  catch (e)
1260
1262
  {
@@ -1295,7 +1297,7 @@ var startSlave = function(config, afterStartFn)
1295
1297
  process.send("server-startup");
1296
1298
  }
1297
1299
 
1298
- afterStartFn(app, server);
1300
+ afterStartFn(app, httpServer);
1299
1301
 
1300
1302
  });
1301
1303
  });
package/util/redis.js ADDED
@@ -0,0 +1,63 @@
1
+ exports = module.exports;
2
+
3
+ var redisOptions = exports.redisOptions = function(config, prefix)
4
+ {
5
+ if (!config) {
6
+ config = {};
7
+ }
8
+
9
+ // redis port
10
+ var redisPort = config.port;
11
+ if (prefix)
12
+ {
13
+ if (typeof(redisPort) === "undefined" || !redisPort)
14
+ {
15
+ // CLOUDCMS_LOCKS_REDIS_PORT;
16
+ redisPort = process.env[prefix + "_REDIS_PORT"];
17
+ }
18
+ }
19
+ if (typeof(redisPort) === "undefined" || !redisPort)
20
+ {
21
+ redisPort = process.env.CLOUDCMS_REDIS_PORT;
22
+ }
23
+
24
+ // redis host
25
+ var redisEndpoint = config.endpoint;
26
+ if (prefix)
27
+ {
28
+ if (typeof(redisEndpoint) === "undefined" || !redisEndpoint)
29
+ {
30
+ redisEndpoint = process.env[prefix + "_REDIS_ENDPOINT"];
31
+ }
32
+ }
33
+ if (typeof(redisEndpoint) === "undefined" || !redisEndpoint)
34
+ {
35
+ redisEndpoint = process.env.CLOUDCMS_REDIS_ENDPOINT;
36
+ }
37
+
38
+ // redis url
39
+ var redisUrl = config.url;
40
+ if (prefix)
41
+ {
42
+ if (typeof(redisUrl) === "undefined" || !redisUrl)
43
+ {
44
+ redisUrl = process.env[prefix + "_REDIS_URL"];
45
+ }
46
+ }
47
+ if (typeof(redisUrl) === "undefined" || !redisUrl)
48
+ {
49
+ redisUrl = process.env.CLOUDCMS_REDIS_URL;
50
+ }
51
+
52
+ // build redis URL from components if not otherwise provided
53
+ if (!redisUrl)
54
+ {
55
+ redisUrl = "redis://" + redisEndpoint + ":" + redisPort;
56
+ }
57
+
58
+ var redisOptions = {};
59
+ redisOptions.url = redisUrl;
60
+ redisOptions.legacyMode = true;
61
+
62
+ return redisOptions;
63
+ }