tezx 1.0.39 → 1.0.41
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/context.js +9 -7
- package/cjs/index.js +1 -1
- package/core/context.d.ts +19 -18
- package/core/context.js +9 -7
- package/core/router.d.ts +2 -3
- package/index.js +1 -1
- package/package.json +1 -1
package/cjs/core/context.js
CHANGED
|
@@ -75,7 +75,6 @@ class Context {
|
|
|
75
75
|
#rawRequest;
|
|
76
76
|
env = {};
|
|
77
77
|
headers = new header_1.HeadersParser();
|
|
78
|
-
res;
|
|
79
78
|
pathname;
|
|
80
79
|
url;
|
|
81
80
|
method;
|
|
@@ -93,8 +92,14 @@ class Context {
|
|
|
93
92
|
this.pathname = this.req.urlRef.pathname;
|
|
94
93
|
this.url = this.req.url;
|
|
95
94
|
}
|
|
96
|
-
header(key, value) {
|
|
97
|
-
|
|
95
|
+
header(key, value, options) {
|
|
96
|
+
let append = options?.append;
|
|
97
|
+
if (append) {
|
|
98
|
+
this.headers.append(key, value);
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
this.headers.set(key, value);
|
|
102
|
+
}
|
|
98
103
|
return this;
|
|
99
104
|
}
|
|
100
105
|
get cookies() {
|
|
@@ -387,10 +392,7 @@ class Context {
|
|
|
387
392
|
status: status,
|
|
388
393
|
headers,
|
|
389
394
|
});
|
|
390
|
-
|
|
391
|
-
this.body = body;
|
|
392
|
-
this.res = response;
|
|
393
|
-
return clone;
|
|
395
|
+
return response;
|
|
394
396
|
}
|
|
395
397
|
get req() {
|
|
396
398
|
return new request_1.Request(this.#rawRequest, this.params, this.#remoteAddress);
|
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.41";
|
package/core/context.d.ts
CHANGED
|
@@ -25,11 +25,6 @@ export declare class Context<T extends Record<string, any> = {}> {
|
|
|
25
25
|
* @type {HeadersParser}
|
|
26
26
|
*/
|
|
27
27
|
headers: HeadersParser;
|
|
28
|
-
/**
|
|
29
|
-
* Parser for handling and manipulating HTTP response(Read Only)
|
|
30
|
-
* @type {Response}
|
|
31
|
-
*/
|
|
32
|
-
readonly res: Response | undefined;
|
|
33
28
|
/**
|
|
34
29
|
* Request path without query parameters
|
|
35
30
|
* @type {string}
|
|
@@ -53,20 +48,26 @@ export declare class Context<T extends Record<string, any> = {}> {
|
|
|
53
48
|
state: State;
|
|
54
49
|
constructor(req: any, connInfo: ConnAddress);
|
|
55
50
|
/**
|
|
56
|
-
*
|
|
57
|
-
* @returns {{
|
|
58
|
-
* get: (name: string) => string | undefined,
|
|
59
|
-
* all: () => Record<string, string>,
|
|
60
|
-
* delete: (name: string, options?: CookieOptions) => void,
|
|
61
|
-
* set: (name: string, value: string, options?: CookieOptions) => void
|
|
62
|
-
* }} Cookie handling interface
|
|
63
|
-
*/
|
|
64
|
-
/**
|
|
65
|
-
* Sets a header value.
|
|
51
|
+
* Appends or set a value to an existing header or creates a new one.
|
|
66
52
|
* @param key - Header name.
|
|
67
|
-
* @param value -
|
|
68
|
-
|
|
69
|
-
|
|
53
|
+
* @param value - Value to append.
|
|
54
|
+
* @default {append:false}
|
|
55
|
+
*/
|
|
56
|
+
header(key: string, value: string, options?: {
|
|
57
|
+
append?: true;
|
|
58
|
+
}): this;
|
|
59
|
+
header(key: string, value: string | string[], options?: {
|
|
60
|
+
append?: false;
|
|
61
|
+
}): this;
|
|
62
|
+
/**
|
|
63
|
+
* Cookie handling utility with get/set/delete operations
|
|
64
|
+
* @returns {{
|
|
65
|
+
* get: (name: string) => string | undefined,
|
|
66
|
+
* all: () => Record<string, string>,
|
|
67
|
+
* delete: (name: string, options?: CookieOptions) => void,
|
|
68
|
+
* set: (name: string, value: string, options?: CookieOptions) => void
|
|
69
|
+
* }} Cookie handling interface
|
|
70
|
+
*/
|
|
70
71
|
get cookies(): {
|
|
71
72
|
/**
|
|
72
73
|
* Get a specific cookie by name.
|
package/core/context.js
CHANGED
|
@@ -72,7 +72,6 @@ export class Context {
|
|
|
72
72
|
#rawRequest;
|
|
73
73
|
env = {};
|
|
74
74
|
headers = new HeadersParser();
|
|
75
|
-
res;
|
|
76
75
|
pathname;
|
|
77
76
|
url;
|
|
78
77
|
method;
|
|
@@ -90,8 +89,14 @@ export class Context {
|
|
|
90
89
|
this.pathname = this.req.urlRef.pathname;
|
|
91
90
|
this.url = this.req.url;
|
|
92
91
|
}
|
|
93
|
-
header(key, value) {
|
|
94
|
-
|
|
92
|
+
header(key, value, options) {
|
|
93
|
+
let append = options?.append;
|
|
94
|
+
if (append) {
|
|
95
|
+
this.headers.append(key, value);
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
this.headers.set(key, value);
|
|
99
|
+
}
|
|
95
100
|
return this;
|
|
96
101
|
}
|
|
97
102
|
get cookies() {
|
|
@@ -384,10 +389,7 @@ export class Context {
|
|
|
384
389
|
status: status,
|
|
385
390
|
headers,
|
|
386
391
|
});
|
|
387
|
-
|
|
388
|
-
this.body = body;
|
|
389
|
-
this.res = response;
|
|
390
|
-
return clone;
|
|
392
|
+
return response;
|
|
391
393
|
}
|
|
392
394
|
get req() {
|
|
393
395
|
return new Request(this.#rawRequest, this.params, this.#remoteAddress);
|
package/core/router.d.ts
CHANGED
|
@@ -3,9 +3,8 @@ import MiddlewareConfigure, { DuplicateMiddlewares, UniqueMiddlewares } from "./
|
|
|
3
3
|
import { HTTPMethod } from "./request";
|
|
4
4
|
export type NextCallback = () => Promise<any>;
|
|
5
5
|
export type ctx<T extends Record<string, any> = {}> = Context<T> & T;
|
|
6
|
-
export type
|
|
7
|
-
export type
|
|
8
|
-
export type Middleware<T extends Record<string, any> = {}> = (ctx: ctx<T>, next: NextCallback) => NextCallback | Promise<NextCallback | Response> | Response | string | Record<string, any>;
|
|
6
|
+
export type Callback<T extends Record<string, any> = {}> = (ctx: ctx<T>) => Promise<Response> | Response | string | Record<string, any> | void;
|
|
7
|
+
export type Middleware<T extends Record<string, any> = {}> = (ctx: ctx<T>, next: NextCallback) => NextCallback | Promise<NextCallback> | Response | string | Record<string, any> | void;
|
|
9
8
|
export type RouterConfig = {
|
|
10
9
|
/**
|
|
11
10
|
* `env` allows you to define environment variables for the router.
|
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.41",
|
|
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",
|