tezx 2.0.8 → 2.0.10
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/router.js +2 -2
- package/cjs/index.js +3 -3
- package/core/router.d.ts +41 -41
- package/core/router.js +2 -2
- package/index.d.ts +4 -3
- package/index.js +3 -3
- package/middleware/index.d.ts +1 -1
- package/package.json +1 -1
package/cjs/core/router.js
CHANGED
|
@@ -250,7 +250,7 @@ class Router extends MiddlewareConfigure_js_1.default {
|
|
|
250
250
|
if (!config_js_1.GlobalConfig.overwriteMethod && handler.has(method))
|
|
251
251
|
return;
|
|
252
252
|
return handler.set(method, {
|
|
253
|
-
callback,
|
|
253
|
+
callback: callback,
|
|
254
254
|
paramNames: [],
|
|
255
255
|
regex: regex,
|
|
256
256
|
middlewares: finalMiddleware
|
|
@@ -275,7 +275,7 @@ class Router extends MiddlewareConfigure_js_1.default {
|
|
|
275
275
|
if (!config_js_1.GlobalConfig.overwriteMethod && handler.has(method))
|
|
276
276
|
return;
|
|
277
277
|
return handler.set(method, {
|
|
278
|
-
callback,
|
|
278
|
+
callback: callback,
|
|
279
279
|
regex: regex,
|
|
280
280
|
paramNames: paramNames,
|
|
281
281
|
middlewares: finalMiddleware
|
package/cjs/index.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.version = exports.
|
|
3
|
+
exports.version = exports.regexMatchRoute = exports.compileRegexRoute = exports.TezX = exports.Router = void 0;
|
|
4
4
|
const router_js_1 = require("./core/router.js");
|
|
5
5
|
const server_js_1 = require("./core/server.js");
|
|
6
6
|
const regexRouter_js_1 = require("./utils/regexRouter.js");
|
|
7
|
-
Object.defineProperty(exports, "regexMatchRoute", { enumerable: true, get: function () { return regexRouter_js_1.regexMatchRoute; } });
|
|
8
7
|
Object.defineProperty(exports, "compileRegexRoute", { enumerable: true, get: function () { return regexRouter_js_1.compileRegexRoute; } });
|
|
8
|
+
Object.defineProperty(exports, "regexMatchRoute", { enumerable: true, get: function () { return regexRouter_js_1.regexMatchRoute; } });
|
|
9
9
|
var router_js_2 = require("./core/router.js");
|
|
10
10
|
Object.defineProperty(exports, "Router", { enumerable: true, get: function () { return router_js_2.Router; } });
|
|
11
11
|
var server_js_2 = require("./core/server.js");
|
|
12
12
|
Object.defineProperty(exports, "TezX", { enumerable: true, get: function () { return server_js_2.TezX; } });
|
|
13
|
-
exports.version = "2.0.
|
|
13
|
+
exports.version = "2.0.10";
|
|
14
14
|
exports.default = {
|
|
15
15
|
Router: router_js_1.Router,
|
|
16
16
|
regexMatchRoute: regexRouter_js_1.regexMatchRoute, compileRegexRoute: regexRouter_js_1.compileRegexRoute,
|
package/core/router.d.ts
CHANGED
|
@@ -80,9 +80,9 @@ export declare class Router<T extends Record<string, any> = {}> extends Middlewa
|
|
|
80
80
|
* // With multiple middlewares
|
|
81
81
|
* app.get('/admin', [authMiddleware, adminMiddleware], (ctx) => { ... });
|
|
82
82
|
*/
|
|
83
|
-
get(path: PathType, callback: Callback<T>): this;
|
|
84
|
-
get(path: PathType, middleware: Middleware<T>, callback: Callback<T>): this;
|
|
85
|
-
get(path: PathType, middlewares: Middleware<T>[], callback: Callback<T>): this;
|
|
83
|
+
get<U extends Record<string, any> = {}>(path: PathType, callback: Callback<T & U>): this;
|
|
84
|
+
get<U extends Record<string, any> = {}>(path: PathType, middleware: Middleware<T & U>, callback: Callback<T & U>): this;
|
|
85
|
+
get<U extends Record<string, any> = {}>(path: PathType, middlewares: Middleware<T & U>[], callback: Callback<T & U>): this;
|
|
86
86
|
/**
|
|
87
87
|
* Registers a Server-Sent Events (SSE) route handler for the given path.
|
|
88
88
|
*
|
|
@@ -115,63 +115,63 @@ export declare class Router<T extends Record<string, any> = {}> extends Middlewa
|
|
|
115
115
|
* @param {PathType} path - The route path for SSE (e.g. `/events`).
|
|
116
116
|
* @param {(ctx: Context) => any} handler - A handler function that returns a streamed response.
|
|
117
117
|
*/
|
|
118
|
-
sse(path: PathType, handler: (ctx: Context) => any): void;
|
|
118
|
+
sse<U extends Record<string, any> = {}>(path: PathType, handler: (ctx: Context<T & U>) => any): void;
|
|
119
119
|
/**
|
|
120
120
|
* Registers a POST route with optional middleware(s)
|
|
121
121
|
* @param path - URL path pattern
|
|
122
122
|
* @param args - Handler callback or middleware(s) + handler
|
|
123
123
|
*/
|
|
124
|
-
post(path: PathType, callback: Callback<T>): this;
|
|
125
|
-
post(path: PathType, middleware: Middleware<T>, callback: Callback<T>): this;
|
|
126
|
-
post(path: PathType, middlewares: Middleware<T>[], callback: Callback<T>): this;
|
|
124
|
+
post<U extends Record<string, any> = {}>(path: PathType, callback: Callback<T & U>): this;
|
|
125
|
+
post<U extends Record<string, any> = {}>(path: PathType, middleware: Middleware<T & U>, callback: Callback<T & U>): this;
|
|
126
|
+
post<U extends Record<string, any> = {}>(path: PathType, middlewares: Middleware<T & U>[], callback: Callback<T & U>): this;
|
|
127
127
|
/**
|
|
128
128
|
* Registers a PUT route with optional middleware(s)
|
|
129
129
|
* @param path - URL path pattern
|
|
130
130
|
* @param args - Handler callback or middleware(s) + handler
|
|
131
131
|
*/
|
|
132
|
-
put(path: PathType, callback: Callback<T>): this;
|
|
133
|
-
put(path: PathType, middleware: Middleware<T>, callback: Callback<T>): this;
|
|
134
|
-
put(path: PathType, middlewares: Middleware<T>[], callback: Callback<T>): this;
|
|
132
|
+
put<U extends Record<string, any> = {}>(path: PathType, callback: Callback<T & U>): this;
|
|
133
|
+
put<U extends Record<string, any> = {}>(path: PathType, middleware: Middleware<T & U>, callback: Callback<T & U>): this;
|
|
134
|
+
put<U extends Record<string, any> = {}>(path: PathType, middlewares: Middleware<T & U>[], callback: Callback<T & U>): this;
|
|
135
135
|
/**
|
|
136
136
|
* Registers a PATCH route with optional middleware(s)
|
|
137
137
|
* @param path - URL path pattern
|
|
138
138
|
* @param args - Handler callback or middleware(s) + handler
|
|
139
139
|
*/
|
|
140
|
-
patch(path: PathType, callback: Callback<T>): this;
|
|
141
|
-
patch(path: PathType, middleware: Middleware<T>, callback: Callback<T>): this;
|
|
142
|
-
patch(path: PathType, middlewares: Middleware<T>[], callback: Callback<T>): this;
|
|
140
|
+
patch<U extends Record<string, any> = {}>(path: PathType, callback: Callback<T & U>): this;
|
|
141
|
+
patch<U extends Record<string, any> = {}>(path: PathType, middleware: Middleware<T & U>, callback: Callback<T & U>): this;
|
|
142
|
+
patch<U extends Record<string, any> = {}>(path: PathType, middlewares: Middleware<T & U>[], callback: Callback<T & U>): this;
|
|
143
143
|
/**
|
|
144
144
|
* Registers a DELETE route with optional middleware(s)
|
|
145
145
|
* @param path - URL path pattern
|
|
146
146
|
* @param args - Handler callback or middleware(s) + handler
|
|
147
147
|
*/
|
|
148
|
-
delete(path: PathType, callback: Callback<T>): this;
|
|
149
|
-
delete(path: PathType, middleware: Middleware<T>, callback: Callback<T>): this;
|
|
150
|
-
delete(path: PathType, middlewares: Middleware<T>[], callback: Callback<T>): this;
|
|
148
|
+
delete<U extends Record<string, any> = {}>(path: PathType, callback: Callback<T & U>): this;
|
|
149
|
+
delete<U extends Record<string, any> = {}>(path: PathType, middleware: Middleware<T & U>, callback: Callback<T & U>): this;
|
|
150
|
+
delete<U extends Record<string, any> = {}>(path: PathType, middlewares: Middleware<T & U>[], callback: Callback<T & U>): this;
|
|
151
151
|
/**
|
|
152
152
|
* Registers an OPTIONS route (primarily for CORS preflight requests)
|
|
153
153
|
* @param path - URL path pattern
|
|
154
154
|
* @param args - Handler callback or middleware(s) + handler
|
|
155
155
|
*/
|
|
156
|
-
options(path: PathType, callback: Callback<T>): this;
|
|
157
|
-
options(path: PathType, middleware: Middleware<T>, callback: Callback<T>): this;
|
|
158
|
-
options(path: PathType, middlewares: Middleware<T>[], callback: Callback<T>): this;
|
|
156
|
+
options<U extends Record<string, any> = {}>(path: PathType, callback: Callback<T & U>): this;
|
|
157
|
+
options<U extends Record<string, any> = {}>(path: PathType, middleware: Middleware<T & U>, callback: Callback<T & U>): this;
|
|
158
|
+
options<U extends Record<string, any> = {}>(path: PathType, middlewares: Middleware<T & U>[], callback: Callback<T & U>): this;
|
|
159
159
|
/**
|
|
160
160
|
* Registers a HEAD route (returns headers only)
|
|
161
161
|
* @param path - URL path pattern
|
|
162
162
|
* @param args - Handler callback or middleware(s) + handler
|
|
163
163
|
*/
|
|
164
|
-
head(path: PathType, callback: Callback<T>): this;
|
|
165
|
-
head(path: PathType, middleware: Middleware<T>, callback: Callback<T>): this;
|
|
166
|
-
head(path: PathType, middlewares: Middleware<T>[], callback: Callback<T>): this;
|
|
164
|
+
head<U extends Record<string, any> = {}>(path: PathType, callback: Callback<T & U>): this;
|
|
165
|
+
head<U extends Record<string, any> = {}>(path: PathType, middleware: Middleware<T & U>, callback: Callback<T & U>): this;
|
|
166
|
+
head<U extends Record<string, any> = {}>(path: PathType, middlewares: Middleware<T & U>[], callback: Callback<T & U>): this;
|
|
167
167
|
/**
|
|
168
168
|
* Registers a route that responds to all HTTP methods
|
|
169
169
|
* @param path - URL path pattern
|
|
170
170
|
* @param args - Handler callback or middleware(s) + handler
|
|
171
171
|
*/
|
|
172
|
-
all(path: PathType, callback: Callback<T>): this;
|
|
173
|
-
all(path: PathType, middleware: Middleware<T>, callback: Callback<T>): this;
|
|
174
|
-
all(path: PathType, middlewares: Middleware<T>[], callback: Callback<T>): this;
|
|
172
|
+
all<U extends Record<string, any> = {}>(path: PathType, callback: Callback<T & U>): this;
|
|
173
|
+
all<U extends Record<string, any> = {}>(path: PathType, middleware: Middleware<T & U>, callback: Callback<T & U>): this;
|
|
174
|
+
all<U extends Record<string, any> = {}>(path: PathType, middlewares: Middleware<T & U>[], callback: Callback<T & U>): this;
|
|
175
175
|
/**
|
|
176
176
|
* Generic method registration for custom HTTP methods
|
|
177
177
|
* @param method - HTTP method name (e.g., 'PURGE')
|
|
@@ -182,10 +182,10 @@ export declare class Router<T extends Record<string, any> = {}> extends Middlewa
|
|
|
182
182
|
* // Register custom method
|
|
183
183
|
* server.addRoute('PURGE', '/cache', purgeHandler);
|
|
184
184
|
*/
|
|
185
|
-
addRoute(method: HTTPMethod, path: PathType, callback: Callback<T>): this;
|
|
186
|
-
addRoute(method: HTTPMethod, path: PathType, middleware: Middleware<T>): this;
|
|
187
|
-
addRoute(method: HTTPMethod, path: PathType, middleware: Middleware<T>, callback: Callback<T>): this;
|
|
188
|
-
addRoute(method: HTTPMethod, path: PathType, middlewares: Middleware<T>[], callback: Callback<T>): this;
|
|
185
|
+
addRoute<U extends Record<string, any> = {}>(method: HTTPMethod, path: PathType, callback: Callback<T & U>): this;
|
|
186
|
+
addRoute<U extends Record<string, any> = {}>(method: HTTPMethod, path: PathType, middleware: Middleware<T & U>): this;
|
|
187
|
+
addRoute<U extends Record<string, any> = {}>(method: HTTPMethod, path: PathType, middleware: Middleware<T & U>, callback: Callback<T & U>): this;
|
|
188
|
+
addRoute<U extends Record<string, any> = {}>(method: HTTPMethod, path: PathType, middlewares: Middleware<T & U>[], callback: Callback<T & U>): this;
|
|
189
189
|
/**
|
|
190
190
|
* Mount a sub-router at specific path prefix
|
|
191
191
|
* @param path - Base path for the sub-router
|
|
@@ -197,7 +197,7 @@ export declare class Router<T extends Record<string, any> = {}> extends Middlewa
|
|
|
197
197
|
* apiRouter.get('/users', () => { ... });
|
|
198
198
|
* server.addRouter('/api', apiRouter);
|
|
199
199
|
*/
|
|
200
|
-
addRouter(path: string, router: Router<T | any>): void;
|
|
200
|
+
addRouter<U extends Record<string, any> = {}>(path: string, router: Router<T | U | any>): void;
|
|
201
201
|
/**
|
|
202
202
|
* Create route group with shared path prefix
|
|
203
203
|
* @param prefix - Path prefix for the group
|
|
@@ -209,7 +209,7 @@ export declare class Router<T extends Record<string, any> = {}> extends Middlewa
|
|
|
209
209
|
* group.get('/users', v1UserHandler);
|
|
210
210
|
* });
|
|
211
211
|
*/
|
|
212
|
-
group(prefix: string, callback: (group: Router<T>) => void): this;
|
|
212
|
+
group<U extends Record<string, any> = {}>(prefix: string, callback: (group: Router<T & U>) => void): this;
|
|
213
213
|
/**
|
|
214
214
|
* Register middleware with flexible signature
|
|
215
215
|
* @overload
|
|
@@ -217,14 +217,14 @@ export declare class Router<T extends Record<string, any> = {}> extends Middlewa
|
|
|
217
217
|
* @param middlewares - Middleware(s) to register
|
|
218
218
|
* @param [callback] - Optional sub-router or handler
|
|
219
219
|
*/
|
|
220
|
-
use(path: string, middlewares: Middleware<T>[], callback: Callback<T> | Router<T | any>): this;
|
|
221
|
-
use(path: string, middleware: Middleware<T>, callback: Callback<T> | Router<T | any>): this;
|
|
222
|
-
use(path: string, middlewares: Middleware<T>[]): this;
|
|
223
|
-
use(path: string, middlewares: Middleware<T>): this;
|
|
224
|
-
use(path: string, callback: Callback<T> | Router<T | any>): this;
|
|
225
|
-
use(middlewares: Middleware<T>[], callback: Callback<T> | Router<T | any>): this;
|
|
226
|
-
use(middleware: Middleware<T>, callback: Callback<T> | Router<T | any>): this;
|
|
227
|
-
use(middlewares: Middleware<T>[]): this;
|
|
228
|
-
use(middleware: Middleware<T>): this;
|
|
229
|
-
use(callback: Callback<T> | Router<T | any>): this;
|
|
220
|
+
use<U extends Record<string, any> = {}>(path: string, middlewares: Middleware<T & U>[], callback: Callback<T & U> | Router<T & U | any>): this;
|
|
221
|
+
use<U extends Record<string, any> = {}>(path: string, middleware: Middleware<T & U>, callback: Callback<T & U> | Router<T & U | any>): this;
|
|
222
|
+
use<U extends Record<string, any> = {}>(path: string, middlewares: Middleware<T & U>[]): this;
|
|
223
|
+
use<U extends Record<string, any> = {}>(path: string, middlewares: Middleware<T & U>): this;
|
|
224
|
+
use<U extends Record<string, any> = {}>(path: string, callback: Callback<T & U> | Router<T & U | any>): this;
|
|
225
|
+
use<U extends Record<string, any> = {}>(middlewares: Middleware<T & U>[], callback: Callback<T & U> | Router<T & U | any>): this;
|
|
226
|
+
use<U extends Record<string, any> = {}>(middleware: Middleware<T & U>, callback: Callback<T & U> | Router<T & U | any>): this;
|
|
227
|
+
use<U extends Record<string, any> = {}>(middlewares: Middleware<T & U>[]): this;
|
|
228
|
+
use<U extends Record<string, any> = {}>(middleware: Middleware<T & U>): this;
|
|
229
|
+
use<U extends Record<string, any> = {}>(callback: Callback<T & U> | Router<T & U | any>): this;
|
|
230
230
|
}
|
package/core/router.js
CHANGED
|
@@ -213,7 +213,7 @@ export class Router extends MiddlewareConfigure {
|
|
|
213
213
|
if (!GlobalConfig.overwriteMethod && handler.has(method))
|
|
214
214
|
return;
|
|
215
215
|
return handler.set(method, {
|
|
216
|
-
callback,
|
|
216
|
+
callback: callback,
|
|
217
217
|
paramNames: [],
|
|
218
218
|
regex: regex,
|
|
219
219
|
middlewares: finalMiddleware
|
|
@@ -238,7 +238,7 @@ export class Router extends MiddlewareConfigure {
|
|
|
238
238
|
if (!GlobalConfig.overwriteMethod && handler.has(method))
|
|
239
239
|
return;
|
|
240
240
|
return handler.set(method, {
|
|
241
|
-
callback,
|
|
241
|
+
callback: callback,
|
|
242
242
|
regex: regex,
|
|
243
243
|
paramNames: paramNames,
|
|
244
244
|
middlewares: finalMiddleware
|
package/index.d.ts
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import { Router } from "./core/router.js";
|
|
2
2
|
import { TezX } from "./core/server.js";
|
|
3
|
-
import {
|
|
3
|
+
import { compileRegexRoute, regexMatchRoute } from "./utils/regexRouter.js";
|
|
4
4
|
export { Router } from "./core/router.js";
|
|
5
|
-
export type { Callback, ctx as Context, Middleware, NextCallback,
|
|
5
|
+
export type { Callback, ctx as Context, Middleware, NextCallback, PathType, RouterConfig, StaticServeOption } from "./core/router.js";
|
|
6
|
+
export type { Context as BaseContext } from "./core/context.js";
|
|
6
7
|
export type { AdapterType } from "./core/config.js";
|
|
7
8
|
export type { CookieOptions, ResponseHeaders } from "./core/context.js";
|
|
8
9
|
export type { NetAddr as AddressType, ConnAddress, FormDataOptions, HTTPMethod } from "./core/request.js";
|
|
9
10
|
export { TezX } from "./core/server.js";
|
|
10
11
|
export type { TezXConfig, TezXServeOptions } from "./core/server.js";
|
|
11
12
|
export type { UrlRef } from "./utils/url.js";
|
|
12
|
-
export {
|
|
13
|
+
export { compileRegexRoute, regexMatchRoute };
|
|
13
14
|
export declare let version: string;
|
|
14
15
|
declare const _default: {
|
|
15
16
|
Router: typeof Router;
|
package/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Router } from "./core/router.js";
|
|
2
2
|
import { TezX } from "./core/server.js";
|
|
3
|
-
import {
|
|
3
|
+
import { compileRegexRoute, regexMatchRoute } from "./utils/regexRouter.js";
|
|
4
4
|
export { Router } from "./core/router.js";
|
|
5
5
|
export { TezX } from "./core/server.js";
|
|
6
|
-
export {
|
|
7
|
-
export let version = "2.0.
|
|
6
|
+
export { compileRegexRoute, regexMatchRoute };
|
|
7
|
+
export let version = "2.0.10";
|
|
8
8
|
export default {
|
|
9
9
|
Router,
|
|
10
10
|
regexMatchRoute, compileRegexRoute,
|
package/middleware/index.d.ts
CHANGED
|
@@ -33,6 +33,6 @@ declare const _default: {
|
|
|
33
33
|
requestTimeout: (options: import("./requestTimeout.js").TimeoutOptions) => import("../index.js").Middleware;
|
|
34
34
|
sanitizeHeaders: (options?: import("./sanitizeHeader.js").SanitizeHeadersOptions) => import("../index.js").Middleware;
|
|
35
35
|
secureHeaders: (options?: import("./secureHeaders.js").SecurityHeaderOptions) => import("../index.js").Middleware;
|
|
36
|
-
xssProtection: (options?: import("./xssProtection.js").XSSProtectionOptions) => (ctx: import("../
|
|
36
|
+
xssProtection: (options?: import("./xssProtection.js").XSSProtectionOptions) => (ctx: import("../index.js").BaseContext, next: import("../index.js").NextCallback) => Promise<any>;
|
|
37
37
|
};
|
|
38
38
|
export default _default;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tezx",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.10",
|
|
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",
|