cloudcms-server 3.2.326 → 3.2.327
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.
- package/index.js +64 -0
- package/package.json +1 -1
- package/server/index.js +27 -43
- package/util/auth.js +1 -0
package/index.js
CHANGED
|
@@ -29,6 +29,28 @@ process.logInfo = process.log = function(text, level)
|
|
|
29
29
|
systemLogger.log(text, level);
|
|
30
30
|
};
|
|
31
31
|
|
|
32
|
+
var debugMiddleware = process.debugMiddleware = function(message)
|
|
33
|
+
{
|
|
34
|
+
return function(req, res, next)
|
|
35
|
+
{
|
|
36
|
+
var text = "[" + req.id + "] URL: " + req.url;
|
|
37
|
+
// if (req.headers)
|
|
38
|
+
// {
|
|
39
|
+
// text += ", HEADERS: " + JSON.stringify(req.headers);
|
|
40
|
+
// }
|
|
41
|
+
if (req.query)
|
|
42
|
+
{
|
|
43
|
+
text += ", QUERY: " + JSON.stringify(req.query);
|
|
44
|
+
}
|
|
45
|
+
text += ", MESSAGE: " + message;
|
|
46
|
+
|
|
47
|
+
console.log(text);
|
|
48
|
+
|
|
49
|
+
next();
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
|
|
32
54
|
|
|
33
55
|
// by default, set up Gitana driver so that it limits to five concurrent HTTP requests back to Cloud CMS API at at time
|
|
34
56
|
var Gitana = require("gitana");
|
|
@@ -306,43 +328,82 @@ exports = module.exports = function()
|
|
|
306
328
|
|
|
307
329
|
r.common1 = function(app)
|
|
308
330
|
{
|
|
331
|
+
// DEBUG
|
|
332
|
+
app.use(debugMiddleware("DEBUG x1"));
|
|
333
|
+
|
|
309
334
|
// app config interceptor
|
|
310
335
|
applyApplicationConfiguration(app);
|
|
311
336
|
|
|
337
|
+
// DEBUG
|
|
338
|
+
app.use(debugMiddleware("DEBUG x2"));
|
|
339
|
+
|
|
312
340
|
// sets locale onto the request
|
|
313
341
|
app.use(locale.localeInterceptor());
|
|
314
342
|
|
|
343
|
+
// DEBUG
|
|
344
|
+
app.use(debugMiddleware("DEBUG x3"));
|
|
345
|
+
|
|
315
346
|
// sets host onto the request
|
|
316
347
|
app.use(host.hostInterceptor());
|
|
348
|
+
|
|
349
|
+
// DEBUG
|
|
350
|
+
app.use(debugMiddleware("DEBUG x4"));
|
|
317
351
|
};
|
|
318
352
|
|
|
319
353
|
r.common2 = function(app)
|
|
320
354
|
{
|
|
355
|
+
// DEBUG
|
|
356
|
+
app.use(debugMiddleware("DEBUG y1"));
|
|
357
|
+
|
|
321
358
|
// bind stores into the request
|
|
322
359
|
app.use(storeService.storesInterceptor());
|
|
323
360
|
|
|
361
|
+
// DEBUG
|
|
362
|
+
app.use(debugMiddleware("DEBUG y2"));
|
|
363
|
+
|
|
324
364
|
// puts req.descriptor into the request and req.virtualFiles = true
|
|
325
365
|
app.use(virtualFiles.interceptor());
|
|
326
366
|
|
|
367
|
+
// DEBUG
|
|
368
|
+
app.use(debugMiddleware("DEBUG y3"));
|
|
369
|
+
|
|
327
370
|
// puts req.runtime into the request
|
|
328
371
|
app.use(runtime.interceptor());
|
|
329
372
|
|
|
373
|
+
// DEBUG
|
|
374
|
+
app.use(debugMiddleware("DEBUG y4"));
|
|
375
|
+
|
|
330
376
|
// if virtual hosting is enabled, loads "gitana.json" from cloud cms and places it into rootStore
|
|
331
377
|
// for convenience, also populates req.gitanaConfig
|
|
332
378
|
app.use(virtualConfig.interceptor());
|
|
333
379
|
|
|
380
|
+
// DEBUG
|
|
381
|
+
app.use(debugMiddleware("DEBUG y5"));
|
|
382
|
+
|
|
334
383
|
// general method for finding "gitana.json" in root store and populating req.gitanaConfig
|
|
335
384
|
app.use(driverConfig.interceptor());
|
|
385
|
+
|
|
386
|
+
// DEBUG
|
|
387
|
+
app.use(debugMiddleware("DEBUG y6"));
|
|
336
388
|
};
|
|
337
389
|
|
|
338
390
|
r.common3 = function(app)
|
|
339
391
|
{
|
|
392
|
+
// DEBUG
|
|
393
|
+
app.use(debugMiddleware("DEBUG z1"));
|
|
394
|
+
|
|
340
395
|
// binds "req.gitana" into the request for the loaded "req.gitanaConfig"
|
|
341
396
|
app.use(driver.driverInterceptor());
|
|
397
|
+
|
|
398
|
+
// DEBUG
|
|
399
|
+
app.use(debugMiddleware("DEBUG z2"));
|
|
342
400
|
};
|
|
343
401
|
|
|
344
402
|
r.common4 = function(app, includeCloudCMS)
|
|
345
403
|
{
|
|
404
|
+
// DEBUG
|
|
405
|
+
app.use(debugMiddleware("DEBUG v1"));
|
|
406
|
+
|
|
346
407
|
var configuration = app.configuration;
|
|
347
408
|
|
|
348
409
|
if (includeCloudCMS)
|
|
@@ -375,6 +436,9 @@ exports = module.exports = function()
|
|
|
375
436
|
|
|
376
437
|
// graphql
|
|
377
438
|
app.use(graphql.interceptor());
|
|
439
|
+
|
|
440
|
+
// DEBUG
|
|
441
|
+
app.use(debugMiddleware("DEBUG v2"));
|
|
378
442
|
};
|
|
379
443
|
|
|
380
444
|
r.perf1 = function(app)
|
package/package.json
CHANGED
package/server/index.js
CHANGED
|
@@ -729,6 +729,8 @@ var initSession = function(initDone)
|
|
|
729
729
|
}
|
|
730
730
|
};
|
|
731
731
|
|
|
732
|
+
var debugMiddleware = process.debugMiddleware;
|
|
733
|
+
|
|
732
734
|
var startServer = function(config, startServerFinishedFn)
|
|
733
735
|
{
|
|
734
736
|
var app = express();
|
|
@@ -898,10 +900,7 @@ var startServer = function(config, startServerFinishedFn)
|
|
|
898
900
|
});
|
|
899
901
|
|
|
900
902
|
// DEBUG
|
|
901
|
-
app.use(
|
|
902
|
-
console.log("[REQ: " + req.id + "] DEBUG 1");
|
|
903
|
-
next();
|
|
904
|
-
});
|
|
903
|
+
app.use(debugMiddleware("DEBUG 1"));
|
|
905
904
|
|
|
906
905
|
// APPLY CUSTOM INIT FUNCTIONS
|
|
907
906
|
runFunctions(config.initFunctions, [app], function (err) {
|
|
@@ -997,10 +996,7 @@ var startServer = function(config, startServerFinishedFn)
|
|
|
997
996
|
main.common1(app);
|
|
998
997
|
|
|
999
998
|
// DEBUG
|
|
1000
|
-
app.use(
|
|
1001
|
-
console.log("[REQ: " + req.id + "] DEBUG 2");
|
|
1002
|
-
next();
|
|
1003
|
-
});
|
|
999
|
+
app.use(debugMiddleware("DEBUG 2"));
|
|
1004
1000
|
|
|
1005
1001
|
// general logging of requests
|
|
1006
1002
|
// gather statistics on response time
|
|
@@ -1040,22 +1036,28 @@ var startServer = function(config, startServerFinishedFn)
|
|
|
1040
1036
|
|
|
1041
1037
|
req.log(m, warn);
|
|
1042
1038
|
}));
|
|
1043
|
-
|
|
1039
|
+
|
|
1040
|
+
// DEBUG
|
|
1041
|
+
app.use(debugMiddleware("DEBUG 2a"));
|
|
1042
|
+
|
|
1044
1043
|
// set up CORS allowances
|
|
1045
1044
|
// this lets CORS requests float through the proxy
|
|
1046
1045
|
app.use(main.ensureCORS());
|
|
1047
|
-
|
|
1046
|
+
|
|
1047
|
+
// DEBUG
|
|
1048
|
+
app.use(debugMiddleware("DEBUG 2b"));
|
|
1049
|
+
|
|
1048
1050
|
// set up default security headers
|
|
1049
1051
|
app.use(main.ensureHeaders());
|
|
1050
|
-
|
|
1052
|
+
|
|
1053
|
+
// DEBUG
|
|
1054
|
+
app.use(debugMiddleware("DEBUG 2c"));
|
|
1055
|
+
|
|
1051
1056
|
// common interceptors and config
|
|
1052
1057
|
main.common2(app);
|
|
1053
1058
|
|
|
1054
1059
|
// DEBUG
|
|
1055
|
-
app.use(
|
|
1056
|
-
console.log("[REQ: " + req.id + "] DEBUG 3");
|
|
1057
|
-
next();
|
|
1058
|
-
});
|
|
1060
|
+
app.use(debugMiddleware("DEBUG 3"));
|
|
1059
1061
|
|
|
1060
1062
|
// APPLY CUSTOM DRIVER FUNCTIONS
|
|
1061
1063
|
runFunctions(config.driverFunctions, [app], function(err) {
|
|
@@ -1070,10 +1072,7 @@ var startServer = function(config, startServerFinishedFn)
|
|
|
1070
1072
|
main.common4(app, true);
|
|
1071
1073
|
|
|
1072
1074
|
// DEBUG
|
|
1073
|
-
app.use(
|
|
1074
|
-
console.log("[REQ: " + req.id + "] DEBUG 4");
|
|
1075
|
-
next();
|
|
1076
|
-
});
|
|
1075
|
+
app.use(debugMiddleware("DEBUG 4"));
|
|
1077
1076
|
|
|
1078
1077
|
// APPLY CUSTOM FILTER FUNCTIONS
|
|
1079
1078
|
runFunctions(config.filterFunctions, [app], function (err) {
|
|
@@ -1091,10 +1090,7 @@ var startServer = function(config, startServerFinishedFn)
|
|
|
1091
1090
|
main.perf3(app);
|
|
1092
1091
|
|
|
1093
1092
|
// DEBUG
|
|
1094
|
-
app.use(
|
|
1095
|
-
console.log("[REQ: " + req.id + "] DEBUG 5");
|
|
1096
|
-
next();
|
|
1097
|
-
});
|
|
1093
|
+
app.use(debugMiddleware("DEBUG 5"));
|
|
1098
1094
|
|
|
1099
1095
|
// standard body parsing + a special cloud cms body parser that makes a last ditch effort for anything
|
|
1100
1096
|
// that might be JSON (regardless of content type)
|
|
@@ -1119,10 +1115,7 @@ var startServer = function(config, startServerFinishedFn)
|
|
|
1119
1115
|
}
|
|
1120
1116
|
|
|
1121
1117
|
// DEBUG
|
|
1122
|
-
app.use(
|
|
1123
|
-
console.log("[REQ: " + req.id + "] DEBUG 6");
|
|
1124
|
-
next();
|
|
1125
|
-
});
|
|
1118
|
+
app.use(debugMiddleware("DEBUG 6"));
|
|
1126
1119
|
|
|
1127
1120
|
// this is the same as calling
|
|
1128
1121
|
// app.use(passport.initialize());
|
|
@@ -1164,10 +1157,7 @@ var startServer = function(config, startServerFinishedFn)
|
|
|
1164
1157
|
}
|
|
1165
1158
|
|
|
1166
1159
|
// DEBUG
|
|
1167
|
-
app.use(
|
|
1168
|
-
console.log("[REQ: " + req.id + "] DEBUG 7");
|
|
1169
|
-
next();
|
|
1170
|
-
});
|
|
1160
|
+
app.use(debugMiddleware("DEBUG 7"));
|
|
1171
1161
|
|
|
1172
1162
|
// welcome files
|
|
1173
1163
|
main.welcome(app);
|
|
@@ -1181,28 +1171,19 @@ var startServer = function(config, startServerFinishedFn)
|
|
|
1181
1171
|
main.healthcheck(app);
|
|
1182
1172
|
|
|
1183
1173
|
// DEBUG
|
|
1184
|
-
app.use(
|
|
1185
|
-
console.log("[REQ: " + req.id + "] DEBUG 8");
|
|
1186
|
-
next();
|
|
1187
|
-
});
|
|
1174
|
+
app.use(debugMiddleware("DEBUG 8"));
|
|
1188
1175
|
|
|
1189
1176
|
// APPLY CUSTOM ROUTES
|
|
1190
1177
|
runFunctions(config.routeFunctions, [app], function (err) {
|
|
1191
1178
|
|
|
1192
1179
|
// DEBUG
|
|
1193
|
-
app.use(
|
|
1194
|
-
console.log("[REQ: " + req.id + "] DEBUG 9");
|
|
1195
|
-
next();
|
|
1196
|
-
});
|
|
1180
|
+
app.use(debugMiddleware("DEBUG 9"));
|
|
1197
1181
|
|
|
1198
1182
|
// configure cloudcms app server handlers
|
|
1199
1183
|
main.handlers(app, true);
|
|
1200
1184
|
|
|
1201
1185
|
// DEBUG
|
|
1202
|
-
app.use(
|
|
1203
|
-
console.log("[REQ: " + req.id + "] DEBUG 10");
|
|
1204
|
-
next();
|
|
1205
|
-
});
|
|
1186
|
+
app.use(debugMiddleware("DEBUG 10"));
|
|
1206
1187
|
|
|
1207
1188
|
// register error functions
|
|
1208
1189
|
runFunctions(config.errorFunctions, [app], function (err) {
|
|
@@ -1279,6 +1260,9 @@ var createHttpServer = function(app, done)
|
|
|
1279
1260
|
|
|
1280
1261
|
// socket
|
|
1281
1262
|
httpServer.on("connection", function (socket) {
|
|
1263
|
+
|
|
1264
|
+
console.log("[SOCKET CONNECTION] " + socket);
|
|
1265
|
+
|
|
1282
1266
|
socket.setNoDelay(true);
|
|
1283
1267
|
|
|
1284
1268
|
socket.setTimeout(requestTimeout, function(socket) {
|
package/util/auth.js
CHANGED