cloudcms-server 3.2.334 → 3.2.335
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 +25 -67
- package/middleware/virtual-config/virtual-config.js +1 -30
- package/package.json +1 -1
- package/server/index.js +1 -40
package/index.js
CHANGED
|
@@ -29,31 +29,31 @@ process.logInfo = process.log = function(text, level)
|
|
|
29
29
|
systemLogger.log(text, level);
|
|
30
30
|
};
|
|
31
31
|
|
|
32
|
-
var debugLog = process.debugLog = function(req, message)
|
|
33
|
-
{
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
var debugMiddleware = process.debugMiddleware = function(message)
|
|
49
|
-
{
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
};
|
|
32
|
+
// var debugLog = process.debugLog = function(req, message)
|
|
33
|
+
// {
|
|
34
|
+
// var text = "[" + req.id + "] URL: " + req.url;
|
|
35
|
+
// // if (req.headers)
|
|
36
|
+
// // {
|
|
37
|
+
// // text += ", HEADERS: " + JSON.stringify(req.headers);
|
|
38
|
+
// // }
|
|
39
|
+
// if (req.query)
|
|
40
|
+
// {
|
|
41
|
+
// text += ", QUERY: " + JSON.stringify(req.query);
|
|
42
|
+
// }
|
|
43
|
+
// text += ", MESSAGE: " + message;
|
|
44
|
+
//
|
|
45
|
+
// console.log(text);
|
|
46
|
+
// };
|
|
47
|
+
//
|
|
48
|
+
// var debugMiddleware = process.debugMiddleware = function(message)
|
|
49
|
+
// {
|
|
50
|
+
// return function(req, res, next)
|
|
51
|
+
// {
|
|
52
|
+
// debugLog(req, message);
|
|
53
|
+
//
|
|
54
|
+
// next();
|
|
55
|
+
// }
|
|
56
|
+
// };
|
|
57
57
|
|
|
58
58
|
|
|
59
59
|
|
|
@@ -333,82 +333,43 @@ exports = module.exports = function()
|
|
|
333
333
|
|
|
334
334
|
r.common1 = function(app)
|
|
335
335
|
{
|
|
336
|
-
// DEBUG
|
|
337
|
-
app.use(debugMiddleware("DEBUG x1"));
|
|
338
|
-
|
|
339
336
|
// app config interceptor
|
|
340
337
|
applyApplicationConfiguration(app);
|
|
341
338
|
|
|
342
|
-
// DEBUG
|
|
343
|
-
app.use(debugMiddleware("DEBUG x2"));
|
|
344
|
-
|
|
345
339
|
// sets locale onto the request
|
|
346
340
|
app.use(locale.localeInterceptor());
|
|
347
341
|
|
|
348
|
-
// DEBUG
|
|
349
|
-
app.use(debugMiddleware("DEBUG x3"));
|
|
350
|
-
|
|
351
342
|
// sets host onto the request
|
|
352
343
|
app.use(host.hostInterceptor());
|
|
353
|
-
|
|
354
|
-
// DEBUG
|
|
355
|
-
app.use(debugMiddleware("DEBUG x4"));
|
|
356
344
|
};
|
|
357
345
|
|
|
358
346
|
r.common2 = function(app)
|
|
359
347
|
{
|
|
360
|
-
// DEBUG
|
|
361
|
-
app.use(debugMiddleware("DEBUG y1"));
|
|
362
|
-
|
|
363
348
|
// bind stores into the request
|
|
364
349
|
app.use(storeService.storesInterceptor());
|
|
365
350
|
|
|
366
|
-
// DEBUG
|
|
367
|
-
app.use(debugMiddleware("DEBUG y2"));
|
|
368
|
-
|
|
369
351
|
// puts req.descriptor into the request and req.virtualFiles = true
|
|
370
352
|
app.use(virtualFiles.interceptor());
|
|
371
353
|
|
|
372
|
-
// DEBUG
|
|
373
|
-
app.use(debugMiddleware("DEBUG y3"));
|
|
374
|
-
|
|
375
354
|
// puts req.runtime into the request
|
|
376
355
|
app.use(runtime.interceptor());
|
|
377
356
|
|
|
378
|
-
// DEBUG
|
|
379
|
-
app.use(debugMiddleware("DEBUG y4"));
|
|
380
|
-
|
|
381
357
|
// if virtual hosting is enabled, loads "gitana.json" from cloud cms and places it into rootStore
|
|
382
358
|
// for convenience, also populates req.gitanaConfig
|
|
383
359
|
app.use(virtualConfig.interceptor());
|
|
384
360
|
|
|
385
|
-
// DEBUG
|
|
386
|
-
app.use(debugMiddleware("DEBUG y5"));
|
|
387
|
-
|
|
388
361
|
// general method for finding "gitana.json" in root store and populating req.gitanaConfig
|
|
389
362
|
app.use(driverConfig.interceptor());
|
|
390
|
-
|
|
391
|
-
// DEBUG
|
|
392
|
-
app.use(debugMiddleware("DEBUG y6"));
|
|
393
363
|
};
|
|
394
364
|
|
|
395
365
|
r.common3 = function(app)
|
|
396
366
|
{
|
|
397
|
-
// DEBUG
|
|
398
|
-
app.use(debugMiddleware("DEBUG z1"));
|
|
399
|
-
|
|
400
367
|
// binds "req.gitana" into the request for the loaded "req.gitanaConfig"
|
|
401
368
|
app.use(driver.driverInterceptor());
|
|
402
|
-
|
|
403
|
-
// DEBUG
|
|
404
|
-
app.use(debugMiddleware("DEBUG z2"));
|
|
405
369
|
};
|
|
406
370
|
|
|
407
371
|
r.common4 = function(app, includeCloudCMS)
|
|
408
372
|
{
|
|
409
|
-
// DEBUG
|
|
410
|
-
app.use(debugMiddleware("DEBUG v1"));
|
|
411
|
-
|
|
412
373
|
var configuration = app.configuration;
|
|
413
374
|
|
|
414
375
|
if (includeCloudCMS)
|
|
@@ -441,9 +402,6 @@ exports = module.exports = function()
|
|
|
441
402
|
|
|
442
403
|
// graphql
|
|
443
404
|
app.use(graphql.interceptor());
|
|
444
|
-
|
|
445
|
-
// DEBUG
|
|
446
|
-
app.use(debugMiddleware("DEBUG v2"));
|
|
447
405
|
};
|
|
448
406
|
|
|
449
407
|
r.perf1 = function(app)
|
|
@@ -2,7 +2,7 @@ var util = require("../../util/util");
|
|
|
2
2
|
|
|
3
3
|
var workQueueFactory = require("../../util/workqueue");
|
|
4
4
|
|
|
5
|
-
var debugLog = process.debugLog;
|
|
5
|
+
//var debugLog = process.debugLog;
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Retrieves virtual driver configuration for hosts from Cloud CMS.
|
|
@@ -382,11 +382,8 @@ exports = module.exports = function()
|
|
|
382
382
|
|
|
383
383
|
var completionFunction = function (err, gitanaConfig, doesNotExist)
|
|
384
384
|
{
|
|
385
|
-
debugLog(req, "g20");
|
|
386
385
|
if (doesNotExist)
|
|
387
386
|
{
|
|
388
|
-
debugLog(req, "g21");
|
|
389
|
-
|
|
390
387
|
// console.log("BLOCK, method: " + req.method + ", url: " + req.url);
|
|
391
388
|
// if (req.headers)
|
|
392
389
|
// {
|
|
@@ -403,8 +400,6 @@ exports = module.exports = function()
|
|
|
403
400
|
return res.end(JSON.stringify({"error": true, "message": "Bad Request."}));
|
|
404
401
|
}
|
|
405
402
|
|
|
406
|
-
debugLog(req, "g22");
|
|
407
|
-
|
|
408
403
|
if (err)
|
|
409
404
|
{
|
|
410
405
|
if (err.message)
|
|
@@ -412,15 +407,11 @@ exports = module.exports = function()
|
|
|
412
407
|
req.log(err.message);
|
|
413
408
|
}
|
|
414
409
|
|
|
415
|
-
debugLog(req, "g23: " + err);
|
|
416
|
-
|
|
417
410
|
return next();
|
|
418
411
|
}
|
|
419
412
|
|
|
420
413
|
if (gitanaConfig)
|
|
421
414
|
{
|
|
422
|
-
debugLog(req, "g24: " + JSON.stringify(gitanaConfig, null, 2));
|
|
423
|
-
|
|
424
415
|
// store config
|
|
425
416
|
req.gitanaConfig = gitanaConfig;
|
|
426
417
|
|
|
@@ -428,18 +419,11 @@ exports = module.exports = function()
|
|
|
428
419
|
req.gitanaLocal = false;
|
|
429
420
|
}
|
|
430
421
|
|
|
431
|
-
debugLog(req, "g30");
|
|
432
|
-
|
|
433
422
|
next();
|
|
434
423
|
};
|
|
435
424
|
|
|
436
|
-
debugLog(req, "g1: " + req.virtualHost);
|
|
437
|
-
|
|
438
425
|
process.driverConfigCache.read(req.virtualHost, function(err, cachedValue)
|
|
439
426
|
{
|
|
440
|
-
debugLog(req, "g2: " + err);
|
|
441
|
-
debugLog(req, "g3: " + cachedValue);
|
|
442
|
-
|
|
443
427
|
if (process.env.NULL_DRIVER_CACHE === "true") {
|
|
444
428
|
cachedValue = null;
|
|
445
429
|
}
|
|
@@ -448,29 +432,20 @@ exports = module.exports = function()
|
|
|
448
432
|
{
|
|
449
433
|
if (cachedValue === SENTINEL_NOT_FOUND_VALUE)
|
|
450
434
|
{
|
|
451
|
-
debugLog(req, "g4");
|
|
452
|
-
|
|
453
435
|
// null means there verifiably isn't anything on disk (null used as sentinel marker)
|
|
454
436
|
completionFunction(null, null, true);
|
|
455
437
|
}
|
|
456
438
|
else
|
|
457
439
|
{
|
|
458
|
-
debugLog(req, "g5");
|
|
459
|
-
|
|
460
440
|
// we have something in cache
|
|
461
441
|
completionFunction(null, cachedValue.config);
|
|
462
442
|
}
|
|
463
443
|
}
|
|
464
444
|
else
|
|
465
445
|
{
|
|
466
|
-
debugLog(req, "g6");
|
|
467
|
-
|
|
468
446
|
// try to load from disk
|
|
469
447
|
acquireGitanaJson(req.virtualHost, req.rootStore, req.log, function (err, gitanaConfig, doesNotExist)
|
|
470
448
|
{
|
|
471
|
-
debugLog(req, "g7: " + err);
|
|
472
|
-
debugLog(req, "g8: " + gitanaConfig);
|
|
473
|
-
|
|
474
449
|
if (err && !doesNotExist)
|
|
475
450
|
{
|
|
476
451
|
return completionFunction(err);
|
|
@@ -478,8 +453,6 @@ exports = module.exports = function()
|
|
|
478
453
|
|
|
479
454
|
if (gitanaConfig)
|
|
480
455
|
{
|
|
481
|
-
debugLog(req, "g9: " + JSON.stringify(gitanaConfig, null, 2));
|
|
482
|
-
|
|
483
456
|
return process.driverConfigCache.write(req.virtualHost, {
|
|
484
457
|
"config": gitanaConfig
|
|
485
458
|
}, function (err) {
|
|
@@ -487,8 +460,6 @@ exports = module.exports = function()
|
|
|
487
460
|
});
|
|
488
461
|
}
|
|
489
462
|
|
|
490
|
-
debugLog(req, "g10: " + req.virtualHost);
|
|
491
|
-
|
|
492
463
|
// mark with sentinel (30 minutes)
|
|
493
464
|
req.log("[BLACKLIST] Adding: " + req.virtualHost);
|
|
494
465
|
process.driverConfigCache.write(req.virtualHost, SENTINEL_NOT_FOUND_VALUE, BLACKLIST_TTL_SECONDS, function (err) {
|
package/package.json
CHANGED
package/server/index.js
CHANGED
|
@@ -729,7 +729,7 @@ var initSession = function(initDone)
|
|
|
729
729
|
}
|
|
730
730
|
};
|
|
731
731
|
|
|
732
|
-
var debugMiddleware = process.debugMiddleware;
|
|
732
|
+
//var debugMiddleware = process.debugMiddleware;
|
|
733
733
|
|
|
734
734
|
var startServer = function(config, startServerFinishedFn)
|
|
735
735
|
{
|
|
@@ -899,9 +899,6 @@ var startServer = function(config, startServerFinishedFn)
|
|
|
899
899
|
next();
|
|
900
900
|
});
|
|
901
901
|
|
|
902
|
-
// DEBUG
|
|
903
|
-
app.use(debugMiddleware("DEBUG 1"));
|
|
904
|
-
|
|
905
902
|
// APPLY CUSTOM INIT FUNCTIONS
|
|
906
903
|
runFunctions(config.initFunctions, [app], function (err) {
|
|
907
904
|
|
|
@@ -995,9 +992,6 @@ var startServer = function(config, startServerFinishedFn)
|
|
|
995
992
|
// common interceptors and config
|
|
996
993
|
main.common1(app);
|
|
997
994
|
|
|
998
|
-
// DEBUG
|
|
999
|
-
app.use(debugMiddleware("DEBUG 2"));
|
|
1000
|
-
|
|
1001
995
|
// general logging of requests
|
|
1002
996
|
// gather statistics on response time
|
|
1003
997
|
app.use(responseTime(function (req, res, time) {
|
|
@@ -1037,28 +1031,16 @@ var startServer = function(config, startServerFinishedFn)
|
|
|
1037
1031
|
req.log(m, warn);
|
|
1038
1032
|
}));
|
|
1039
1033
|
|
|
1040
|
-
// DEBUG
|
|
1041
|
-
app.use(debugMiddleware("DEBUG 2a"));
|
|
1042
|
-
|
|
1043
1034
|
// set up CORS allowances
|
|
1044
1035
|
// this lets CORS requests float through the proxy
|
|
1045
1036
|
app.use(main.ensureCORS());
|
|
1046
1037
|
|
|
1047
|
-
// DEBUG
|
|
1048
|
-
app.use(debugMiddleware("DEBUG 2b"));
|
|
1049
|
-
|
|
1050
1038
|
// set up default security headers
|
|
1051
1039
|
app.use(main.ensureHeaders());
|
|
1052
1040
|
|
|
1053
|
-
// DEBUG
|
|
1054
|
-
app.use(debugMiddleware("DEBUG 2c"));
|
|
1055
|
-
|
|
1056
1041
|
// common interceptors and config
|
|
1057
1042
|
main.common2(app);
|
|
1058
1043
|
|
|
1059
|
-
// DEBUG
|
|
1060
|
-
app.use(debugMiddleware("DEBUG 3"));
|
|
1061
|
-
|
|
1062
1044
|
// APPLY CUSTOM DRIVER FUNCTIONS
|
|
1063
1045
|
runFunctions(config.driverFunctions, [app], function(err) {
|
|
1064
1046
|
|
|
@@ -1071,9 +1053,6 @@ var startServer = function(config, startServerFinishedFn)
|
|
|
1071
1053
|
// cloudcms things need to run here
|
|
1072
1054
|
main.common4(app, true);
|
|
1073
1055
|
|
|
1074
|
-
// DEBUG
|
|
1075
|
-
app.use(debugMiddleware("DEBUG 4"));
|
|
1076
|
-
|
|
1077
1056
|
// APPLY CUSTOM FILTER FUNCTIONS
|
|
1078
1057
|
runFunctions(config.filterFunctions, [app], function (err) {
|
|
1079
1058
|
|
|
@@ -1089,9 +1068,6 @@ var startServer = function(config, startServerFinishedFn)
|
|
|
1089
1068
|
// DEVELOPMENT BASED PERFORMANCE CACHING
|
|
1090
1069
|
main.perf3(app);
|
|
1091
1070
|
|
|
1092
|
-
// DEBUG
|
|
1093
|
-
app.use(debugMiddleware("DEBUG 5"));
|
|
1094
|
-
|
|
1095
1071
|
// standard body parsing + a special cloud cms body parser that makes a last ditch effort for anything
|
|
1096
1072
|
// that might be JSON (regardless of content type)
|
|
1097
1073
|
app.use(function (req, res, next) {
|
|
@@ -1114,9 +1090,6 @@ var startServer = function(config, startServerFinishedFn)
|
|
|
1114
1090
|
app.use(flash());
|
|
1115
1091
|
}
|
|
1116
1092
|
|
|
1117
|
-
// DEBUG
|
|
1118
|
-
app.use(debugMiddleware("DEBUG 6"));
|
|
1119
|
-
|
|
1120
1093
|
// this is the same as calling
|
|
1121
1094
|
// app.use(passport.initialize());
|
|
1122
1095
|
// except we create a new passport each time and store on request to support multitenancy
|
|
@@ -1156,9 +1129,6 @@ var startServer = function(config, startServerFinishedFn)
|
|
|
1156
1129
|
});
|
|
1157
1130
|
}
|
|
1158
1131
|
|
|
1159
|
-
// DEBUG
|
|
1160
|
-
app.use(debugMiddleware("DEBUG 7"));
|
|
1161
|
-
|
|
1162
1132
|
// welcome files
|
|
1163
1133
|
main.welcome(app);
|
|
1164
1134
|
|
|
@@ -1170,21 +1140,12 @@ var startServer = function(config, startServerFinishedFn)
|
|
|
1170
1140
|
// healthcheck middleware
|
|
1171
1141
|
main.healthcheck(app);
|
|
1172
1142
|
|
|
1173
|
-
// DEBUG
|
|
1174
|
-
app.use(debugMiddleware("DEBUG 8"));
|
|
1175
|
-
|
|
1176
1143
|
// APPLY CUSTOM ROUTES
|
|
1177
1144
|
runFunctions(config.routeFunctions, [app], function (err) {
|
|
1178
1145
|
|
|
1179
|
-
// DEBUG
|
|
1180
|
-
app.use(debugMiddleware("DEBUG 9"));
|
|
1181
|
-
|
|
1182
1146
|
// configure cloudcms app server handlers
|
|
1183
1147
|
main.handlers(app, true);
|
|
1184
1148
|
|
|
1185
|
-
// DEBUG
|
|
1186
|
-
app.use(debugMiddleware("DEBUG 10"));
|
|
1187
|
-
|
|
1188
1149
|
// register error functions
|
|
1189
1150
|
runFunctions(config.errorFunctions, [app], function (err) {
|
|
1190
1151
|
|