tezx 4.0.7 → 4.0.8

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.
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Context = void 0;
4
4
  const mimeTypes_js_1 = require("../utils/mimeTypes.js");
5
5
  const response_js_1 = require("../utils/response.js");
6
- const utils_js_1 = require("../utils/utils.js");
7
6
  const request_js_1 = require("./request.js");
8
7
  class Context {
9
8
  #status = 200;
@@ -89,15 +88,7 @@ class Context {
89
88
  if (init?.filename) {
90
89
  headers["Content-Disposition"] = `attachment; filename="${init?.filename}"`;
91
90
  }
92
- let contentType = null;
93
- if (init?.download || init?.filename) {
94
- contentType = "application/octet-stream";
95
- }
96
- else {
97
- const ext = (0, utils_js_1.extensionExtract)(filePath);
98
- contentType = mimeTypes_js_1.mimeTypes[ext] ?? mimeTypes_js_1.defaultMimeType;
99
- }
100
- return this.createResponse(stream, contentType, {
91
+ return this.createResponse(stream, (init?.download || init?.filename) ? "application/octet-stream" : file?.type ?? mimeTypes_js_1.defaultMimeType, {
101
92
  status: init?.status ?? this.#status,
102
93
  statusText: init?.statusText,
103
94
  headers,
package/cjs/index.js CHANGED
@@ -5,7 +5,7 @@ const router_js_1 = require("./core/router.js");
5
5
  Object.defineProperty(exports, "Router", { enumerable: true, get: function () { return router_js_1.Router; } });
6
6
  const server_js_1 = require("./core/server.js");
7
7
  Object.defineProperty(exports, "TezX", { enumerable: true, get: function () { return server_js_1.TezX; } });
8
- exports.version = "4.0.7";
8
+ exports.version = "4.0.8";
9
9
  exports.default = {
10
10
  Router: router_js_1.Router,
11
11
  TezX: server_js_1.TezX,
@@ -11,7 +11,7 @@ function logger(options = { enabled: true }) {
11
11
  }
12
12
  console.log(`${(0, colors_js_1.colorText)("<--", "bold")} ${(0, colors_js_1.colorText)(ctx.method, "bgMagenta")} ${ctx.pathname}`);
13
13
  const startTime = performance.now();
14
- let n = (await next());
14
+ let n = (await next?.());
15
15
  const elapsed = performance.now() - startTime;
16
16
  console.log(`${(0, colors_js_1.colorText)("-->", "bold")} ${(0, colors_js_1.colorText)(ctx.method, "bgBlue")} ${ctx.pathname} ` +
17
17
  `${(0, colors_js_1.colorText)(ctx.res?.status ?? 404, "yellow")} ${(0, colors_js_1.colorText)(`${elapsed.toFixed(2)}ms`, "magenta")}`);
package/core/context.js CHANGED
@@ -1,6 +1,5 @@
1
- import { defaultMimeType, mimeTypes } from "../utils/mimeTypes.js";
1
+ import { defaultMimeType } from "../utils/mimeTypes.js";
2
2
  import { mergeHeaders } from "../utils/response.js";
3
- import { extensionExtract } from "../utils/utils.js";
4
3
  import { TezXRequest } from "./request.js";
5
4
  export class Context {
6
5
  #status = 200;
@@ -86,15 +85,7 @@ export class Context {
86
85
  if (init?.filename) {
87
86
  headers["Content-Disposition"] = `attachment; filename="${init?.filename}"`;
88
87
  }
89
- let contentType = null;
90
- if (init?.download || init?.filename) {
91
- contentType = "application/octet-stream";
92
- }
93
- else {
94
- const ext = extensionExtract(filePath);
95
- contentType = mimeTypes[ext] ?? defaultMimeType;
96
- }
97
- return this.createResponse(stream, contentType, {
88
+ return this.createResponse(stream, (init?.download || init?.filename) ? "application/octet-stream" : file?.type ?? defaultMimeType, {
98
89
  status: init?.status ?? this.#status,
99
90
  statusText: init?.statusText,
100
91
  headers,
package/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { Router } from "./core/router.js";
2
2
  import { TezX } from "./core/server.js";
3
3
  export { Router, TezX };
4
- export let version = "4.0.7";
4
+ export let version = "4.0.8";
5
5
  export default {
6
6
  Router,
7
7
  TezX,
@@ -7,7 +7,7 @@ function logger(options = { enabled: true }) {
7
7
  }
8
8
  console.log(`${colorText("<--", "bold")} ${colorText(ctx.method, "bgMagenta")} ${ctx.pathname}`);
9
9
  const startTime = performance.now();
10
- let n = (await next());
10
+ let n = (await next?.());
11
11
  const elapsed = performance.now() - startTime;
12
12
  console.log(`${colorText("-->", "bold")} ${colorText(ctx.method, "bgBlue")} ${ctx.pathname} ` +
13
13
  `${colorText(ctx.res?.status ?? 404, "yellow")} ${colorText(`${elapsed.toFixed(2)}ms`, "magenta")}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tezx",
3
- "version": "4.0.7",
3
+ "version": "4.0.8",
4
4
  "description": "TezX is a modern, ultra-lightweight, and high-performance JavaScript framework built specifically for Bun. It provides a minimal yet powerful API, seamless environment management, and a high-concurrency HTTP engine for building fast, scalable web applications.",
5
5
  "type": "module",
6
6
  "main": "cjs/index.js",