tezx 4.0.8 → 4.0.11
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 +0 -9
- package/cjs/core/router.js +3 -3
- package/cjs/index.js +1 -1
- package/core/context.d.ts +3 -3
- package/core/router.d.ts +1 -6
- package/core/router.js +3 -3
- package/core/server.d.ts +1 -1
- package/index.js +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -46,14 +46,6 @@ app.use(logger());
|
|
|
46
46
|
// Static files
|
|
47
47
|
app.static(serveStatic("/", "./static"));
|
|
48
48
|
|
|
49
|
-
// Route
|
|
50
|
-
app.get("/", (ctx) =>
|
|
51
|
-
ctx.html(`
|
|
52
|
-
<h1>Welcome to TezX</h1>
|
|
53
|
-
<p>High-performance JavaScript framework optimized for Bun.</p>
|
|
54
|
-
`)
|
|
55
|
-
);
|
|
56
|
-
|
|
57
49
|
// Server
|
|
58
50
|
const port = Number(process.env.PORT) || 3001;
|
|
59
51
|
|
|
@@ -111,7 +103,6 @@ http://localhost:3001/assets/your-file.ext
|
|
|
111
103
|
## 🧭 Routing
|
|
112
104
|
|
|
113
105
|
```ts
|
|
114
|
-
app.get("/about", (ctx) => ctx.html("<h1>About TezX</h1>"));
|
|
115
106
|
|
|
116
107
|
app.post("/contact", async (ctx) => {
|
|
117
108
|
const body = await ctx.json();
|
package/cjs/core/router.js
CHANGED
|
@@ -4,7 +4,7 @@ exports.Router = void 0;
|
|
|
4
4
|
const url_js_1 = require("../utils/url.js");
|
|
5
5
|
class Router {
|
|
6
6
|
router;
|
|
7
|
-
|
|
7
|
+
routes = [];
|
|
8
8
|
staticFile = Object.create(null);
|
|
9
9
|
basePath;
|
|
10
10
|
constructor({ basePath = "/" } = {}) {
|
|
@@ -150,7 +150,7 @@ class Router {
|
|
|
150
150
|
#addRoute(method, path, handlers) {
|
|
151
151
|
let pattern = `/${(0, url_js_1.sanitizePathSplitBasePath)(this.basePath, path).join("/")}`;
|
|
152
152
|
this.router?.addRoute?.(method, pattern, handlers);
|
|
153
|
-
this.
|
|
153
|
+
this.routes.push({
|
|
154
154
|
method: method,
|
|
155
155
|
pattern: pattern,
|
|
156
156
|
handlers: handlers,
|
|
@@ -186,7 +186,7 @@ class Router {
|
|
|
186
186
|
if (!(router instanceof Router)) {
|
|
187
187
|
throw new Error("Router instance is required.");
|
|
188
188
|
}
|
|
189
|
-
router.
|
|
189
|
+
router.routes.forEach((r) => {
|
|
190
190
|
this.#addRoute(r?.method, `/${(0, url_js_1.sanitizePathSplitBasePath)(path, r?.pattern).join("/")}`, r?.handlers);
|
|
191
191
|
});
|
|
192
192
|
Object.assign(this.staticFile, router.staticFile);
|
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.
|
|
8
|
+
exports.version = "4.0.11";
|
|
9
9
|
exports.default = {
|
|
10
10
|
Router: router_js_1.Router,
|
|
11
11
|
TezX: server_js_1.TezX,
|
package/core/context.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ExtractParamsFromPath, HttpBaseResponse, ResHeaderKey, ResponseInit
|
|
1
|
+
import { ExtractParamsFromPath, HttpBaseResponse, ResHeaderKey, ResponseInit } from "../types/index.js";
|
|
2
2
|
import { ContentType } from "../utils/mimeTypes.js";
|
|
3
3
|
import { TezXRequest } from "./request.js";
|
|
4
4
|
export declare class Context<TPath extends string = any> {
|
|
@@ -49,7 +49,7 @@ export declare class Context<TPath extends string = any> {
|
|
|
49
49
|
* @type {string}
|
|
50
50
|
*/
|
|
51
51
|
readonly method: string;
|
|
52
|
-
constructor(req: Request, pathname: string, method: string, server:
|
|
52
|
+
constructor(req: Request, pathname: string, method: string, server: any);
|
|
53
53
|
/**
|
|
54
54
|
* Access the response headers.
|
|
55
55
|
*
|
|
@@ -243,5 +243,5 @@ export declare class Context<TPath extends string = any> {
|
|
|
243
243
|
* @public
|
|
244
244
|
* @returns {Bun.Server} The active Bun server instance.
|
|
245
245
|
*/
|
|
246
|
-
get server():
|
|
246
|
+
get server(): any;
|
|
247
247
|
}
|
package/core/router.d.ts
CHANGED
|
@@ -23,7 +23,7 @@ export declare class Router<T extends Record<string, any> = {}> {
|
|
|
23
23
|
/** Internal route registry to hold all routes */
|
|
24
24
|
protected router?: RouteRegistry;
|
|
25
25
|
/** Array tracking registered routes and their handlers */
|
|
26
|
-
protected
|
|
26
|
+
protected routes: {
|
|
27
27
|
method: string;
|
|
28
28
|
pattern: string;
|
|
29
29
|
handlers: HandlerType;
|
|
@@ -120,11 +120,6 @@ export declare class Router<T extends Record<string, any> = {}> {
|
|
|
120
120
|
options<U extends Record<string, any> = {}, Path extends string = any>(path: Path, callback: Callback<T & U, Path>): this;
|
|
121
121
|
options<U extends Record<string, any> = {}, Path extends string = any>(path: Path, middleware: Middleware<T & U, Path>, callback: Callback<T & U, Path>): this;
|
|
122
122
|
options<U extends Record<string, any> = {}, Path extends string = any>(path: Path, middlewares: Middleware<T & U, Path>[], callback: Callback<T & U, Path>): this;
|
|
123
|
-
/**
|
|
124
|
-
* Registers a HEAD route (returns headers only)
|
|
125
|
-
* @param path - URL path pattern
|
|
126
|
-
* @param args - Handler callback or middleware(s) + handler
|
|
127
|
-
*/
|
|
128
123
|
/**
|
|
129
124
|
* Register a route that responds to all HTTP methods.
|
|
130
125
|
*
|
package/core/router.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { sanitizePathSplitBasePath } from "../utils/url.js";
|
|
2
2
|
export class Router {
|
|
3
3
|
router;
|
|
4
|
-
|
|
4
|
+
routes = [];
|
|
5
5
|
staticFile = Object.create(null);
|
|
6
6
|
basePath;
|
|
7
7
|
constructor({ basePath = "/" } = {}) {
|
|
@@ -147,7 +147,7 @@ export class Router {
|
|
|
147
147
|
#addRoute(method, path, handlers) {
|
|
148
148
|
let pattern = `/${sanitizePathSplitBasePath(this.basePath, path).join("/")}`;
|
|
149
149
|
this.router?.addRoute?.(method, pattern, handlers);
|
|
150
|
-
this.
|
|
150
|
+
this.routes.push({
|
|
151
151
|
method: method,
|
|
152
152
|
pattern: pattern,
|
|
153
153
|
handlers: handlers,
|
|
@@ -183,7 +183,7 @@ export class Router {
|
|
|
183
183
|
if (!(router instanceof Router)) {
|
|
184
184
|
throw new Error("Router instance is required.");
|
|
185
185
|
}
|
|
186
|
-
router.
|
|
186
|
+
router.routes.forEach((r) => {
|
|
187
187
|
this.#addRoute(r?.method, `/${sanitizePathSplitBasePath(path, r?.pattern).join("/")}`, r?.handlers);
|
|
188
188
|
});
|
|
189
189
|
Object.assign(this.staticFile, router.staticFile);
|
package/core/server.d.ts
CHANGED
|
@@ -69,5 +69,5 @@ export declare class TezX<T extends Record<string, any> = {}> extends Router<T>
|
|
|
69
69
|
* fetch: (req) => app.serve(req, server),
|
|
70
70
|
* });
|
|
71
71
|
*/
|
|
72
|
-
serve(req: Request, server:
|
|
72
|
+
serve(req: Request, server: any): Promise<Response>;
|
|
73
73
|
}
|
package/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tezx",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.11",
|
|
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",
|
|
@@ -104,4 +104,4 @@
|
|
|
104
104
|
],
|
|
105
105
|
"author": "SRAKIB17",
|
|
106
106
|
"license": "MIT"
|
|
107
|
-
}
|
|
107
|
+
}
|