@morojs/moro 1.4.0 → 1.5.1
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/core/config/index.d.ts +0 -1
- package/dist/core/config/index.js +0 -4
- package/dist/core/config/index.js.map +1 -1
- package/dist/core/config/loader.js +219 -226
- package/dist/core/config/loader.js.map +1 -1
- package/dist/core/config/schema.d.ts +30 -335
- package/dist/core/config/schema.js +133 -224
- package/dist/core/config/schema.js.map +1 -1
- package/dist/core/config/utils.d.ts +3 -2
- package/dist/core/config/utils.js.map +1 -1
- package/dist/core/config/validation.d.ts +0 -1
- package/dist/core/config/validation.js +7 -10
- package/dist/core/config/validation.js.map +1 -1
- package/dist/core/database/adapters/drizzle.js +6 -1
- package/dist/core/database/adapters/drizzle.js.map +1 -1
- package/dist/core/database/adapters/mongodb.js +5 -1
- package/dist/core/database/adapters/mongodb.js.map +1 -1
- package/dist/core/database/adapters/mysql.js +3 -1
- package/dist/core/database/adapters/mysql.js.map +1 -1
- package/dist/core/database/adapters/postgresql.js +3 -1
- package/dist/core/database/adapters/postgresql.js.map +1 -1
- package/dist/core/database/adapters/redis.js +5 -1
- package/dist/core/database/adapters/redis.js.map +1 -1
- package/dist/core/database/adapters/sqlite.js +3 -1
- package/dist/core/database/adapters/sqlite.js.map +1 -1
- package/dist/core/docs/index.js +6 -1
- package/dist/core/docs/index.js.map +1 -1
- package/dist/core/docs/openapi-generator.js +4 -3
- package/dist/core/docs/openapi-generator.js.map +1 -1
- package/dist/core/docs/simple-docs.js +7 -6
- package/dist/core/docs/simple-docs.js.map +1 -1
- package/dist/core/docs/swagger-ui.js +3 -0
- package/dist/core/docs/swagger-ui.js.map +1 -1
- package/dist/core/docs/zod-to-openapi.d.ts +2 -3
- package/dist/core/docs/zod-to-openapi.js +28 -0
- package/dist/core/docs/zod-to-openapi.js.map +1 -1
- package/dist/core/events/event-bus.js +17 -14
- package/dist/core/events/event-bus.js.map +1 -1
- package/dist/core/framework.js +13 -2
- package/dist/core/framework.js.map +1 -1
- package/dist/core/http/http-server.d.ts +2 -0
- package/dist/core/http/http-server.js +117 -69
- package/dist/core/http/http-server.js.map +1 -1
- package/dist/core/http/router.js +2 -4
- package/dist/core/http/router.js.map +1 -1
- package/dist/core/logger/logger.js +38 -34
- package/dist/core/logger/logger.js.map +1 -1
- package/dist/core/logger/outputs.js +12 -5
- package/dist/core/logger/outputs.js.map +1 -1
- package/dist/core/middleware/built-in/adapters/cache/file.js +1 -0
- package/dist/core/middleware/built-in/adapters/cache/file.js.map +1 -1
- package/dist/core/middleware/built-in/adapters/cache/memory.js +2 -4
- package/dist/core/middleware/built-in/adapters/cache/memory.js.map +1 -1
- package/dist/core/middleware/built-in/adapters/cache/redis.js +1 -0
- package/dist/core/middleware/built-in/adapters/cache/redis.js.map +1 -1
- package/dist/core/middleware/built-in/adapters/cdn/azure.js +5 -0
- package/dist/core/middleware/built-in/adapters/cdn/azure.js.map +1 -1
- package/dist/core/middleware/built-in/adapters/cdn/cloudflare.js +2 -0
- package/dist/core/middleware/built-in/adapters/cdn/cloudflare.js.map +1 -1
- package/dist/core/middleware/built-in/adapters/cdn/cloudfront.js +2 -0
- package/dist/core/middleware/built-in/adapters/cdn/cloudfront.js.map +1 -1
- package/dist/core/middleware/built-in/session.js +6 -3
- package/dist/core/middleware/built-in/session.js.map +1 -1
- package/dist/core/middleware/index.js +4 -3
- package/dist/core/middleware/index.js.map +1 -1
- package/dist/core/modules/auto-discovery.js +4 -4
- package/dist/core/modules/auto-discovery.js.map +1 -1
- package/dist/core/modules/modules.js +1 -0
- package/dist/core/modules/modules.js.map +1 -1
- package/dist/core/networking/adapters/socketio-adapter.js +6 -1
- package/dist/core/networking/adapters/socketio-adapter.js.map +1 -1
- package/dist/core/networking/adapters/ws-adapter.js +22 -13
- package/dist/core/networking/adapters/ws-adapter.js.map +1 -1
- package/dist/core/networking/service-discovery.js +3 -1
- package/dist/core/networking/service-discovery.js.map +1 -1
- package/dist/core/networking/websocket-manager.js +24 -22
- package/dist/core/networking/websocket-manager.js.map +1 -1
- package/dist/core/routing/app-integration.js +3 -7
- package/dist/core/routing/app-integration.js.map +1 -1
- package/dist/core/routing/index.js +2 -0
- package/dist/core/routing/index.js.map +1 -1
- package/dist/core/runtime/aws-lambda-adapter.js +1 -4
- package/dist/core/runtime/aws-lambda-adapter.js.map +1 -1
- package/dist/core/runtime/cloudflare-workers-adapter.js +1 -4
- package/dist/core/runtime/cloudflare-workers-adapter.js.map +1 -1
- package/dist/core/runtime/node-adapter.js +1 -4
- package/dist/core/runtime/node-adapter.js.map +1 -1
- package/dist/core/runtime/vercel-edge-adapter.js +1 -4
- package/dist/core/runtime/vercel-edge-adapter.js.map +1 -1
- package/dist/core/utilities/circuit-breaker.js +4 -3
- package/dist/core/utilities/circuit-breaker.js.map +1 -1
- package/dist/core/utilities/container.js +19 -17
- package/dist/core/utilities/container.js.map +1 -1
- package/dist/core/utilities/hooks.js +4 -4
- package/dist/core/utilities/hooks.js.map +1 -1
- package/dist/core/validation/adapters.js +6 -0
- package/dist/core/validation/adapters.js.map +1 -1
- package/dist/core/validation/index.d.ts +0 -2
- package/dist/core/validation/index.js +3 -8
- package/dist/core/validation/index.js.map +1 -1
- package/dist/core/validation/schema-interface.js +1 -0
- package/dist/core/validation/schema-interface.js.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +9 -1
- package/dist/index.js.map +1 -1
- package/dist/moro.d.ts +1 -0
- package/dist/moro.js +73 -58
- package/dist/moro.js.map +1 -1
- package/dist/types/auth.js +6 -3
- package/dist/types/auth.js.map +1 -1
- package/dist/{core/config/types.d.ts → types/config.d.ts} +0 -1
- package/dist/types/config.js +4 -0
- package/dist/types/config.js.map +1 -0
- package/dist/types/core.d.ts +20 -0
- package/package.json +6 -7
- package/src/core/config/index.ts +0 -3
- package/src/core/config/loader.ts +571 -247
- package/src/core/config/schema.ts +146 -279
- package/src/core/config/utils.ts +1 -2
- package/src/core/config/validation.ts +5 -10
- package/src/core/docs/index.ts +1 -1
- package/src/core/docs/simple-docs.ts +5 -5
- package/src/core/docs/zod-to-openapi.ts +50 -20
- package/src/core/http/http-server.ts +61 -7
- package/src/core/networking/websocket-manager.ts +17 -17
- package/src/core/validation/index.ts +2 -8
- package/src/index.ts +11 -1
- package/src/moro.ts +47 -43
- package/src/{core/config/types.ts → types/config.ts} +0 -120
- package/src/types/core.ts +21 -0
- package/tsconfig.json +2 -2
- package/dist/core/config/types.js +0 -124
- package/dist/core/config/types.js.map +0 -1
- package/dist/core/config/typescript-loader.d.ts +0 -6
- package/dist/core/config/typescript-loader.js +0 -268
- package/dist/core/config/typescript-loader.js.map +0 -1
- package/src/core/config/typescript-loader.ts +0 -571
|
@@ -18,7 +18,7 @@ export class MoroHttpServer {
|
|
|
18
18
|
private hookManager: any;
|
|
19
19
|
private requestCounter = 0;
|
|
20
20
|
|
|
21
|
-
//
|
|
21
|
+
// Efficient object pooling with minimal overhead
|
|
22
22
|
private paramObjectPool: Record<string, string>[] = [];
|
|
23
23
|
private bufferPool: Buffer[] = [];
|
|
24
24
|
private readonly maxPoolSize = 50;
|
|
@@ -213,6 +213,9 @@ export class MoroHttpServer {
|
|
|
213
213
|
const httpReq = this.enhanceRequest(req);
|
|
214
214
|
const httpRes = this.enhanceResponse(res);
|
|
215
215
|
|
|
216
|
+
// Store original params for efficient cleanup
|
|
217
|
+
const originalParams = httpReq.params;
|
|
218
|
+
|
|
216
219
|
try {
|
|
217
220
|
// Optimized URL and query parsing
|
|
218
221
|
const urlString = req.url!;
|
|
@@ -327,15 +330,47 @@ export class MoroHttpServer {
|
|
|
327
330
|
}
|
|
328
331
|
}
|
|
329
332
|
}
|
|
333
|
+
} finally {
|
|
334
|
+
// CRITICAL: Always release pooled objects back to the pool
|
|
335
|
+
// This prevents memory leaks and ensures consistent performance
|
|
336
|
+
if (originalParams && Object.keys(originalParams).length === 0) {
|
|
337
|
+
this.releaseParamObject(originalParams);
|
|
338
|
+
}
|
|
339
|
+
if (
|
|
340
|
+
httpReq.params &&
|
|
341
|
+
httpReq.params !== originalParams &&
|
|
342
|
+
Object.keys(httpReq.params).length === 0
|
|
343
|
+
) {
|
|
344
|
+
this.releaseParamObject(httpReq.params);
|
|
345
|
+
}
|
|
330
346
|
}
|
|
347
|
+
|
|
348
|
+
// Additional cleanup on response completion to ensure objects are returned to pool
|
|
349
|
+
res.once('finish', () => {
|
|
350
|
+
if (originalParams && Object.keys(originalParams).length === 0) {
|
|
351
|
+
this.releaseParamObject(originalParams);
|
|
352
|
+
}
|
|
353
|
+
if (
|
|
354
|
+
httpReq.params &&
|
|
355
|
+
httpReq.params !== originalParams &&
|
|
356
|
+
Object.keys(httpReq.params).length === 0
|
|
357
|
+
) {
|
|
358
|
+
this.releaseParamObject(httpReq.params);
|
|
359
|
+
}
|
|
360
|
+
});
|
|
331
361
|
}
|
|
332
362
|
|
|
333
|
-
//
|
|
363
|
+
// Efficient object pooling for parameter objects with ES2022 optimizations
|
|
334
364
|
private acquireParamObject(): Record<string, string> {
|
|
335
365
|
const obj = this.paramObjectPool.pop();
|
|
336
366
|
if (obj) {
|
|
337
|
-
//
|
|
338
|
-
|
|
367
|
+
// ES2022: Use Object.hasOwn for safer property checks and faster clearing
|
|
368
|
+
// Clear existing properties more efficiently
|
|
369
|
+
for (const key in obj) {
|
|
370
|
+
if (Object.hasOwn(obj, key)) {
|
|
371
|
+
delete obj[key];
|
|
372
|
+
}
|
|
373
|
+
}
|
|
339
374
|
return obj;
|
|
340
375
|
}
|
|
341
376
|
return {};
|
|
@@ -347,10 +382,24 @@ export class MoroHttpServer {
|
|
|
347
382
|
}
|
|
348
383
|
}
|
|
349
384
|
|
|
385
|
+
// Force cleanup of all pooled objects
|
|
386
|
+
private forceCleanupPools(): void {
|
|
387
|
+
// ES2022: More efficient array clearing
|
|
388
|
+
this.paramObjectPool.splice(0);
|
|
389
|
+
this.bufferPool.splice(0);
|
|
390
|
+
|
|
391
|
+
// Force garbage collection if available
|
|
392
|
+
// Use modern globalThis check with optional chaining
|
|
393
|
+
if (globalThis?.gc) {
|
|
394
|
+
globalThis.gc();
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
|
|
350
398
|
private acquireBuffer(size: number): Buffer {
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
399
|
+
// ES2022: Use findIndex for better performance than find + indexOf
|
|
400
|
+
const index = this.bufferPool.findIndex(b => b.length >= size);
|
|
401
|
+
if (index !== -1) {
|
|
402
|
+
const buffer = this.bufferPool.splice(index, 1)[0];
|
|
354
403
|
return buffer.subarray(0, size);
|
|
355
404
|
}
|
|
356
405
|
return Buffer.allocUnsafe(size);
|
|
@@ -893,6 +942,11 @@ export class MoroHttpServer {
|
|
|
893
942
|
});
|
|
894
943
|
}
|
|
895
944
|
|
|
945
|
+
// Public method to force cleanup
|
|
946
|
+
forceCleanup(): void {
|
|
947
|
+
this.forceCleanupPools();
|
|
948
|
+
}
|
|
949
|
+
|
|
896
950
|
getServer(): Server {
|
|
897
951
|
return this.server;
|
|
898
952
|
}
|
|
@@ -128,26 +128,26 @@ export class WebSocketManager {
|
|
|
128
128
|
return;
|
|
129
129
|
}
|
|
130
130
|
|
|
131
|
-
//
|
|
131
|
+
// Universal validation (works with any ValidationSchema)
|
|
132
132
|
if (wsConfig.validation) {
|
|
133
133
|
try {
|
|
134
|
-
data = wsConfig.validation.
|
|
134
|
+
data = await wsConfig.validation.parseAsync(data);
|
|
135
135
|
} catch (validationError: any) {
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
136
|
+
// Handle universal validation errors
|
|
137
|
+
const { normalizeValidationError } = require('../validation/schema-interface');
|
|
138
|
+
const normalizedError = normalizeValidationError(validationError);
|
|
139
|
+
const error = {
|
|
140
|
+
success: false,
|
|
141
|
+
error: 'Validation failed',
|
|
142
|
+
details: normalizedError.issues.map((issue: any) => ({
|
|
143
|
+
field: issue.path.length > 0 ? issue.path.join('.') : 'data',
|
|
144
|
+
message: issue.message,
|
|
145
|
+
code: issue.code,
|
|
146
|
+
})),
|
|
147
|
+
};
|
|
148
|
+
if (callback) callback(error);
|
|
149
|
+
else socket.emit('error', error);
|
|
150
|
+
return;
|
|
151
151
|
}
|
|
152
152
|
}
|
|
153
153
|
|
|
@@ -11,12 +11,7 @@ import {
|
|
|
11
11
|
} from './schema-interface';
|
|
12
12
|
|
|
13
13
|
// Re-export zod if available (for backward compatibility)
|
|
14
|
-
|
|
15
|
-
try {
|
|
16
|
-
z = require('zod').z;
|
|
17
|
-
} catch {
|
|
18
|
-
// Zod not available - that's fine!
|
|
19
|
-
}
|
|
14
|
+
// The dynamic import is handled in the main index.ts
|
|
20
15
|
|
|
21
16
|
const logger = createFrameworkLogger('Validation');
|
|
22
17
|
|
|
@@ -208,5 +203,4 @@ export {
|
|
|
208
203
|
} from './schema-interface';
|
|
209
204
|
export { joi, yup, fn as customValidator, classValidator } from './adapters';
|
|
210
205
|
|
|
211
|
-
//
|
|
212
|
-
export { z };
|
|
206
|
+
// Note: z is re-exported from main index.ts with dynamic import
|
package/src/index.ts
CHANGED
|
@@ -106,7 +106,17 @@ export type {
|
|
|
106
106
|
export { createFrameworkLogger, logger } from './core/logger';
|
|
107
107
|
|
|
108
108
|
// Universal Validation System
|
|
109
|
-
export { validate, body, query, params, combineSchemas
|
|
109
|
+
export { validate, body, query, params, combineSchemas } from './core/validation';
|
|
110
|
+
|
|
111
|
+
// Dynamic Zod export (optional dependency)
|
|
112
|
+
let z: any;
|
|
113
|
+
try {
|
|
114
|
+
z = require('zod').z;
|
|
115
|
+
} catch {
|
|
116
|
+
// Zod not available - that's fine!
|
|
117
|
+
z = undefined;
|
|
118
|
+
}
|
|
119
|
+
export { z };
|
|
110
120
|
export type {
|
|
111
121
|
ValidationConfig,
|
|
112
122
|
ValidationResult,
|
package/src/moro.ts
CHANGED
|
@@ -95,6 +95,28 @@ export class Moro extends EventEmitter {
|
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
97
|
|
|
98
|
+
// Apply modules configuration from createApp options (takes precedence)
|
|
99
|
+
if (options.modules) {
|
|
100
|
+
if (options.modules.cache) {
|
|
101
|
+
this.config.modules.cache = {
|
|
102
|
+
...this.config.modules.cache,
|
|
103
|
+
...options.modules.cache,
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
if (options.modules.rateLimit) {
|
|
107
|
+
this.config.modules.rateLimit = {
|
|
108
|
+
...this.config.modules.rateLimit,
|
|
109
|
+
...options.modules.rateLimit,
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
if (options.modules.validation) {
|
|
113
|
+
this.config.modules.validation = {
|
|
114
|
+
...this.config.modules.validation,
|
|
115
|
+
...options.modules.validation,
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
98
120
|
this.logger.info(
|
|
99
121
|
`Configuration system initialized: ${this.config.server.environment}:${this.config.server.port}`
|
|
100
122
|
);
|
|
@@ -713,6 +735,14 @@ export class Moro extends EventEmitter {
|
|
|
713
735
|
return this.coreFramework;
|
|
714
736
|
}
|
|
715
737
|
|
|
738
|
+
// Force cleanup of pooled objects
|
|
739
|
+
forceCleanup(): void {
|
|
740
|
+
const httpServer = (this.coreFramework as any).httpServer;
|
|
741
|
+
if (httpServer && httpServer.forceCleanup) {
|
|
742
|
+
httpServer.forceCleanup();
|
|
743
|
+
}
|
|
744
|
+
}
|
|
745
|
+
|
|
716
746
|
// Private methods
|
|
717
747
|
private addRoute(method: string, path: string, handler: Function, options: any = {}) {
|
|
718
748
|
const handlerName = `handler_${this.routes.length}`;
|
|
@@ -770,25 +800,26 @@ export class Moro extends EventEmitter {
|
|
|
770
800
|
// Enhance request with events property for direct routes
|
|
771
801
|
req.events = this.eventBus;
|
|
772
802
|
|
|
773
|
-
//
|
|
803
|
+
// Universal validation middleware (works with any ValidationSchema)
|
|
774
804
|
if (route.validation) {
|
|
775
805
|
try {
|
|
776
|
-
const validated = route.validation.
|
|
806
|
+
const validated = await route.validation.parseAsync(req.body);
|
|
777
807
|
req.body = validated;
|
|
778
808
|
} catch (error: any) {
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
809
|
+
// Handle universal validation errors
|
|
810
|
+
const { normalizeValidationError } = require('./core/validation/schema-interface');
|
|
811
|
+
const normalizedError = normalizeValidationError(error);
|
|
812
|
+
res.status(400).json({
|
|
813
|
+
success: false,
|
|
814
|
+
error: 'Validation failed',
|
|
815
|
+
details: normalizedError.issues.map((issue: any) => ({
|
|
816
|
+
field: issue.path.length > 0 ? issue.path.join('.') : 'body',
|
|
817
|
+
message: issue.message,
|
|
818
|
+
code: issue.code,
|
|
819
|
+
})),
|
|
820
|
+
requestId: req.requestId,
|
|
821
|
+
});
|
|
822
|
+
return;
|
|
792
823
|
}
|
|
793
824
|
}
|
|
794
825
|
|
|
@@ -1133,34 +1164,7 @@ export class Moro extends EventEmitter {
|
|
|
1133
1164
|
|
|
1134
1165
|
// Export convenience function
|
|
1135
1166
|
export function createApp(options?: MoroOptions): Moro {
|
|
1136
|
-
|
|
1137
|
-
const globalConfig = initializeConfig();
|
|
1138
|
-
|
|
1139
|
-
// Convert global config to MoroOptions format for createApp
|
|
1140
|
-
const configAsOptions: Partial<MoroOptions> = {
|
|
1141
|
-
performance: globalConfig.performance,
|
|
1142
|
-
logger: globalConfig.logging
|
|
1143
|
-
? {
|
|
1144
|
-
level: globalConfig.logging.level,
|
|
1145
|
-
enableColors: globalConfig.logging.enableColors,
|
|
1146
|
-
enableTimestamp: globalConfig.logging.enableTimestamp,
|
|
1147
|
-
}
|
|
1148
|
-
: undefined,
|
|
1149
|
-
// Add other relevant config mappings as needed
|
|
1150
|
-
};
|
|
1151
|
-
|
|
1152
|
-
// Merge config file options with passed options (passed options take precedence)
|
|
1153
|
-
const mergedOptions = {
|
|
1154
|
-
...configAsOptions,
|
|
1155
|
-
...options,
|
|
1156
|
-
// Deep merge performance settings
|
|
1157
|
-
performance: {
|
|
1158
|
-
...configAsOptions.performance,
|
|
1159
|
-
...options?.performance,
|
|
1160
|
-
},
|
|
1161
|
-
};
|
|
1162
|
-
|
|
1163
|
-
return new Moro(mergedOptions);
|
|
1167
|
+
return new Moro(options);
|
|
1164
1168
|
}
|
|
1165
1169
|
|
|
1166
1170
|
// Runtime-specific convenience functions
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
// TypeScript-based Configuration Types for Moro Framework
|
|
2
|
-
// Replaces Zod schemas with pure TypeScript interfaces
|
|
3
2
|
|
|
4
3
|
export interface ServerConfig {
|
|
5
4
|
port: number;
|
|
@@ -156,122 +155,3 @@ export interface AppConfig {
|
|
|
156
155
|
external: ExternalServicesConfig;
|
|
157
156
|
performance: PerformanceConfig;
|
|
158
157
|
}
|
|
159
|
-
|
|
160
|
-
// Default configuration
|
|
161
|
-
export const DEFAULT_CONFIG: AppConfig = {
|
|
162
|
-
server: {
|
|
163
|
-
port: 3001,
|
|
164
|
-
host: 'localhost',
|
|
165
|
-
environment: 'development',
|
|
166
|
-
maxConnections: 1000,
|
|
167
|
-
timeout: 30000,
|
|
168
|
-
},
|
|
169
|
-
serviceDiscovery: {
|
|
170
|
-
enabled: false,
|
|
171
|
-
type: 'memory',
|
|
172
|
-
consulUrl: 'http://localhost:8500',
|
|
173
|
-
kubernetesNamespace: 'default',
|
|
174
|
-
healthCheckInterval: 30000,
|
|
175
|
-
retryAttempts: 3,
|
|
176
|
-
},
|
|
177
|
-
database: {
|
|
178
|
-
redis: {
|
|
179
|
-
url: 'redis://localhost:6379',
|
|
180
|
-
maxRetries: 3,
|
|
181
|
-
retryDelay: 1000,
|
|
182
|
-
keyPrefix: 'moro:',
|
|
183
|
-
},
|
|
184
|
-
},
|
|
185
|
-
modules: {
|
|
186
|
-
cache: {
|
|
187
|
-
enabled: true,
|
|
188
|
-
defaultTtl: 300,
|
|
189
|
-
maxSize: 1000,
|
|
190
|
-
strategy: 'lru',
|
|
191
|
-
},
|
|
192
|
-
rateLimit: {
|
|
193
|
-
enabled: true,
|
|
194
|
-
defaultRequests: 100,
|
|
195
|
-
defaultWindow: 60000,
|
|
196
|
-
skipSuccessfulRequests: false,
|
|
197
|
-
skipFailedRequests: false,
|
|
198
|
-
},
|
|
199
|
-
validation: {
|
|
200
|
-
enabled: true,
|
|
201
|
-
stripUnknown: true,
|
|
202
|
-
abortEarly: false,
|
|
203
|
-
},
|
|
204
|
-
},
|
|
205
|
-
logging: {
|
|
206
|
-
level: 'info',
|
|
207
|
-
format: 'pretty',
|
|
208
|
-
enableColors: true,
|
|
209
|
-
enableTimestamp: true,
|
|
210
|
-
enableContext: true,
|
|
211
|
-
outputs: {
|
|
212
|
-
console: true,
|
|
213
|
-
file: {
|
|
214
|
-
enabled: false,
|
|
215
|
-
path: './logs/moro.log',
|
|
216
|
-
maxSize: '10MB',
|
|
217
|
-
maxFiles: 5,
|
|
218
|
-
},
|
|
219
|
-
webhook: {
|
|
220
|
-
enabled: false,
|
|
221
|
-
headers: {},
|
|
222
|
-
},
|
|
223
|
-
},
|
|
224
|
-
},
|
|
225
|
-
security: {
|
|
226
|
-
cors: {
|
|
227
|
-
enabled: true,
|
|
228
|
-
origin: '*',
|
|
229
|
-
methods: ['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'OPTIONS'],
|
|
230
|
-
allowedHeaders: ['Content-Type', 'Authorization'],
|
|
231
|
-
credentials: false,
|
|
232
|
-
},
|
|
233
|
-
helmet: {
|
|
234
|
-
enabled: true,
|
|
235
|
-
contentSecurityPolicy: true,
|
|
236
|
-
hsts: true,
|
|
237
|
-
noSniff: true,
|
|
238
|
-
frameguard: true,
|
|
239
|
-
},
|
|
240
|
-
rateLimit: {
|
|
241
|
-
global: {
|
|
242
|
-
enabled: false,
|
|
243
|
-
requests: 1000,
|
|
244
|
-
window: 60000,
|
|
245
|
-
},
|
|
246
|
-
},
|
|
247
|
-
},
|
|
248
|
-
external: {
|
|
249
|
-
stripe: {
|
|
250
|
-
apiVersion: '2023-10-16',
|
|
251
|
-
},
|
|
252
|
-
paypal: {
|
|
253
|
-
environment: 'sandbox',
|
|
254
|
-
},
|
|
255
|
-
smtp: {
|
|
256
|
-
port: 587,
|
|
257
|
-
secure: false,
|
|
258
|
-
},
|
|
259
|
-
},
|
|
260
|
-
performance: {
|
|
261
|
-
compression: {
|
|
262
|
-
enabled: true,
|
|
263
|
-
level: 6,
|
|
264
|
-
threshold: 1024,
|
|
265
|
-
},
|
|
266
|
-
circuitBreaker: {
|
|
267
|
-
enabled: true,
|
|
268
|
-
failureThreshold: 5,
|
|
269
|
-
resetTimeout: 60000,
|
|
270
|
-
monitoringPeriod: 10000,
|
|
271
|
-
},
|
|
272
|
-
clustering: {
|
|
273
|
-
enabled: false,
|
|
274
|
-
workers: 1,
|
|
275
|
-
},
|
|
276
|
-
},
|
|
277
|
-
};
|
package/src/types/core.ts
CHANGED
|
@@ -14,6 +14,27 @@ export interface MoroOptions {
|
|
|
14
14
|
runtime?: RuntimeConfig;
|
|
15
15
|
// Logger configuration
|
|
16
16
|
logger?: LoggerOptions | boolean;
|
|
17
|
+
// Module configuration
|
|
18
|
+
modules?: {
|
|
19
|
+
cache?: {
|
|
20
|
+
enabled?: boolean;
|
|
21
|
+
defaultTtl?: number;
|
|
22
|
+
maxSize?: number;
|
|
23
|
+
strategy?: 'lru' | 'lfu' | 'fifo';
|
|
24
|
+
};
|
|
25
|
+
rateLimit?: {
|
|
26
|
+
enabled?: boolean;
|
|
27
|
+
defaultRequests?: number;
|
|
28
|
+
defaultWindow?: number;
|
|
29
|
+
skipSuccessfulRequests?: boolean;
|
|
30
|
+
skipFailedRequests?: boolean;
|
|
31
|
+
};
|
|
32
|
+
validation?: {
|
|
33
|
+
enabled?: boolean;
|
|
34
|
+
stripUnknown?: boolean;
|
|
35
|
+
abortEarly?: boolean;
|
|
36
|
+
};
|
|
37
|
+
};
|
|
17
38
|
// Performance configuration
|
|
18
39
|
performance?: {
|
|
19
40
|
clustering?: {
|
package/tsconfig.json
CHANGED
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// TypeScript-based Configuration Types for Moro Framework
|
|
3
|
-
// Replaces Zod schemas with pure TypeScript interfaces
|
|
4
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
-
exports.DEFAULT_CONFIG = void 0;
|
|
6
|
-
// Default configuration
|
|
7
|
-
exports.DEFAULT_CONFIG = {
|
|
8
|
-
server: {
|
|
9
|
-
port: 3001,
|
|
10
|
-
host: 'localhost',
|
|
11
|
-
environment: 'development',
|
|
12
|
-
maxConnections: 1000,
|
|
13
|
-
timeout: 30000,
|
|
14
|
-
},
|
|
15
|
-
serviceDiscovery: {
|
|
16
|
-
enabled: false,
|
|
17
|
-
type: 'memory',
|
|
18
|
-
consulUrl: 'http://localhost:8500',
|
|
19
|
-
kubernetesNamespace: 'default',
|
|
20
|
-
healthCheckInterval: 30000,
|
|
21
|
-
retryAttempts: 3,
|
|
22
|
-
},
|
|
23
|
-
database: {
|
|
24
|
-
redis: {
|
|
25
|
-
url: 'redis://localhost:6379',
|
|
26
|
-
maxRetries: 3,
|
|
27
|
-
retryDelay: 1000,
|
|
28
|
-
keyPrefix: 'moro:',
|
|
29
|
-
},
|
|
30
|
-
},
|
|
31
|
-
modules: {
|
|
32
|
-
cache: {
|
|
33
|
-
enabled: true,
|
|
34
|
-
defaultTtl: 300,
|
|
35
|
-
maxSize: 1000,
|
|
36
|
-
strategy: 'lru',
|
|
37
|
-
},
|
|
38
|
-
rateLimit: {
|
|
39
|
-
enabled: true,
|
|
40
|
-
defaultRequests: 100,
|
|
41
|
-
defaultWindow: 60000,
|
|
42
|
-
skipSuccessfulRequests: false,
|
|
43
|
-
skipFailedRequests: false,
|
|
44
|
-
},
|
|
45
|
-
validation: {
|
|
46
|
-
enabled: true,
|
|
47
|
-
stripUnknown: true,
|
|
48
|
-
abortEarly: false,
|
|
49
|
-
},
|
|
50
|
-
},
|
|
51
|
-
logging: {
|
|
52
|
-
level: 'info',
|
|
53
|
-
format: 'pretty',
|
|
54
|
-
enableColors: true,
|
|
55
|
-
enableTimestamp: true,
|
|
56
|
-
enableContext: true,
|
|
57
|
-
outputs: {
|
|
58
|
-
console: true,
|
|
59
|
-
file: {
|
|
60
|
-
enabled: false,
|
|
61
|
-
path: './logs/moro.log',
|
|
62
|
-
maxSize: '10MB',
|
|
63
|
-
maxFiles: 5,
|
|
64
|
-
},
|
|
65
|
-
webhook: {
|
|
66
|
-
enabled: false,
|
|
67
|
-
headers: {},
|
|
68
|
-
},
|
|
69
|
-
},
|
|
70
|
-
},
|
|
71
|
-
security: {
|
|
72
|
-
cors: {
|
|
73
|
-
enabled: true,
|
|
74
|
-
origin: '*',
|
|
75
|
-
methods: ['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'OPTIONS'],
|
|
76
|
-
allowedHeaders: ['Content-Type', 'Authorization'],
|
|
77
|
-
credentials: false,
|
|
78
|
-
},
|
|
79
|
-
helmet: {
|
|
80
|
-
enabled: true,
|
|
81
|
-
contentSecurityPolicy: true,
|
|
82
|
-
hsts: true,
|
|
83
|
-
noSniff: true,
|
|
84
|
-
frameguard: true,
|
|
85
|
-
},
|
|
86
|
-
rateLimit: {
|
|
87
|
-
global: {
|
|
88
|
-
enabled: false,
|
|
89
|
-
requests: 1000,
|
|
90
|
-
window: 60000,
|
|
91
|
-
},
|
|
92
|
-
},
|
|
93
|
-
},
|
|
94
|
-
external: {
|
|
95
|
-
stripe: {
|
|
96
|
-
apiVersion: '2023-10-16',
|
|
97
|
-
},
|
|
98
|
-
paypal: {
|
|
99
|
-
environment: 'sandbox',
|
|
100
|
-
},
|
|
101
|
-
smtp: {
|
|
102
|
-
port: 587,
|
|
103
|
-
secure: false,
|
|
104
|
-
},
|
|
105
|
-
},
|
|
106
|
-
performance: {
|
|
107
|
-
compression: {
|
|
108
|
-
enabled: true,
|
|
109
|
-
level: 6,
|
|
110
|
-
threshold: 1024,
|
|
111
|
-
},
|
|
112
|
-
circuitBreaker: {
|
|
113
|
-
enabled: true,
|
|
114
|
-
failureThreshold: 5,
|
|
115
|
-
resetTimeout: 60000,
|
|
116
|
-
monitoringPeriod: 10000,
|
|
117
|
-
},
|
|
118
|
-
clustering: {
|
|
119
|
-
enabled: false,
|
|
120
|
-
workers: 1,
|
|
121
|
-
},
|
|
122
|
-
},
|
|
123
|
-
};
|
|
124
|
-
//# sourceMappingURL=types.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/core/config/types.ts"],"names":[],"mappings":"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"}
|