tezx 1.0.65 → 1.0.67
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/core/server.js +24 -17
- package/cjs/index.js +1 -1
- package/core/server.js +24 -17
- package/index.js +1 -1
- package/package.json +1 -1
package/cjs/core/server.js
CHANGED
|
@@ -78,32 +78,39 @@ class TezX extends router_js_1.Router {
|
|
|
78
78
|
}
|
|
79
79
|
#createHandler(middlewares) {
|
|
80
80
|
return async (ctx) => {
|
|
81
|
-
let response = undefined;
|
|
82
81
|
let index = 0;
|
|
83
|
-
let
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
ctx.res = result;
|
|
88
|
-
response = ctx.res;
|
|
89
|
-
return result;
|
|
82
|
+
let response = undefined;
|
|
83
|
+
const next = async () => {
|
|
84
|
+
if (index >= middlewares.length) {
|
|
85
|
+
return;
|
|
90
86
|
}
|
|
91
|
-
|
|
92
|
-
|
|
87
|
+
const currentMiddleware = middlewares[index++];
|
|
88
|
+
try {
|
|
89
|
+
const result = await currentMiddleware(ctx, next);
|
|
90
|
+
if (result instanceof Response) {
|
|
91
|
+
ctx.res = result;
|
|
92
|
+
}
|
|
93
|
+
if (result !== undefined) {
|
|
94
|
+
response = result;
|
|
95
|
+
}
|
|
93
96
|
return response;
|
|
94
97
|
}
|
|
98
|
+
catch (err) {
|
|
99
|
+
ctx.body = err;
|
|
100
|
+
throw err;
|
|
101
|
+
}
|
|
95
102
|
};
|
|
96
|
-
await next();
|
|
97
|
-
if (
|
|
98
|
-
return
|
|
103
|
+
let res = await next();
|
|
104
|
+
if (res instanceof Response) {
|
|
105
|
+
return res;
|
|
99
106
|
}
|
|
100
|
-
if (typeof
|
|
101
|
-
return
|
|
107
|
+
if (typeof res == "function" && ctx.wsProtocol) {
|
|
108
|
+
return res;
|
|
102
109
|
}
|
|
103
|
-
if (!
|
|
110
|
+
if (!res && !ctx.body) {
|
|
104
111
|
throw new Error(`Handler failed: Middleware chain incomplete or response missing. Did you forget ${colors_js_1.COLORS.bgRed} 'await next()' ${colors_js_1.COLORS.reset} or to return a response? ${colors_js_1.COLORS.bgCyan} Path: ${ctx.pathname}, Method: ${ctx.method} ${colors_js_1.COLORS.reset}`);
|
|
105
112
|
}
|
|
106
|
-
const resBody =
|
|
113
|
+
const resBody = res || ctx.body;
|
|
107
114
|
return ctx.send(resBody, ctx.headers.toJSON());
|
|
108
115
|
};
|
|
109
116
|
}
|
package/cjs/index.js
CHANGED
|
@@ -7,4 +7,4 @@ var server_js_1 = require("./core/server.js");
|
|
|
7
7
|
Object.defineProperty(exports, "TezX", { enumerable: true, get: function () { return server_js_1.TezX; } });
|
|
8
8
|
var params_js_1 = require("./utils/params.js");
|
|
9
9
|
Object.defineProperty(exports, "useParams", { enumerable: true, get: function () { return params_js_1.useParams; } });
|
|
10
|
-
exports.version = "1.0.
|
|
10
|
+
exports.version = "1.0.67";
|
package/core/server.js
CHANGED
|
@@ -75,32 +75,39 @@ export class TezX extends Router {
|
|
|
75
75
|
}
|
|
76
76
|
#createHandler(middlewares) {
|
|
77
77
|
return async (ctx) => {
|
|
78
|
-
let response = undefined;
|
|
79
78
|
let index = 0;
|
|
80
|
-
let
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
ctx.res = result;
|
|
85
|
-
response = ctx.res;
|
|
86
|
-
return result;
|
|
79
|
+
let response = undefined;
|
|
80
|
+
const next = async () => {
|
|
81
|
+
if (index >= middlewares.length) {
|
|
82
|
+
return;
|
|
87
83
|
}
|
|
88
|
-
|
|
89
|
-
|
|
84
|
+
const currentMiddleware = middlewares[index++];
|
|
85
|
+
try {
|
|
86
|
+
const result = await currentMiddleware(ctx, next);
|
|
87
|
+
if (result instanceof Response) {
|
|
88
|
+
ctx.res = result;
|
|
89
|
+
}
|
|
90
|
+
if (result !== undefined) {
|
|
91
|
+
response = result;
|
|
92
|
+
}
|
|
90
93
|
return response;
|
|
91
94
|
}
|
|
95
|
+
catch (err) {
|
|
96
|
+
ctx.body = err;
|
|
97
|
+
throw err;
|
|
98
|
+
}
|
|
92
99
|
};
|
|
93
|
-
await next();
|
|
94
|
-
if (
|
|
95
|
-
return
|
|
100
|
+
let res = await next();
|
|
101
|
+
if (res instanceof Response) {
|
|
102
|
+
return res;
|
|
96
103
|
}
|
|
97
|
-
if (typeof
|
|
98
|
-
return
|
|
104
|
+
if (typeof res == "function" && ctx.wsProtocol) {
|
|
105
|
+
return res;
|
|
99
106
|
}
|
|
100
|
-
if (!
|
|
107
|
+
if (!res && !ctx.body) {
|
|
101
108
|
throw new Error(`Handler failed: Middleware chain incomplete or response missing. Did you forget ${COLORS.bgRed} 'await next()' ${COLORS.reset} or to return a response? ${COLORS.bgCyan} Path: ${ctx.pathname}, Method: ${ctx.method} ${COLORS.reset}`);
|
|
102
109
|
}
|
|
103
|
-
const resBody =
|
|
110
|
+
const resBody = res || ctx.body;
|
|
104
111
|
return ctx.send(resBody, ctx.headers.toJSON());
|
|
105
112
|
};
|
|
106
113
|
}
|
package/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tezx",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.67",
|
|
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",
|