tezx 1.0.3 → 1.0.5
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 +105 -9
- package/dist/index.d.ts +7 -1
- package/dist/index.js +9 -0
- package/dist/index.mjs +9 -0
- package/package.json +10 -4
package/README.md
CHANGED
|
@@ -51,14 +51,14 @@ const app = new TezX({ logger });
|
|
|
51
51
|
app.static("/", "./static");
|
|
52
52
|
|
|
53
53
|
app.get("/", (ctx) => {
|
|
54
|
-
|
|
54
|
+
return ctx.html(`
|
|
55
55
|
<h1>Welcome to TezX</h1>
|
|
56
56
|
<p>A modern, high-performance cross-environment framework.</p>
|
|
57
57
|
`);
|
|
58
58
|
});
|
|
59
59
|
|
|
60
60
|
nodeAdapter(app).listen(3001, (message) => {
|
|
61
|
-
|
|
61
|
+
console.log(message);
|
|
62
62
|
});
|
|
63
63
|
```
|
|
64
64
|
|
|
@@ -95,8 +95,8 @@ Enhance your application with middleware:
|
|
|
95
95
|
|
|
96
96
|
```javascript
|
|
97
97
|
app.use((ctx, next) => {
|
|
98
|
-
|
|
99
|
-
|
|
98
|
+
console.log(`Incoming request: ${ctx.request.url}`);
|
|
99
|
+
return next();
|
|
100
100
|
});
|
|
101
101
|
```
|
|
102
102
|
|
|
@@ -113,7 +113,9 @@ Access static files via `/public/filename.ext`.
|
|
|
113
113
|
```javascript
|
|
114
114
|
app.get("/about", (ctx) => ctx.html("<h1>About Us</h1>"));
|
|
115
115
|
|
|
116
|
-
app.post("/submit", (ctx) =>
|
|
116
|
+
app.post("/submit", (ctx) =>
|
|
117
|
+
ctx.json({ message: "Form submitted successfully" }),
|
|
118
|
+
);
|
|
117
119
|
```
|
|
118
120
|
|
|
119
121
|
## ⚠️ Error Handling
|
|
@@ -123,7 +125,100 @@ app.onError((err, ctx) => {
|
|
|
123
125
|
return ctx.status(500).json({ error: "Internal Server Error" });
|
|
124
126
|
});
|
|
125
127
|
```
|
|
126
|
-
|
|
128
|
+
|
|
129
|
+
## ▶️ **Running the Server**
|
|
130
|
+
|
|
131
|
+
### **Clone Repository & Install Dependencies**
|
|
132
|
+
|
|
133
|
+
```bash
|
|
134
|
+
git clone https://github.com/tezxjs/tezx-app-example
|
|
135
|
+
npm install tezx@latest
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
### **Run Project in Development Mode**
|
|
139
|
+
|
|
140
|
+
```bash
|
|
141
|
+
npm run dev
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
This will start the TezX server on **<http://localhost:3000>**.
|
|
145
|
+
|
|
146
|
+
## **Platform-Specific Configurations**
|
|
147
|
+
|
|
148
|
+
### **Node.js**
|
|
149
|
+
|
|
150
|
+
Add the following scripts to **`package.json`**:
|
|
151
|
+
|
|
152
|
+
```json
|
|
153
|
+
"scripts": {
|
|
154
|
+
"build": "npx pkgroll --clean-dist",
|
|
155
|
+
"start": "node dist/index.js",
|
|
156
|
+
"nodemon": "nodemon src/index.ts",
|
|
157
|
+
"dev": "tsx watch src/index.ts"
|
|
158
|
+
}
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
### **Bun**
|
|
162
|
+
|
|
163
|
+
```json
|
|
164
|
+
"scripts": {
|
|
165
|
+
"dev": "bun run --hot --watch src/index.ts"
|
|
166
|
+
}
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
**`src/index.ts`**
|
|
170
|
+
|
|
171
|
+
```typescript
|
|
172
|
+
bunAdapter(server).listen(3000, (message) => {
|
|
173
|
+
console.log(message);
|
|
174
|
+
});
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
### **Deno**
|
|
178
|
+
|
|
179
|
+
```json
|
|
180
|
+
"scripts": {
|
|
181
|
+
"dev": "deno run --watch --allow-net --allow-read --allow-env --unstable-sloppy-imports src/index.ts"
|
|
182
|
+
}
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
**`src/index.ts`**
|
|
186
|
+
|
|
187
|
+
```typescript
|
|
188
|
+
denoAdapter(server).listen(3000, (message) => {
|
|
189
|
+
console.log(message);
|
|
190
|
+
});
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
## **Build & Deployment**
|
|
194
|
+
|
|
195
|
+
### **Compiling TypeScript to JavaScript**
|
|
196
|
+
|
|
197
|
+
#### **Using `tsc`**
|
|
198
|
+
|
|
199
|
+
```json
|
|
200
|
+
"build": "npx tsc"
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
#### **Using `pkgroll`**
|
|
204
|
+
|
|
205
|
+
```json
|
|
206
|
+
"build": "npx pkgroll --clean-dist"
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
### **Exports Configuration for Node.js**
|
|
210
|
+
|
|
211
|
+
```json
|
|
212
|
+
"exports": {
|
|
213
|
+
".": {
|
|
214
|
+
"require": "./dist/index.js",
|
|
215
|
+
"import": "./dist/index.mjs",
|
|
216
|
+
"types": "./dist/index.d.ts"
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
<!--
|
|
127
222
|
## 📖 Documentation
|
|
128
223
|
|
|
129
224
|
For full documentation, visit: [TezX Docs](https://tezx.dev/docs) -->
|
|
@@ -131,11 +226,12 @@ For full documentation, visit: [TezX Docs](https://tezx.dev/docs) -->
|
|
|
131
226
|
## 🤝 Contributing
|
|
132
227
|
|
|
133
228
|
We welcome contributions! Submit issues and pull requests on our GitHub repository.
|
|
134
|
-
|
|
229
|
+
|
|
230
|
+
<!--
|
|
135
231
|
## 👤 Author
|
|
136
232
|
|
|
137
|
-
**TezX Team**
|
|
138
|
-
📧 Email: <support@tezx.dev>
|
|
233
|
+
**TezX Team**
|
|
234
|
+
📧 Email: <support@tezx.dev>
|
|
139
235
|
🌐 Website: [https://tezx.dev](https://tezx.dev) -->
|
|
140
236
|
|
|
141
237
|
## 📜 License
|
package/dist/index.d.ts
CHANGED
|
@@ -327,6 +327,12 @@ declare class Context<T extends Record<string, any> = {}> {
|
|
|
327
327
|
* set: (name: string, value: string, options?: CookieOptions) => void
|
|
328
328
|
* }} Cookie handling interface
|
|
329
329
|
*/
|
|
330
|
+
/**
|
|
331
|
+
* Sets a header value.
|
|
332
|
+
* @param key - Header name.
|
|
333
|
+
* @param value - Header value(s).
|
|
334
|
+
*/
|
|
335
|
+
header(key: string, value: string | string[]): this;
|
|
330
336
|
get cookies(): {
|
|
331
337
|
/**
|
|
332
338
|
* Get a specific cookie by name.
|
|
@@ -641,7 +647,7 @@ declare class Router<T extends Record<string, any> = {}> extends MiddlewareConfi
|
|
|
641
647
|
* apiRouter.get('/users', () => { ... });
|
|
642
648
|
* server.addRouter('/api', apiRouter);
|
|
643
649
|
*/
|
|
644
|
-
addRouter(path: string, router: Router<T>): void;
|
|
650
|
+
addRouter(path: string, router: Router<T | any>): void;
|
|
645
651
|
/**
|
|
646
652
|
* Create route group with shared path prefix
|
|
647
653
|
* @param prefix - Path prefix for the group
|
package/dist/index.js
CHANGED
|
@@ -1807,6 +1807,15 @@ class Context {
|
|
|
1807
1807
|
* set: (name: string, value: string, options?: CookieOptions) => void
|
|
1808
1808
|
* }} Cookie handling interface
|
|
1809
1809
|
*/
|
|
1810
|
+
/**
|
|
1811
|
+
* Sets a header value.
|
|
1812
|
+
* @param key - Header name.
|
|
1813
|
+
* @param value - Header value(s).
|
|
1814
|
+
*/
|
|
1815
|
+
header(key, value) {
|
|
1816
|
+
this.headers.set(key, value);
|
|
1817
|
+
return this;
|
|
1818
|
+
}
|
|
1810
1819
|
get cookies() {
|
|
1811
1820
|
const c = this.headers.getAll("cookie");
|
|
1812
1821
|
let cookies = {};
|
package/dist/index.mjs
CHANGED
|
@@ -1805,6 +1805,15 @@ class Context {
|
|
|
1805
1805
|
* set: (name: string, value: string, options?: CookieOptions) => void
|
|
1806
1806
|
* }} Cookie handling interface
|
|
1807
1807
|
*/
|
|
1808
|
+
/**
|
|
1809
|
+
* Sets a header value.
|
|
1810
|
+
* @param key - Header name.
|
|
1811
|
+
* @param value - Header value(s).
|
|
1812
|
+
*/
|
|
1813
|
+
header(key, value) {
|
|
1814
|
+
this.headers.set(key, value);
|
|
1815
|
+
return this;
|
|
1816
|
+
}
|
|
1808
1817
|
get cookies() {
|
|
1809
1818
|
const c = this.headers.getAll("cookie");
|
|
1810
1819
|
let cookies = {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tezx",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
4
4
|
"description": "TezX is a cutting-edge, high-performance, and lightweight JavaScript framework designed for speed, scalability, and flexibility. Built with modern web development needs in mind, TezX enables efficient routing, middleware management, and static file serving with minimal configuration. It is fully compatible with Node.js, Deno, and Bun, making it a truly cross-environment framework.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -11,13 +11,19 @@
|
|
|
11
11
|
"dev": "nodemon --watch src --exec ts-node src/index.ts",
|
|
12
12
|
"start": "node dist/index.js"
|
|
13
13
|
},
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "git+https://github.com/tezxjs/TezX"
|
|
17
|
+
},
|
|
18
|
+
"bugs": {
|
|
19
|
+
"url": "https://github.com/tezxjs/TezX"
|
|
20
|
+
},
|
|
21
|
+
"homepage": "https://github.com/tezxjs/TezX",
|
|
14
22
|
"files": [
|
|
15
23
|
"dist/",
|
|
16
24
|
"dist/index.js",
|
|
17
25
|
"dist/index.mjs",
|
|
18
|
-
"dist/index.
|
|
19
|
-
"dist/index.d.ts",
|
|
20
|
-
"dist/index.mjs.map"
|
|
26
|
+
"dist/index.d.ts"
|
|
21
27
|
],
|
|
22
28
|
"keywords": [
|
|
23
29
|
"server",
|