tezx 1.0.29 → 1.0.31

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/README.md CHANGED
@@ -29,7 +29,7 @@ yarn add tezx
29
29
 
30
30
  <!-- ### Deno
31
31
 
32
- ```typescript
32
+ ```ts
33
33
  import { TezX } from "https://deno.land/x/tezx/mod.ts";
34
34
  ``` -->
35
35
 
@@ -46,10 +46,10 @@ Create a simple TezX server:
46
46
  ```javascript
47
47
  import { TezX } from "tezx";
48
48
  import { logger } from "tezx/middleware";
49
- import {nodeAdapter} from "tezx/adapter";
49
+ import { nodeAdapter } from "tezx/adapter";
50
50
 
51
51
  const app = new TezX();
52
- app.use(logger())
52
+ app.use(logger());
53
53
 
54
54
  app.static("/", "./static");
55
55
 
@@ -175,8 +175,8 @@ Add the following scripts to **`package.json`**:
175
175
 
176
176
  **`src/index.ts`**
177
177
 
178
- ```typescript
179
- import {bunAdapter} from "tezx/adapter";
178
+ ```ts
179
+ import { bunAdapter } from "tezx/adapter";
180
180
  bunAdapter(server).listen(3000, (message) => {
181
181
  console.log(message);
182
182
  });
@@ -192,8 +192,8 @@ bunAdapter(server).listen(3000, (message) => {
192
192
 
193
193
  **`src/index.ts`**
194
194
 
195
- ```typescript
196
- import {denoAdapter} from "tezx/adapter";
195
+ ```ts
196
+ import { denoAdapter } from "tezx/adapter";
197
197
  denoAdapter(server).listen(3000, (message) => {
198
198
  console.log(message);
199
199
  });
@@ -82,6 +82,7 @@ class Context {
82
82
  #status = 200;
83
83
  state = new state_1.State();
84
84
  #params = {};
85
+ body = {};
85
86
  #localAddress = {};
86
87
  #remoteAddress = {};
87
88
  constructor(req, connInfo) {
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.29";
10
+ exports.version = "1.0.31";
@@ -155,14 +155,16 @@ async function parseMultipartBody(req, boundary, options) {
155
155
  }
156
156
  if (formDataField[fieldName]) {
157
157
  if (Array.isArray(formDataField[fieldName])) {
158
+ const existingFiles = formDataField[fieldName].filter((f) => f instanceof File);
158
159
  if (typeof options?.maxFiles != "undefined" &&
159
- formDataField[fieldName]?.length >= options.maxFiles) {
160
+ existingFiles.length >= options.maxFiles) {
160
161
  reject(new Error(`Field "${fieldName}" exceeds the maximum allowed file count of ${options.maxFiles}.`));
161
162
  }
162
163
  formDataField[fieldName].push(file);
163
164
  }
164
165
  else {
165
- if (typeof options?.maxFiles != "undefined" &&
166
+ if (formDataField[fieldName] instanceof File &&
167
+ typeof options?.maxFiles != "undefined" &&
166
168
  options.maxFiles == 1) {
167
169
  reject(new Error(`Field "${fieldName}" exceeds the maximum allowed file count of ${options.maxFiles}.`));
168
170
  }
@@ -218,7 +220,8 @@ async function parseMultipartBody(req, boundary, options) {
218
220
  }
219
221
  else {
220
222
  if (val instanceof File &&
221
- typeof options?.maxFiles != "undefined" && options.maxFiles == 1) {
223
+ typeof options?.maxFiles != "undefined" &&
224
+ options.maxFiles == 1) {
222
225
  throw new Error(`Field "${key}" exceeds the maximum allowed file count of ${options.maxFiles}.`);
223
226
  }
224
227
  result[key] = [result[key], val];
package/core/context.d.ts CHANGED
@@ -51,6 +51,7 @@ export declare class Context<T extends Record<string, any> = {}> {
51
51
  * @type {State}
52
52
  */
53
53
  state: State;
54
+ body: Record<string, any>;
54
55
  constructor(req: any, connInfo: ConnAddress);
55
56
  /**
56
57
  * Cookie handling utility with get/set/delete operations
package/core/context.js CHANGED
@@ -79,6 +79,7 @@ export class Context {
79
79
  #status = 200;
80
80
  state = new State();
81
81
  #params = {};
82
+ body = {};
82
83
  #localAddress = {};
83
84
  #remoteAddress = {};
84
85
  constructor(req, connInfo) {
package/index.js CHANGED
@@ -1,4 +1,4 @@
1
1
  export { Router } from "./core/router";
2
2
  export { TezX } from "./core/server";
3
3
  export { useParams } from "./utils/params";
4
- export let version = "1.0.29";
4
+ export let version = "1.0.31";
@@ -15,7 +15,7 @@ export type SecurityHeaderOptions = {
15
15
  * @default true
16
16
  * @example
17
17
  * frameGuard: true // Always enable
18
- * frameGuard: (ctx) => !ctx.path.startsWith('/embed/') // Disable for embed routes
18
+ * frameGuard: (ctx) => !ctx.pathname.startsWith('/embed/') // Disable for embed routes
19
19
  */
20
20
  frameGuard?: boolean | ((ctx: Context) => boolean);
21
21
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tezx",
3
- "version": "1.0.29",
3
+ "version": "1.0.31",
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",
package/utils/formData.js CHANGED
@@ -149,14 +149,16 @@ export async function parseMultipartBody(req, boundary, options) {
149
149
  }
150
150
  if (formDataField[fieldName]) {
151
151
  if (Array.isArray(formDataField[fieldName])) {
152
+ const existingFiles = formDataField[fieldName].filter((f) => f instanceof File);
152
153
  if (typeof options?.maxFiles != "undefined" &&
153
- formDataField[fieldName]?.length >= options.maxFiles) {
154
+ existingFiles.length >= options.maxFiles) {
154
155
  reject(new Error(`Field "${fieldName}" exceeds the maximum allowed file count of ${options.maxFiles}.`));
155
156
  }
156
157
  formDataField[fieldName].push(file);
157
158
  }
158
159
  else {
159
- if (typeof options?.maxFiles != "undefined" &&
160
+ if (formDataField[fieldName] instanceof File &&
161
+ typeof options?.maxFiles != "undefined" &&
160
162
  options.maxFiles == 1) {
161
163
  reject(new Error(`Field "${fieldName}" exceeds the maximum allowed file count of ${options.maxFiles}.`));
162
164
  }
@@ -212,7 +214,8 @@ export async function parseMultipartBody(req, boundary, options) {
212
214
  }
213
215
  else {
214
216
  if (val instanceof File &&
215
- typeof options?.maxFiles != "undefined" && options.maxFiles == 1) {
217
+ typeof options?.maxFiles != "undefined" &&
218
+ options.maxFiles == 1) {
216
219
  throw new Error(`Field "${key}" exceeds the maximum allowed file count of ${options.maxFiles}.`);
217
220
  }
218
221
  result[key] = [result[key], val];