tinny-backend 1.0.9 → 1.1.0

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.
@@ -255,14 +255,6 @@ export default class Server {
255
255
  }
256
256
  Req.body = body;
257
257
  body = "";
258
- let handlersCount = 0;
259
- for (const fun of this.golobalMidellWare) {
260
- await fun.handler(req, res);
261
- if (res.writableEnded) {
262
- handlersCount++;
263
- break;
264
- }
265
- }
266
258
  for (let i = 0; i < this.methodHandler.length; i++) {
267
259
  const match = Req.ReqUrl?.pathname.match(this.methodHandler[i]?.regex ?? "");
268
260
  if (this.methodHandler[i]?.method == req.method
@@ -271,24 +263,28 @@ export default class Server {
271
263
  this.methodHandler[i]?.paramNames.forEach((name, index) => {
272
264
  Req.params[name] = match[index + 1] || "";
273
265
  });
274
- if (!Res.isClosed) {
266
+ if (!res.writableEnded) {
275
267
  if (this.methodHandler[i]?.middelWares && typeof this.methodHandler[i]?.middelWares != "undefined") {
276
268
  for (const middelware of this.methodHandler[i]?.middelWares ?? []) {
277
269
  await middelware(Req, Res);
278
- if (Res.isClosed)
270
+ if (res.writableEnded)
279
271
  break;
280
272
  }
281
273
  }
282
- if (!Res.isClosed)
274
+ if (!res.writableEnded)
283
275
  await this.methodHandler[i]?.handler(req, res);
284
276
  const nextFn = this.methodHandler[i]?.next;
285
- if (typeof nextFn === "function")
277
+ if (typeof nextFn === "function" && !res.writableEnded)
286
278
  await nextFn(Req, Res);
287
- handlersCount++;
288
279
  }
289
280
  }
290
281
  }
291
- if (!handlersCount) {
282
+ for (const fun of this.golobalMidellWare) {
283
+ if (res.writableEnded)
284
+ break;
285
+ await fun.handler(req, res);
286
+ }
287
+ if (!res.writableEnded) {
292
288
  this.defaultHandler(Req, Res);
293
289
  }
294
290
  });
@@ -1 +1 @@
1
- export declare const VERSION = "1.0.9";
1
+ export declare const VERSION = "1.1.0";
@@ -1 +1 @@
1
- export const VERSION = "1.0.9";
1
+ export const VERSION = "1.1.0";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tinny-backend",
3
- "version": "1.0.9",
3
+ "version": "1.1.0",
4
4
  "description": "A lightweight and flexible backend framework built on Node.js.",
5
5
  "license": "MIT",
6
6
  "author": {