mastercontroller 1.3.2 → 1.3.4
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/.claude/settings.local.json +5 -1
- package/CIRCULAR-DEPENDENCY-FIX-v1.3.4.md +480 -0
- package/MasterAction.js +51 -34
- package/MasterActionFilters.js +20 -5
- package/MasterControl.js +35 -8
- package/MasterCors.js +13 -6
- package/MasterCors.js.tmp +0 -0
- package/MasterHtml.js +39 -24
- package/MasterPipeline.js +15 -8
- package/MasterPipeline.js.tmp +0 -0
- package/MasterRequest.js +10 -3
- package/MasterRequest.js.tmp +0 -0
- package/MasterRouter.js +17 -10
- package/MasterRouter.js.tmp +0 -0
- package/MasterSocket.js +26 -19
- package/MasterSocket.js.tmp +0 -0
- package/MasterTemp.js +10 -3
- package/MasterTemp.js.tmp +0 -0
- package/MasterTimeout.js +12 -6
- package/MasterTimeout.js.tmp +0 -0
- package/TemplateOverwrite.js +9 -1
- package/TemplateOverwrite.js.tmp +0 -0
- package/error/MasterError.js +12 -5
- package/error/MasterError.js.tmp +0 -0
- package/error/MasterErrorRenderer.js +12 -5
- package/error/MasterErrorRenderer.js.tmp +0 -0
- package/package.json +1 -1
- package/security/SessionSecurity.js +3 -3
- package/SECURITY-FIXES-v1.3.2.md +0 -614
package/MasterTimeout.js
CHANGED
|
@@ -13,7 +13,6 @@
|
|
|
13
13
|
* @version 1.0.0
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
|
-
var master = require('./MasterControl');
|
|
17
16
|
const { logger } = require('./error/MasterErrorLogger');
|
|
18
17
|
|
|
19
18
|
class MasterTimeout {
|
|
@@ -25,6 +24,14 @@ class MasterTimeout {
|
|
|
25
24
|
this.enabled = true;
|
|
26
25
|
}
|
|
27
26
|
|
|
27
|
+
// Lazy-load master to avoid circular dependency (Google-style lazy initialization)
|
|
28
|
+
get _master() {
|
|
29
|
+
if (!this.__masterCache) {
|
|
30
|
+
this.__masterCache = require('./MasterControl');
|
|
31
|
+
}
|
|
32
|
+
return this.__masterCache;
|
|
33
|
+
}
|
|
34
|
+
|
|
28
35
|
/**
|
|
29
36
|
* Initialize timeout system
|
|
30
37
|
*
|
|
@@ -63,8 +70,8 @@ class MasterTimeout {
|
|
|
63
70
|
* @param {Number} timeout - Timeout in milliseconds
|
|
64
71
|
*
|
|
65
72
|
* @example
|
|
66
|
-
*
|
|
67
|
-
*
|
|
73
|
+
* this._master.timeout.setRouteTimeout('/api/*', 30000); // 30 seconds for APIs
|
|
74
|
+
* this._master.timeout.setRouteTimeout('/admin/reports', 300000); // 5 minutes for reports
|
|
68
75
|
*/
|
|
69
76
|
setRouteTimeout(routePattern, timeout) {
|
|
70
77
|
if (typeof timeout !== 'number' || timeout <= 0) {
|
|
@@ -327,6 +334,5 @@ class MasterTimeout {
|
|
|
327
334
|
}
|
|
328
335
|
}
|
|
329
336
|
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
module.exports = MasterTimeout;
|
|
337
|
+
// Export for MasterControl to register (prevents circular dependency)
|
|
338
|
+
module.exports = { MasterTimeout };
|
|
File without changes
|
package/TemplateOverwrite.js
CHANGED
|
@@ -6,6 +6,14 @@ class TemplateOverwrite{
|
|
|
6
6
|
#templateFunc;
|
|
7
7
|
#isTemplate = false;
|
|
8
8
|
|
|
9
|
+
// Lazy-load master to avoid circular dependency (Google-style lazy initialization)
|
|
10
|
+
get _master() {
|
|
11
|
+
if (!this.__masterCache) {
|
|
12
|
+
this.__masterCache = require('./MasterControl');
|
|
13
|
+
}
|
|
14
|
+
return this.__masterCache;
|
|
15
|
+
}
|
|
16
|
+
|
|
9
17
|
get isTemplate(){
|
|
10
18
|
return this.#isTemplate;
|
|
11
19
|
}
|
|
@@ -30,4 +38,4 @@ class TemplateOverwrite{
|
|
|
30
38
|
}
|
|
31
39
|
}
|
|
32
40
|
|
|
33
|
-
|
|
41
|
+
module.exports = { TemplateOverwrite };
|
|
File without changes
|
package/error/MasterError.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
|
|
2
2
|
// version 1.0.21 - improved console/error logging with syntax error code frames
|
|
3
|
-
var master = require('../MasterControl');
|
|
4
3
|
var winston = require('winston');
|
|
5
4
|
var fileserver = require('fs');
|
|
6
5
|
const { request } = require('http');
|
|
@@ -8,7 +7,15 @@ const { request } = require('http');
|
|
|
8
7
|
class MasterError{
|
|
9
8
|
logger = "";
|
|
10
9
|
statuses = [];
|
|
11
|
-
|
|
10
|
+
|
|
11
|
+
// Lazy-load master to avoid circular dependency (Google-style lazy initialization)
|
|
12
|
+
get _master() {
|
|
13
|
+
if (!this.__masterCache) {
|
|
14
|
+
this.__masterCache = require('../MasterControl');
|
|
15
|
+
}
|
|
16
|
+
return this.__masterCache;
|
|
17
|
+
}
|
|
18
|
+
|
|
12
19
|
init(error){
|
|
13
20
|
var that = this;
|
|
14
21
|
var stat = error;
|
|
@@ -18,7 +25,7 @@ class MasterError{
|
|
|
18
25
|
format: winston.format.json(),
|
|
19
26
|
transports: [
|
|
20
27
|
new winston.transports.Console(),
|
|
21
|
-
new winston.transports.File({ filename: `${
|
|
28
|
+
new winston.transports.File({ filename: `${this._master.root}/log/${this._master.environmentType}.log` })
|
|
22
29
|
]
|
|
23
30
|
});
|
|
24
31
|
|
|
@@ -72,7 +79,7 @@ class MasterError{
|
|
|
72
79
|
for (var i = 0; i < status.length; i++) {
|
|
73
80
|
if(parseInt(status[i].code) === statusCode){
|
|
74
81
|
var location = status[i].route;
|
|
75
|
-
var html = fileserver.readFileSync(`${
|
|
82
|
+
var html = fileserver.readFileSync(`${this._master.root}/${status[i].route.replace(/^\/|\/$/g, '')}`, 'utf8' );
|
|
76
83
|
if (!res.headersSent) {
|
|
77
84
|
res.writeHead(200, {'Content-Type': 'text/html'});
|
|
78
85
|
res.write(html, 'utf8');
|
|
@@ -174,7 +181,7 @@ class MasterError{
|
|
|
174
181
|
}
|
|
175
182
|
}
|
|
176
183
|
|
|
177
|
-
|
|
184
|
+
module.exports = { MasterError };
|
|
178
185
|
|
|
179
186
|
// ================ CODES YOU CAN USE ================ //
|
|
180
187
|
// ACCEPTED 202 Accepted
|
|
File without changes
|
|
@@ -14,7 +14,6 @@
|
|
|
14
14
|
* @version 1.0.0
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
var master = require('../MasterControl');
|
|
18
17
|
const fs = require('fs');
|
|
19
18
|
const path = require('path');
|
|
20
19
|
const { logger } = require('./MasterErrorLogger');
|
|
@@ -27,6 +26,14 @@ class MasterErrorRenderer {
|
|
|
27
26
|
this.environment = 'development';
|
|
28
27
|
}
|
|
29
28
|
|
|
29
|
+
// Lazy-load master to avoid circular dependency (Google-style lazy initialization)
|
|
30
|
+
get _master() {
|
|
31
|
+
if (!this.__masterCache) {
|
|
32
|
+
this.__masterCache = require('../MasterControl');
|
|
33
|
+
}
|
|
34
|
+
return this.__masterCache;
|
|
35
|
+
}
|
|
36
|
+
|
|
30
37
|
/**
|
|
31
38
|
* Initialize error renderer
|
|
32
39
|
*
|
|
@@ -36,8 +43,8 @@ class MasterErrorRenderer {
|
|
|
36
43
|
* @param {Boolean} options.showStackTrace - Show stack traces in dev (default: true in dev)
|
|
37
44
|
*/
|
|
38
45
|
init(options = {}) {
|
|
39
|
-
this.templateDir = options.templateDir || path.join(
|
|
40
|
-
this.environment = options.environment ||
|
|
46
|
+
this.templateDir = options.templateDir || path.join(this._master.root, 'public/errors');
|
|
47
|
+
this.environment = options.environment || this._master.environmentType || 'development';
|
|
41
48
|
this.showStackTrace = options.showStackTrace !== undefined
|
|
42
49
|
? options.showStackTrace
|
|
43
50
|
: (this.environment === 'development');
|
|
@@ -119,7 +126,7 @@ class MasterErrorRenderer {
|
|
|
119
126
|
* @param {Function} handler - Handler function (ctx, errorData) => String
|
|
120
127
|
*
|
|
121
128
|
* @example
|
|
122
|
-
*
|
|
129
|
+
* this._master.errorRenderer.registerHandler(404, (ctx, errorData) => {
|
|
123
130
|
* return `<html><body>Custom 404: ${errorData.message}</body></html>`;
|
|
124
131
|
* });
|
|
125
132
|
*/
|
|
@@ -524,6 +531,6 @@ class MasterErrorRenderer {
|
|
|
524
531
|
}
|
|
525
532
|
}
|
|
526
533
|
|
|
527
|
-
|
|
534
|
+
module.exports = { MasterErrorRenderer };
|
|
528
535
|
|
|
529
536
|
module.exports = MasterErrorRenderer;
|
|
File without changes
|
package/package.json
CHANGED
|
@@ -407,9 +407,6 @@ const SESSION_BEST_PRACTICES = {
|
|
|
407
407
|
}
|
|
408
408
|
};
|
|
409
409
|
|
|
410
|
-
// MasterController Integration
|
|
411
|
-
const master = require('../MasterControl');
|
|
412
|
-
|
|
413
410
|
// Create MasterController-compatible wrapper
|
|
414
411
|
class MasterSessionSecurity {
|
|
415
412
|
constructor() {
|
|
@@ -425,6 +422,9 @@ class MasterSessionSecurity {
|
|
|
425
422
|
this._options = options;
|
|
426
423
|
this._instance = new SessionSecurity(options);
|
|
427
424
|
|
|
425
|
+
// Lazy load master to avoid circular dependency
|
|
426
|
+
const master = require('../MasterControl');
|
|
427
|
+
|
|
428
428
|
// Auto-register with pipeline if available
|
|
429
429
|
if (master.pipeline) {
|
|
430
430
|
master.pipeline.use(this._instance.middleware());
|