xypriss 4.0.1 → 4.1.0
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/dist/cjs/src/config.js +57 -31
- package/dist/cjs/src/config.js.map +1 -1
- package/dist/cjs/src/file-upload.js +5 -4
- package/dist/cjs/src/file-upload.js.map +1 -1
- package/dist/cjs/src/index.js +1 -1
- package/dist/cjs/src/plugins/api/PluginAPI.js +135 -0
- package/dist/cjs/src/plugins/api/PluginAPI.js.map +1 -0
- package/dist/cjs/src/plugins/core/PluginManager.js +46 -0
- package/dist/cjs/src/plugins/core/PluginManager.js.map +1 -1
- package/dist/cjs/src/server/FastServer.js +28 -15
- package/dist/cjs/src/server/FastServer.js.map +1 -1
- package/dist/cjs/src/server/ServerFactory.js +27 -22
- package/dist/cjs/src/server/ServerFactory.js.map +1 -1
- package/dist/cjs/src/server/components/fastapi/FileUploadManager.js +3 -2
- package/dist/cjs/src/server/components/fastapi/FileUploadManager.js.map +1 -1
- package/dist/cjs/src/server/components/fastapi/console/ConsoleInterceptor.js +74 -22
- package/dist/cjs/src/server/components/fastapi/console/ConsoleInterceptor.js.map +1 -1
- package/dist/cjs/src/server/components/fastapi/console/types.js +0 -1
- package/dist/cjs/src/server/components/fastapi/console/types.js.map +1 -1
- package/dist/cjs/src/server/const/default.js +75 -0
- package/dist/cjs/src/server/const/default.js.map +1 -1
- package/dist/cjs/src/server/handlers/NotFoundHandler.js +1 -1
- package/dist/esm/src/config.js +57 -31
- package/dist/esm/src/config.js.map +1 -1
- package/dist/esm/src/file-upload.js +3 -2
- package/dist/esm/src/file-upload.js.map +1 -1
- package/dist/esm/src/index.js +1 -1
- package/dist/esm/src/plugins/api/PluginAPI.js +131 -0
- package/dist/esm/src/plugins/api/PluginAPI.js.map +1 -0
- package/dist/esm/src/plugins/core/PluginManager.js +46 -0
- package/dist/esm/src/plugins/core/PluginManager.js.map +1 -1
- package/dist/esm/src/server/FastServer.js +28 -15
- package/dist/esm/src/server/FastServer.js.map +1 -1
- package/dist/esm/src/server/ServerFactory.js +27 -22
- package/dist/esm/src/server/ServerFactory.js.map +1 -1
- package/dist/esm/src/server/components/fastapi/FileUploadManager.js +3 -2
- package/dist/esm/src/server/components/fastapi/FileUploadManager.js.map +1 -1
- package/dist/esm/src/server/components/fastapi/console/ConsoleInterceptor.js +74 -22
- package/dist/esm/src/server/components/fastapi/console/ConsoleInterceptor.js.map +1 -1
- package/dist/esm/src/server/components/fastapi/console/types.js +0 -1
- package/dist/esm/src/server/components/fastapi/console/types.js.map +1 -1
- package/dist/esm/src/server/const/default.js +75 -0
- package/dist/esm/src/server/const/default.js.map +1 -1
- package/dist/esm/src/server/handlers/NotFoundHandler.js +1 -1
- package/dist/index.d.ts +112 -109
- package/package.json +2 -1
- package/dist/cjs/src/plugins/core/PluginAPI.js +0 -80
- package/dist/cjs/src/plugins/core/PluginAPI.js.map +0 -1
- package/dist/cjs/src/server/utils/ConfigLoader.js +0 -306
- package/dist/cjs/src/server/utils/ConfigLoader.js.map +0 -1
- package/dist/esm/src/plugins/core/PluginAPI.js +0 -78
- package/dist/esm/src/plugins/core/PluginAPI.js.map +0 -1
- package/dist/esm/src/server/utils/ConfigLoader.js +0 -283
- package/dist/esm/src/server/utils/ConfigLoader.js.map +0 -1
package/dist/cjs/src/config.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var _default = require('./server/const/default.js');
|
|
4
|
+
|
|
3
5
|
/**
|
|
4
6
|
* XyPriss Configuration Manager
|
|
5
7
|
*
|
|
@@ -10,6 +12,10 @@
|
|
|
10
12
|
* in modular structures where accessing `app.configs` directly might
|
|
11
13
|
* cause initialization timing issues.
|
|
12
14
|
*
|
|
15
|
+
* **IMPORTANT**: This is the SINGLE SOURCE OF TRUTH for all XyPriss configurations.
|
|
16
|
+
* All components should use `Configs.get()` to access configuration values
|
|
17
|
+
* instead of copying values during initialization.
|
|
18
|
+
*
|
|
13
19
|
* @example
|
|
14
20
|
* ```typescript
|
|
15
21
|
* import { Configs } from 'xypriss';
|
|
@@ -28,7 +34,7 @@
|
|
|
28
34
|
* // Get entire config
|
|
29
35
|
* const allConfigs = Configs.getAll();
|
|
30
36
|
*
|
|
31
|
-
* // Update specific config
|
|
37
|
+
* // Update specific config (updates the source of truth)
|
|
32
38
|
* Configs.update('fileUpload', { maxFileSize: 10 * 1024 * 1024 });
|
|
33
39
|
* ```
|
|
34
40
|
*/
|
|
@@ -39,10 +45,12 @@
|
|
|
39
45
|
class ConfigurationManager {
|
|
40
46
|
/**
|
|
41
47
|
* Private constructor to enforce singleton pattern
|
|
48
|
+
* Initializes with default configuration
|
|
42
49
|
*/
|
|
43
50
|
constructor() {
|
|
44
|
-
this.config = {};
|
|
45
51
|
this.initialized = false;
|
|
52
|
+
// Initialize with default configuration
|
|
53
|
+
this.config = { ..._default.DEFAULT_OPTIONS };
|
|
46
54
|
}
|
|
47
55
|
/**
|
|
48
56
|
* Get the singleton instance
|
|
@@ -55,7 +63,7 @@ class ConfigurationManager {
|
|
|
55
63
|
}
|
|
56
64
|
/**
|
|
57
65
|
* Set the entire configuration
|
|
58
|
-
* @param config - Server configuration options
|
|
66
|
+
* @param config - XP Server configuration options
|
|
59
67
|
*/
|
|
60
68
|
static set(config) {
|
|
61
69
|
const instance = ConfigurationManager.getInstance();
|
|
@@ -73,50 +81,68 @@ class ConfigurationManager {
|
|
|
73
81
|
}
|
|
74
82
|
/**
|
|
75
83
|
* Get the entire configuration object
|
|
76
|
-
* @returns Complete
|
|
84
|
+
* @returns Complete XyPriss Server Configuration (XPSC)
|
|
77
85
|
*/
|
|
78
86
|
static getAll() {
|
|
79
87
|
const instance = ConfigurationManager.getInstance();
|
|
80
88
|
return { ...instance.config };
|
|
81
89
|
}
|
|
82
90
|
/**
|
|
83
|
-
* Update a specific configuration section
|
|
91
|
+
* Update a specific XyPriss configuration section (deep merge)
|
|
84
92
|
* @param key - Configuration key to update
|
|
85
|
-
* @param value -
|
|
93
|
+
* @param value - Partial value to merge with existing configuration
|
|
86
94
|
*/
|
|
87
95
|
static update(key, value) {
|
|
88
96
|
const instance = ConfigurationManager.getInstance();
|
|
89
|
-
instance.config[key]
|
|
97
|
+
const currentValue = instance.config[key];
|
|
98
|
+
// Deep merge the new value with the existing value
|
|
99
|
+
if (typeof currentValue === "object" &&
|
|
100
|
+
currentValue !== null &&
|
|
101
|
+
!Array.isArray(currentValue)) {
|
|
102
|
+
instance.config[key] = {
|
|
103
|
+
...currentValue,
|
|
104
|
+
...value,
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
// For non-object values, just replace
|
|
109
|
+
instance.config[key] = value;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Deep merge helper function
|
|
114
|
+
* @param target - Target object
|
|
115
|
+
* @param source - Source object to merge
|
|
116
|
+
* @returns Merged object
|
|
117
|
+
*/
|
|
118
|
+
static deepMerge(target, source) {
|
|
119
|
+
const result = { ...target };
|
|
120
|
+
for (const key in source) {
|
|
121
|
+
const sourceValue = source[key];
|
|
122
|
+
const targetValue = result[key];
|
|
123
|
+
if (sourceValue &&
|
|
124
|
+
typeof sourceValue === "object" &&
|
|
125
|
+
!Array.isArray(sourceValue) &&
|
|
126
|
+
targetValue &&
|
|
127
|
+
typeof targetValue === "object" &&
|
|
128
|
+
!Array.isArray(targetValue)) {
|
|
129
|
+
// Recursively merge nested objects
|
|
130
|
+
result[key] = ConfigurationManager.deepMerge(targetValue, sourceValue);
|
|
131
|
+
}
|
|
132
|
+
else if (sourceValue !== undefined) {
|
|
133
|
+
// Replace value (including arrays and primitives)
|
|
134
|
+
result[key] = sourceValue;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
return result;
|
|
90
138
|
}
|
|
91
139
|
/**
|
|
92
|
-
* Merge configuration with existing config
|
|
140
|
+
* Merge configuration with existing config (deep merge)
|
|
93
141
|
* @param config - Partial configuration to merge
|
|
94
142
|
*/
|
|
95
143
|
static merge(config) {
|
|
96
144
|
const instance = ConfigurationManager.getInstance();
|
|
97
|
-
instance.config =
|
|
98
|
-
...instance.config,
|
|
99
|
-
...config,
|
|
100
|
-
// Deep merge for nested objects
|
|
101
|
-
server: { ...instance.config.server, ...config.server },
|
|
102
|
-
cache: { ...instance.config.cache, ...config.cache },
|
|
103
|
-
security: { ...instance.config.security, ...config.security },
|
|
104
|
-
performance: {
|
|
105
|
-
...instance.config.performance,
|
|
106
|
-
...config.performance,
|
|
107
|
-
},
|
|
108
|
-
fileUpload: { ...instance.config.fileUpload, ...config.fileUpload },
|
|
109
|
-
monitoring: { ...instance.config.monitoring, ...config.monitoring },
|
|
110
|
-
cluster: { ...instance.config.cluster, ...config.cluster },
|
|
111
|
-
multiServer: {
|
|
112
|
-
...instance.config.multiServer,
|
|
113
|
-
...config.multiServer,
|
|
114
|
-
},
|
|
115
|
-
requestManagement: {
|
|
116
|
-
...instance.config.requestManagement,
|
|
117
|
-
...config.requestManagement,
|
|
118
|
-
},
|
|
119
|
-
};
|
|
145
|
+
instance.config = ConfigurationManager.deepMerge(instance.config, config);
|
|
120
146
|
instance.initialized = true;
|
|
121
147
|
}
|
|
122
148
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sources":["../../../src/config.ts"],"sourcesContent":[null],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"config.js","sources":["../../../src/config.ts"],"sourcesContent":[null],"names":["DEFAULT_OPTIONS"],"mappings":";;;;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCG;AAKH;;;AAGG;AACH,MAAM,oBAAoB,CAAA;AAKtB;;;AAGG;AACH,IAAA,WAAA,GAAA;QANQ,IAAW,CAAA,WAAA,GAAY,KAAK,CAAC;;AAQjC,QAAA,IAAI,CAAC,MAAM,GAAG,EAAE,GAAGA,wBAAe,EAAE,CAAC;KACxC;AAED;;AAEG;AACK,IAA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AQ,GAAG,oBAAoB,CAAC,WAAW,EAAE,CAAC;QACpD,OAAO,QAAQ,CAAC,WAAW,CAAC;KAC/B;AAED;;;AAGG;AACI,IAAA,OAAO,KAAK,GAAA;AACf,QAAA,MAAM,QAAQ,GAAG,oBAAoB,CAAC,WAAW,EAAE,CAAC;AACpD,QAAA,QAAQ,CAAC,MAAM,GAAG,EAAE,CAAC;AACrB,QAAA,QAAQ,CAAC,WAAW,GAAG,KAAK,CAAC;KAChC;AAED;;;;AAIG;IACI,OAAO,GAAG,CAAgC,GAAM,EAAA;AACnD,QAAA,MAAM,QAAQ,GAAG,oBAAoB,CAAC,WAAW,EAAE,CAAC;AACpD,QAAA,OAAO,GAAG,IAAI,QAAQ,CAAC,MAAM,IAAI,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,SAAS,CAAC;KACvE;AAED;;;;;AAKG;AACI,IAAA,OAAO,YAAY,CACtB,GAAM,EACN,YAA8B,EAAA;AAE9B,QAAA,MAAM,QAAQ,GAAG,oBAAoB,CAAC,WAAW,EAAE,CAAC;QACpD,OAAO,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,YAAY,CAAC;KAC/C;AAED;;;AAGG;IACI,OAAO,MAAM,CAAgC,GAAM,EAAA;AACtD,QAAA,MAAM,QAAQ,GAAG,oBAAoB,CAAC,WAAW,EAAE,CAAC;AACpD,QAAA,OAAO,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;KAC/B;AACJ;;;;"}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var FileUploadManager = require('./server/components/fastapi/FileUploadManager.js');
|
|
4
4
|
var Logger = require('../shared/logger/Logger.js');
|
|
5
|
+
var config = require('./config.js');
|
|
5
6
|
var FiUp = require('./FiUp.js');
|
|
6
7
|
|
|
7
8
|
/**
|
|
@@ -56,17 +57,17 @@ class FileUploadAPI {
|
|
|
56
57
|
* ```
|
|
57
58
|
*/
|
|
58
59
|
async initialize(configManager) {
|
|
59
|
-
if (this.initialized) {
|
|
60
|
+
if (this.initialized || config.Configs.get("fileUpload")?.enabled === false) {
|
|
60
61
|
return; // Already initialized
|
|
61
62
|
}
|
|
62
63
|
// Access config internally from the Configs singleton
|
|
63
|
-
const config = configManager.get("fileUpload");
|
|
64
|
-
if (!config) {
|
|
64
|
+
const config$1 = configManager.get("fileUpload");
|
|
65
|
+
if (!config$1) {
|
|
65
66
|
throw new Error("FileUpload configuration not found. Please set fileUpload config in createServer() options or use Configs.set()");
|
|
66
67
|
}
|
|
67
68
|
try {
|
|
68
69
|
this.logger.debug("server", "Initializing FileUploadAPI...");
|
|
69
|
-
this.manager = new FileUploadManager.FileUploadManager(
|
|
70
|
+
this.manager = new FileUploadManager.FileUploadManager(this.logger);
|
|
70
71
|
await this.manager.initialize();
|
|
71
72
|
this.initialized = true;
|
|
72
73
|
this.logger.debug("server", `FileUploadAPI initialized, enabled: ${this.manager.isEnabled()}`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file-upload.js","sources":["../../../src/file-upload.ts"],"sourcesContent":[null],"names":["Logger","FileUploadManager"],"mappings":"
|
|
1
|
+
{"version":3,"file":"file-upload.js","sources":["../../../src/file-upload.ts"],"sourcesContent":[null],"names":["Logger","Configs","config","FileUploadManager"],"mappings":";;;;;;;AAAA;;;;;;;;;;;;;;;;AAgBG;AAUH;;;AAGG;MACU,aAAa,CAAA;AAKtB,IAAA,WAAA,CAAY,MAAe,EAAA;QAJnB,IAAO,CAAA,OAAA,GAA6B,IAAI,CAAC;QAEzC,IAAW,CAAA,WAAA,GAAY,KAAK,CAAC;;AAIjC,QAAA,IAAI,CAAC,MAAM;YACP,MAAM;AACN,gBAAA,IAAIA,aAAM,CAAC;AACP,oBAAA,OAAO,EAAE,IAAI;AACb,oBAAA,KAAK,EAAE,MAAM;AACb,oBAAA,UAAU,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE;AAC9B,oBAAA,KAAK,EAAE,EAAE,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Q,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC,GAAQ,KAAI;gBAChD,IAAI,GAAG,EAAE;oBACL,IAAI,CAAC,iBAAiB,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;iBACzC;qBAAM;AACH,oBAAA,IAAI,EAAE,CAAC;iBACV;AACL,aAAC,CAAC,CAAC;AACP,SAAC,CAAC;KACL;AAED;;;;AAIG;IACH,GAAG,GAAA;AACC,QAAA,OAAO,CAAC,GAAQ,EAAE,GAAQ,EAAE,IAAS,KAAI;AACrC,YAAA,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,EAAE;gBACnB,OAAO,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;AACxB,oBAAA,OAAO,EAAE,KAAK;AACd,oBAAA,KAAK,EAAE,qBAAqB;AAC5B,oBAAA,OAAO,EACH,4EAA4E;AACnF,iBAAA,CAAC,CAAC;aACN;AAED,YAAA,IAAI,CAAC,OAAQ,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC,GAAQ,KAAI;gBACvC,IAAI,GAAG,EAAE;oBACL,IAAI,CAAC,iBAAiB,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;iBACzC;qBAAM;AACH,oBAAA,IAAI,EAAE,CAAC;iBACV;AACL,aAAC,CAAC,CAAC;AACP,SAAC,CAAC;KACL;AACJ,CAAA;AAGD;AACa,MAAA,MAAM,GAAG,IAAI,aAAa;;;;;;;;;;"}
|
package/dist/cjs/src/index.js
CHANGED
|
@@ -9,7 +9,7 @@ var securityMiddleware = require('./middleware/security-middleware.js');
|
|
|
9
9
|
var performanceMonitor = require('./server/optimization/performance-monitor.js');
|
|
10
10
|
var config = require('./config.js');
|
|
11
11
|
var index = require('./plugins/modules/index.js');
|
|
12
|
-
var PluginAPI = require('./plugins/
|
|
12
|
+
var PluginAPI = require('./plugins/api/PluginAPI.js');
|
|
13
13
|
var quickStart = require('./quick-start.js');
|
|
14
14
|
var trustProxy = require('./server/utils/trustProxy.js');
|
|
15
15
|
var safeJsonMiddleware = require('./middleware/safe-json-middleware.js');
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Plugin API
|
|
5
|
+
* Public API for plugin management as documented in PLUGIN_SYSTEM_GUIDE.md
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Global plugin manager instance
|
|
9
|
+
* This will be set by the server when it's created
|
|
10
|
+
*/
|
|
11
|
+
let globalPluginManager = null;
|
|
12
|
+
/**
|
|
13
|
+
* Pending plugins registered before server creation
|
|
14
|
+
*/
|
|
15
|
+
const pendingPlugins = [];
|
|
16
|
+
/**
|
|
17
|
+
* Set the global plugin manager
|
|
18
|
+
* @internal - Used by the server factory
|
|
19
|
+
*/
|
|
20
|
+
function setGlobalPluginManager(manager) {
|
|
21
|
+
globalPluginManager = manager;
|
|
22
|
+
// Register all pending plugins
|
|
23
|
+
for (const { plugin, config } of pendingPlugins) {
|
|
24
|
+
manager.register(plugin, config);
|
|
25
|
+
}
|
|
26
|
+
// Clear pending queue
|
|
27
|
+
pendingPlugins.length = 0;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Get the global plugin manager
|
|
31
|
+
* @internal
|
|
32
|
+
*/
|
|
33
|
+
function getGlobalPluginManager() {
|
|
34
|
+
return globalPluginManager;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Plugin API
|
|
38
|
+
* Provides imperative methods for plugin management
|
|
39
|
+
*/
|
|
40
|
+
const Plugin = {
|
|
41
|
+
/**
|
|
42
|
+
* Register a plugin imperatively
|
|
43
|
+
* @param plugin - Plugin instance or creator function
|
|
44
|
+
* @param config - Optional configuration
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```typescript
|
|
48
|
+
* Plugin.register({
|
|
49
|
+
* name: "my-plugin",
|
|
50
|
+
* version: "1.0.0",
|
|
51
|
+
* onServerStart: () => console.log("Started!")
|
|
52
|
+
* });
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
register(plugin, config) {
|
|
56
|
+
const manager = getGlobalPluginManager();
|
|
57
|
+
if (manager) {
|
|
58
|
+
// Server is already created, register immediately
|
|
59
|
+
manager.register(plugin, config);
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
// Server not created yet, add to pending queue
|
|
63
|
+
pendingPlugins.push({ plugin, config });
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
/**
|
|
67
|
+
* Get a registered plugin by name
|
|
68
|
+
* @param name - Plugin name
|
|
69
|
+
* @returns Plugin instance or undefined if not found
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* ```typescript
|
|
73
|
+
* const plugin = Plugin.get("my-plugin");
|
|
74
|
+
* if (plugin) {
|
|
75
|
+
* console.log(`Found plugin: ${plugin.name}@${plugin.version}`);
|
|
76
|
+
* }
|
|
77
|
+
* ```
|
|
78
|
+
*/
|
|
79
|
+
get(name) {
|
|
80
|
+
const manager = getGlobalPluginManager();
|
|
81
|
+
if (!manager) {
|
|
82
|
+
throw new Error("Plugin system not initialized. Create a server instance first.");
|
|
83
|
+
}
|
|
84
|
+
return manager.getPlugin(name);
|
|
85
|
+
},
|
|
86
|
+
/**
|
|
87
|
+
* Create a plugin (helper method)
|
|
88
|
+
* This is just a type-safe identity function that helps with TypeScript inference
|
|
89
|
+
* @param plugin - Plugin definition
|
|
90
|
+
* @returns The same plugin instance
|
|
91
|
+
*
|
|
92
|
+
* @example
|
|
93
|
+
* ```typescript
|
|
94
|
+
* const myPlugin = Plugin.create({
|
|
95
|
+
* name: "my-plugin",
|
|
96
|
+
* version: "1.0.0",
|
|
97
|
+
* onServerStart: (server) => {
|
|
98
|
+
* console.log("Plugin started!");
|
|
99
|
+
* }
|
|
100
|
+
* });
|
|
101
|
+
* ```
|
|
102
|
+
*/
|
|
103
|
+
create(plugin) {
|
|
104
|
+
return plugin;
|
|
105
|
+
},
|
|
106
|
+
/**
|
|
107
|
+
* Create a plugin factory function
|
|
108
|
+
* Useful for creating reusable plugins with configuration
|
|
109
|
+
* @param creator - Function that creates a plugin from config
|
|
110
|
+
* @returns Plugin creator function
|
|
111
|
+
*
|
|
112
|
+
* @example
|
|
113
|
+
* ```typescript
|
|
114
|
+
* const createMyPlugin = Plugin.factory((config: { apiKey: string }) => ({
|
|
115
|
+
* name: "my-plugin",
|
|
116
|
+
* version: "1.0.0",
|
|
117
|
+
* onServerStart: (server) => {
|
|
118
|
+
* server.apiKey = config.apiKey;
|
|
119
|
+
* }
|
|
120
|
+
* }));
|
|
121
|
+
*
|
|
122
|
+
* // Use it
|
|
123
|
+
* const plugin = createMyPlugin({ apiKey: "secret" });
|
|
124
|
+
* Plugin.register(plugin);
|
|
125
|
+
* ```
|
|
126
|
+
*/
|
|
127
|
+
factory(creator) {
|
|
128
|
+
return creator;
|
|
129
|
+
},
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
exports.Plugin = Plugin;
|
|
133
|
+
exports.getGlobalPluginManager = getGlobalPluginManager;
|
|
134
|
+
exports.setGlobalPluginManager = setGlobalPluginManager;
|
|
135
|
+
//# sourceMappingURL=PluginAPI.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PluginAPI.js","sources":["../../../../../src/plugins/api/PluginAPI.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAAA;;;AAGG;AAKH;;;AAGG;AACH,IAAI,mBAAmB,GAAyB,IAAI,CAAC;AAErD;;AAEG;AACH,MAAM,cAAc,GAGf,EAAE,CAAC;AAER;;;AAGG;AACG,SAAU,sBAAsB,CAAC,OAAsB,EAAA;IACzD,mBAAmB,GAAG,OAAO,CAAC;;IAG9B,KAAK,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,cAAc,EAAE;AAC7C,QAAA,OAAO,CAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;KACpC;;AAGD,IAAA,cAAc,CAAC,MAAM,GAAG,CAAC,CAAC;AAC9B,CAAC;AAED;;;AAGG;SACa,sBAAsB,GAAA;AAClC,IAAA,OAAO,mBAAmB,CAAC;AAC/B,CAAC;AAED;;;AAGG;AACU,MAAA,MAAM,GAAG;AAClB;;;;;;;;;;;;;AAaG;IACH,QAAQ,CAAC,MAAqC,EAAE,MAAY,EAAA;AACxD,QAAA,MAAM,OAAO,GAAG,sBAAsB,EAAE,CAAC;QAEzC,IAAI,OAAO,EAAE;;AAET,YAAA,OAAO,CAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;SACpC;aAAM;;YAEH,cAAc,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;SAC3C;KACJ;AAED;;;;;;;;;;;;AAYG;AACH,IAAA,GAAG,CAAC,IAAY,EAAA;AACZ,QAAA,MAAM,OAAO,GAAG,sBAAsB,EAAE,CAAC;QAEzC,IAAI,CAAC,OAAO,EAAE;AACV,YAAA,MAAM,IAAI,KAAK,CACX,gEAAgE,CACnE,CAAC;SACL;AAED,QAAA,OAAO,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;KAClC;AAED;;;;;;;;;;;;;;;;AAgBG;AACH,IAAA,MAAM,CAAC,MAAqB,EAAA;AACxB,QAAA,OAAO,MAAM,CAAC;KACjB;AAED;;;;;;;;;;;;;;;;;;;;AAoBG;AACH,IAAA,OAAO,CACH,OAA2C,EAAA;AAE3C,QAAA,OAAO,OAAwB,CAAC;KACnC;;;;;;;"}
|
|
@@ -10,6 +10,7 @@ class PluginManager {
|
|
|
10
10
|
constructor(server) {
|
|
11
11
|
this.plugins = new Map();
|
|
12
12
|
this.pluginOrder = [];
|
|
13
|
+
this.initialized = false;
|
|
13
14
|
this.server = server;
|
|
14
15
|
this.logger = new Logger.Logger();
|
|
15
16
|
}
|
|
@@ -35,12 +36,57 @@ class PluginManager {
|
|
|
35
36
|
pluginInstance.onRegister(this.server, config);
|
|
36
37
|
}
|
|
37
38
|
this.logger.info("plugins", `Registered plugin: xypriss::ext/${pluginInstance.name}@${pluginInstance.version}`);
|
|
39
|
+
// If already initialized, fully initialize this plugin immediately
|
|
40
|
+
if (this.initialized) {
|
|
41
|
+
// Resolve dependencies for this plugin
|
|
42
|
+
this.resolveDependencies();
|
|
43
|
+
// Register routes for this plugin
|
|
44
|
+
if (pluginInstance.registerRoutes) {
|
|
45
|
+
try {
|
|
46
|
+
pluginInstance.registerRoutes(this.server.app);
|
|
47
|
+
this.logger.debug("plugins", `Registered routes for late plugin: ${pluginInstance.name}`);
|
|
48
|
+
}
|
|
49
|
+
catch (error) {
|
|
50
|
+
this.logger.error("plugins", `Error registering routes for ${pluginInstance.name}:`, error);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
// Apply middleware for this plugin
|
|
54
|
+
if (pluginInstance.middleware || pluginInstance.onRequest) {
|
|
55
|
+
pluginInstance.middlewarePriority || "normal";
|
|
56
|
+
const middleware = [];
|
|
57
|
+
if (pluginInstance.middleware) {
|
|
58
|
+
const mw = Array.isArray(pluginInstance.middleware)
|
|
59
|
+
? pluginInstance.middleware
|
|
60
|
+
: [pluginInstance.middleware];
|
|
61
|
+
middleware.push(...mw);
|
|
62
|
+
}
|
|
63
|
+
if (pluginInstance.onRequest) {
|
|
64
|
+
middleware.push(pluginInstance.onRequest.bind(pluginInstance));
|
|
65
|
+
}
|
|
66
|
+
// Apply middleware based on priority
|
|
67
|
+
middleware.forEach((mw) => this.server.app.use(mw));
|
|
68
|
+
this.logger.debug("plugins", `Applied middleware for late plugin: ${pluginInstance.name}`);
|
|
69
|
+
}
|
|
70
|
+
// Call onServerStart hook
|
|
71
|
+
if (pluginInstance.onServerStart) {
|
|
72
|
+
Promise.resolve(pluginInstance.onServerStart(this.server)).catch((error) => {
|
|
73
|
+
this.logger.error("plugins", `Error in ${pluginInstance.name}.onServerStart:`, error);
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
// Call onServerReady hook if server is ready
|
|
77
|
+
if (pluginInstance.onServerReady) {
|
|
78
|
+
Promise.resolve(pluginInstance.onServerReady(this.server)).catch((error) => {
|
|
79
|
+
this.logger.error("plugins", `Error in ${pluginInstance.name}.onServerReady:`, error);
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
}
|
|
38
83
|
}
|
|
39
84
|
/**
|
|
40
85
|
* Initialize all plugins (resolve dependencies and set execution order)
|
|
41
86
|
*/
|
|
42
87
|
async initialize() {
|
|
43
88
|
this.resolveDependencies();
|
|
89
|
+
this.initialized = true; // Set before calling hooks so late-registered plugins are detected
|
|
44
90
|
await this.executeHook("onServerStart");
|
|
45
91
|
}
|
|
46
92
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PluginManager.js","sources":["../../../../../src/plugins/core/PluginManager.ts"],"sourcesContent":[null],"names":["Logger"],"mappings":";;;;AAAA;;;AAGG;MAUU,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"PluginManager.js","sources":["../../../../../src/plugins/core/PluginManager.ts"],"sourcesContent":[null],"names":["Logger"],"mappings":";;;;AAAA;;;AAGG;MAUU,aAAa,CAAA;AAOtB,IAAA,WAAA,CAAY,MAAqB,EAAA;AANzB,QAAA,IAAA,CAAA,OAAO,GAA+B,IAAI,GAAG,EAAE,CAAC;QAChD,IAAW,CAAA,WAAA,GAAa,EAAE,CAAC;QAG3B,IAAW,CAAA,WAAA,GAAY,KAAK,CAAC;AAGjC,QAAA,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;AACrB,QAAA,IAAI,CAAC,MAAM,GAAG,IAAIA,aAAM,EAAE,CAAC;KAC9B;AAED;;AAEG;IACH,QAAQ,CAAC,MAAqC,EAAE,MAAY,EAAA;;AAExD,QAAA,MAAM,cAAc,GAChB,OAAO,MAAM,KAAK,UAAU,GAAG,MAAM,CAA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O,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;AAEtC,YAAA,IAAI,MAAM,EAAE,YAAY,EAAE;AACtB,gBAAA,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,YAAY,EAAE;oBACnC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE;wBACxB,MAAM,IAAI,KAAK,CACX,CAAA,QAAA,EAAW,IAAI,CAAiB,cAAA,EAAA,GAAG,CAA2B,yBAAA,CAAA,CACjE,CAAC;qBACL;oBACD,KAAK,CAAC,GAAG,CAAC,CAAC;iBACd;aACJ;AAED,YAAA,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;AAClB,YAAA,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;AAClB,YAAA,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACrB,SAAC,CAAC;;QAGF,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE;YACpC,KAAK,CAAC,IAAI,CAAC,CAAC;SACf;AAED,QAAA,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC;QACzB,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,SAAS,EAAE,yBAAyB,EAAE,KAAK,CAAC,CAAC;KAClE;AAED;;AAEG;AACH,IAAA,MAAM,QAAQ,GAAA;AACV,QAAA,MAAM,IAAI,CAAC,WAAW,CAAC,cAAc,CAAC,CAAC;KAC1C;AACJ;;;;"}
|
|
@@ -55,9 +55,9 @@ require('../cache/SecureCacheAdapter.js');
|
|
|
55
55
|
var pluginManager = require('../plugins/plugin-manager.js');
|
|
56
56
|
var PluginManager = require('./components/fastapi/PluginManager.js');
|
|
57
57
|
var _default = require('./const/default.js');
|
|
58
|
-
var ConfigLoader = require('./utils/ConfigLoader.js');
|
|
59
58
|
var PortManager = require('./utils/PortManager.js');
|
|
60
59
|
var forceClosePort = require('./utils/forceClosePort.js');
|
|
60
|
+
var config = require('../config.js');
|
|
61
61
|
var safeJsonMiddleware = require('../middleware/safe-json-middleware.js');
|
|
62
62
|
var CacheManager = require('./components/fastapi/CacheManager.js');
|
|
63
63
|
var ClusterManagerComponent = require('./components/fastapi/ClusterManagerComponent.js');
|
|
@@ -65,6 +65,7 @@ var FileUploadManager = require('./components/fastapi/FileUploadManager.js');
|
|
|
65
65
|
var FileWatcherManager = require('./components/fastapi/FileWatcherManager.js');
|
|
66
66
|
var PerformanceManager = require('./components/fastapi/PerformanceManager.js');
|
|
67
67
|
var WorkerPoolComponent = require('./components/fastapi/WorkerPoolComponent.js');
|
|
68
|
+
var ConsoleInterceptor = require('./components/fastapi/console/ConsoleInterceptor.js');
|
|
68
69
|
var networkConnectionConf = require('./conf/networkConnectionConf.js');
|
|
69
70
|
var proxyConfig = require('./conf/proxyConfig.js');
|
|
70
71
|
var securityMiddleware = require('../middleware/security-middleware.js');
|
|
@@ -78,20 +79,22 @@ var ServerLifecycleManager = require('./components/lifecycle/ServerLifecycleMana
|
|
|
78
79
|
* Ultra-Fast Express Server with Advanced Performance Optimization
|
|
79
80
|
*/
|
|
80
81
|
class XyPrissServer {
|
|
81
|
-
constructor(
|
|
82
|
-
server: {
|
|
83
|
-
enableMiddleware: true,
|
|
84
|
-
},
|
|
85
|
-
}) {
|
|
82
|
+
constructor() {
|
|
86
83
|
this.ready = false;
|
|
87
84
|
this.initPromise = Promise.resolve();
|
|
88
|
-
//
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
// Initialize logger with user configuration
|
|
85
|
+
// Read configuration from Configs (single source of truth)
|
|
86
|
+
// Configs already has defaults merged with user options from ServerFactory
|
|
87
|
+
this.options = config.Configs.getAll();
|
|
88
|
+
// Initialize logger with configuration from Configs
|
|
93
89
|
this.logger = Logger.initializeLogger(this.options.logging);
|
|
94
90
|
this.logger.startup("server", "Creating server...");
|
|
91
|
+
// Initialize console interceptor SYNCHRONOUSLY if enabled
|
|
92
|
+
// This must happen BEFORE any user code executes to intercept console.log
|
|
93
|
+
if (this.options.logging?.consoleInterception?.enabled) {
|
|
94
|
+
this.consoleInterceptor = new ConsoleInterceptor.ConsoleInterceptor(this.logger, this.options.logging);
|
|
95
|
+
this.consoleInterceptor.start();
|
|
96
|
+
this.logger.debug("server", "Console interceptor started synchronously");
|
|
97
|
+
}
|
|
95
98
|
// Create custom HTTP server app (Express-free)
|
|
96
99
|
this.app = new XyprissApp.XyprissApp(this.logger, this.options);
|
|
97
100
|
// Expose logger on app object for debugging
|
|
@@ -100,8 +103,6 @@ class XyPrissServer {
|
|
|
100
103
|
this.initializeFileUploadMethodsSync();
|
|
101
104
|
// Initialize lifecycle manager
|
|
102
105
|
this.initializeLifecycleManager();
|
|
103
|
-
// Initialize file upload methods synchronously (before async initialization)
|
|
104
|
-
this.initializeFileUploadMethodsSync();
|
|
105
106
|
// Add automatic JSON and URL-encoded body parsing (unless disabled)
|
|
106
107
|
if (this.options.server?.autoParseJson !== false) {
|
|
107
108
|
this.addBodyParsingMiddleware();
|
|
@@ -119,7 +120,7 @@ class XyPrissServer {
|
|
|
119
120
|
*/
|
|
120
121
|
initializeFileUploadMethodsSync() {
|
|
121
122
|
// Create a temporary FileUploadManager for synchronous access
|
|
122
|
-
new FileUploadManager.FileUploadManager(this.
|
|
123
|
+
new FileUploadManager.FileUploadManager(this.logger);
|
|
123
124
|
// Add upload methods to app immediately (they will be replaced with real ones after async init)
|
|
124
125
|
this.app.uploadSingle = (fieldname) => {
|
|
125
126
|
// Return a middleware that will be replaced after initialization
|
|
@@ -312,7 +313,7 @@ class XyPrissServer {
|
|
|
312
313
|
async initializeDependentComponents() {
|
|
313
314
|
// Initialize file upload manager
|
|
314
315
|
this.logger.debug("server", "🔄 Initializing FileUploadManager...");
|
|
315
|
-
this.fileUploadManager = new FileUploadManager.FileUploadManager(this.
|
|
316
|
+
this.fileUploadManager = new FileUploadManager.FileUploadManager(this.logger);
|
|
316
317
|
try {
|
|
317
318
|
await this.fileUploadManager.initialize();
|
|
318
319
|
this.logger.debug("server", `✅ FileUploadManager initialized, enabled: ${this.fileUploadManager.isEnabled()}`);
|
|
@@ -406,6 +407,7 @@ class XyPrissServer {
|
|
|
406
407
|
}
|
|
407
408
|
/**
|
|
408
409
|
* Wait for full initialization (cache, console interceptor, and all components)
|
|
410
|
+
* This method is called automatically by the lifecycle manager
|
|
409
411
|
*/
|
|
410
412
|
async waitForReady() {
|
|
411
413
|
// Wait for cache initialization
|
|
@@ -416,6 +418,17 @@ class XyPrissServer {
|
|
|
416
418
|
// Give console interceptor a moment to fully initialize
|
|
417
419
|
await new Promise((resolve) => setTimeout(resolve, 10));
|
|
418
420
|
}
|
|
421
|
+
// Auto-initialize Upload API if fileUpload is enabled
|
|
422
|
+
if (config.Configs.get("fileUpload")?.enabled) {
|
|
423
|
+
try {
|
|
424
|
+
const { Upload } = await Promise.resolve().then(function () { return require('../file-upload.js'); });
|
|
425
|
+
await Upload.initialize(config.Configs);
|
|
426
|
+
this.logger.debug("server", "Upload API auto-initialized");
|
|
427
|
+
}
|
|
428
|
+
catch (error) {
|
|
429
|
+
this.logger.error("server", "Failed to auto-initialize Upload API:", error.message);
|
|
430
|
+
}
|
|
431
|
+
}
|
|
419
432
|
// Mark as ready
|
|
420
433
|
this.ready = true;
|
|
421
434
|
this.logger.debug("server", "All components initialized and ready");
|