tezx 1.0.32 → 1.0.33
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/cjs/index.js +1 -1
- package/cjs/middleware/lazyLoadModules.js +6 -7
- package/index.js +1 -1
- package/middleware/lazyLoadModules.js +6 -7
- package/package.json +1 -1
package/cjs/index.js
CHANGED
|
@@ -7,4 +7,4 @@ var server_1 = require("./core/server");
|
|
|
7
7
|
Object.defineProperty(exports, "TezX", { enumerable: true, get: function () { return server_1.TezX; } });
|
|
8
8
|
var params_1 = require("./utils/params");
|
|
9
9
|
Object.defineProperty(exports, "useParams", { enumerable: true, get: function () { return params_1.useParams; } });
|
|
10
|
-
exports.version = "1.0.
|
|
10
|
+
exports.version = "1.0.33";
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.lazyLoadModules = void 0;
|
|
4
|
+
const config_1 = require("../core/config");
|
|
4
5
|
;
|
|
5
6
|
const lazyLoadModules = (options) => {
|
|
6
7
|
const { moduleKey = (ctx) => ctx.req.params[queryKeyModule] || ctx.req.query[queryKeyModule], getModuleLoader, queryKeyModule = "module", moduleContextKey = "module", cacheTTL = 3600000, dependencies = {}, enableCache = true, cacheStorage = new Map(), lifecycleHooks = {}, validateModule } = options;
|
|
7
8
|
return async (ctx, next) => {
|
|
8
|
-
console.log(ctx.pathname?.split("/"));
|
|
9
9
|
let moduleName = moduleKey(ctx) || ctx.req.params[queryKeyModule] || ctx.req.query[queryKeyModule];
|
|
10
10
|
if (!moduleName) {
|
|
11
|
-
|
|
11
|
+
config_1.GlobalConfig.debugging.warn("No module specified for lazy loading.");
|
|
12
12
|
return await next();
|
|
13
13
|
}
|
|
14
14
|
try {
|
|
@@ -19,7 +19,7 @@ const lazyLoadModules = (options) => {
|
|
|
19
19
|
cacheStorage.delete(moduleName);
|
|
20
20
|
}
|
|
21
21
|
else {
|
|
22
|
-
|
|
22
|
+
config_1.GlobalConfig.debugging.info(`Using cached module: ${moduleName}`);
|
|
23
23
|
ctx[moduleContextKey] = cached?.module;
|
|
24
24
|
lifecycleHooks.onCacheHit?.(moduleName, ctx[moduleContextKey], ctx);
|
|
25
25
|
lifecycleHooks.onComplete?.(moduleName, ctx[moduleContextKey], ctx);
|
|
@@ -52,14 +52,13 @@ const lazyLoadModules = (options) => {
|
|
|
52
52
|
}
|
|
53
53
|
ctx[moduleContextKey] = module;
|
|
54
54
|
lifecycleHooks.onComplete?.(moduleName, module, ctx);
|
|
55
|
-
|
|
55
|
+
config_1.GlobalConfig.debugging.success(`Successfully loaded module: ${moduleName}`);
|
|
56
56
|
}
|
|
57
57
|
catch (error) {
|
|
58
|
-
|
|
58
|
+
config_1.GlobalConfig.debugging.error(`Error loading module: ${moduleName}`, error);
|
|
59
59
|
lifecycleHooks.onError?.(moduleName, error, ctx);
|
|
60
60
|
ctx.setStatus = 500;
|
|
61
|
-
|
|
62
|
-
return;
|
|
61
|
+
throw error;
|
|
63
62
|
}
|
|
64
63
|
return await next();
|
|
65
64
|
};
|
package/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
+
import { GlobalConfig } from "../core/config";
|
|
1
2
|
;
|
|
2
3
|
export const lazyLoadModules = (options) => {
|
|
3
4
|
const { moduleKey = (ctx) => ctx.req.params[queryKeyModule] || ctx.req.query[queryKeyModule], getModuleLoader, queryKeyModule = "module", moduleContextKey = "module", cacheTTL = 3600000, dependencies = {}, enableCache = true, cacheStorage = new Map(), lifecycleHooks = {}, validateModule } = options;
|
|
4
5
|
return async (ctx, next) => {
|
|
5
|
-
console.log(ctx.pathname?.split("/"));
|
|
6
6
|
let moduleName = moduleKey(ctx) || ctx.req.params[queryKeyModule] || ctx.req.query[queryKeyModule];
|
|
7
7
|
if (!moduleName) {
|
|
8
|
-
|
|
8
|
+
GlobalConfig.debugging.warn("No module specified for lazy loading.");
|
|
9
9
|
return await next();
|
|
10
10
|
}
|
|
11
11
|
try {
|
|
@@ -16,7 +16,7 @@ export const lazyLoadModules = (options) => {
|
|
|
16
16
|
cacheStorage.delete(moduleName);
|
|
17
17
|
}
|
|
18
18
|
else {
|
|
19
|
-
|
|
19
|
+
GlobalConfig.debugging.info(`Using cached module: ${moduleName}`);
|
|
20
20
|
ctx[moduleContextKey] = cached?.module;
|
|
21
21
|
lifecycleHooks.onCacheHit?.(moduleName, ctx[moduleContextKey], ctx);
|
|
22
22
|
lifecycleHooks.onComplete?.(moduleName, ctx[moduleContextKey], ctx);
|
|
@@ -49,14 +49,13 @@ export const lazyLoadModules = (options) => {
|
|
|
49
49
|
}
|
|
50
50
|
ctx[moduleContextKey] = module;
|
|
51
51
|
lifecycleHooks.onComplete?.(moduleName, module, ctx);
|
|
52
|
-
|
|
52
|
+
GlobalConfig.debugging.success(`Successfully loaded module: ${moduleName}`);
|
|
53
53
|
}
|
|
54
54
|
catch (error) {
|
|
55
|
-
|
|
55
|
+
GlobalConfig.debugging.error(`Error loading module: ${moduleName}`, error);
|
|
56
56
|
lifecycleHooks.onError?.(moduleName, error, ctx);
|
|
57
57
|
ctx.setStatus = 500;
|
|
58
|
-
|
|
59
|
-
return;
|
|
58
|
+
throw error;
|
|
60
59
|
}
|
|
61
60
|
return await next();
|
|
62
61
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tezx",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.33",
|
|
4
4
|
"description": "TezX is a high-performance, lightweight JavaScript framework designed for speed, scalability, and flexibility. It enables efficient routing, middleware management, and static file serving with minimal configuration. Fully compatible with Node.js, Deno, and Bun.",
|
|
5
5
|
"main": "cjs/index.js",
|
|
6
6
|
"module": "index.js",
|