tezx 1.0.2 → 1.0.4

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 ADDED
@@ -0,0 +1,243 @@
1
+ # TezX - High-Performance JavaScript Framework
2
+
3
+ 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.
4
+
5
+ ## 🚀 Key Features
6
+
7
+ - **High Performance:** Optimized for speed and scalability.
8
+ - **Minimal & Intuitive API:** Simple yet powerful.
9
+ - **Built-in Static File Serving:** No additional setup required.
10
+ - **Robust Middleware Support:** Easily extend functionality.
11
+ - **Dynamic & Flexible Routing:** Define routes with ease.
12
+ - **Security First:** Designed with security best practices.
13
+ - **Efficient HTTP Handling:** Built for high concurrency.
14
+ - **Cross-Environment Support:** Works with **Node.js, Deno, and Bun**.
15
+
16
+ ## 📦 Installation
17
+
18
+ ### Node.js
19
+
20
+ ```bash
21
+ npm install tezx
22
+ ```
23
+
24
+ or using Yarn:
25
+
26
+ ```bash
27
+ yarn add tezx
28
+ ```
29
+
30
+ <!-- ### Deno
31
+
32
+ ```typescript
33
+ import { TezX } from "https://deno.land/x/tezx/mod.ts";
34
+ ``` -->
35
+
36
+ ### Bun
37
+
38
+ ```bash
39
+ bun add tezx
40
+ ```
41
+
42
+ ## 🚀 Quick Start
43
+
44
+ Create a simple TezX server:
45
+
46
+ ```javascript
47
+ import { logger, nodeAdapter, TezX } from "tezx";
48
+
49
+ const app = new TezX({ logger });
50
+
51
+ app.static("/", "./static");
52
+
53
+ app.get("/", (ctx) => {
54
+ return ctx.html(`
55
+ <h1>Welcome to TezX</h1>
56
+ <p>A modern, high-performance cross-environment framework.</p>
57
+ `);
58
+ });
59
+
60
+ nodeAdapter(app).listen(3001, (message) => {
61
+ console.log(message);
62
+ });
63
+ ```
64
+
65
+ ## ▶ Running the Server
66
+
67
+ ### Node.js
68
+
69
+ ```bash
70
+ node server.js
71
+ ```
72
+
73
+ For development with hot-reloading:
74
+
75
+ ```bash
76
+ npm install -g nodemon
77
+ nodemon server.js
78
+ ```
79
+
80
+ ### Deno
81
+
82
+ ```bash
83
+ deno run --allow-net server.ts
84
+ ```
85
+
86
+ ### Bun
87
+
88
+ ```bash
89
+ bun run server.js
90
+ ```
91
+
92
+ ## 🛠 Middleware Support
93
+
94
+ Enhance your application with middleware:
95
+
96
+ ```javascript
97
+ app.use((ctx, next) => {
98
+ console.log(`Incoming request: ${ctx.request.url}`);
99
+ return next();
100
+ });
101
+ ```
102
+
103
+ ## 📂 Serving Static Files
104
+
105
+ ```javascript
106
+ app.static("/public", "./public");
107
+ ```
108
+
109
+ Access static files via `/public/filename.ext`.
110
+
111
+ ## 🔀 Routing
112
+
113
+ ```javascript
114
+ app.get("/about", (ctx) => ctx.html("<h1>About Us</h1>"));
115
+
116
+ app.post("/submit", (ctx) =>
117
+ ctx.json({ message: "Form submitted successfully" }),
118
+ );
119
+ ```
120
+
121
+ ## ⚠️ Error Handling
122
+
123
+ ```javascript
124
+ app.onError((err, ctx) => {
125
+ return ctx.status(500).json({ error: "Internal Server Error" });
126
+ });
127
+ ```
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
+ <!--
222
+ ## 📖 Documentation
223
+
224
+ For full documentation, visit: [TezX Docs](https://tezx.dev/docs) -->
225
+
226
+ ## 🤝 Contributing
227
+
228
+ We welcome contributions! Submit issues and pull requests on our GitHub repository.
229
+
230
+ <!--
231
+ ## 👤 Author
232
+
233
+ **TezX Team**
234
+ 📧 Email: <support@tezx.dev>
235
+ 🌐 Website: [https://tezx.dev](https://tezx.dev) -->
236
+
237
+ ## 📜 License
238
+
239
+ TezX is open-source under the MIT License. See [LICENSE](LICENSE) for details.
240
+
241
+ ---
242
+
243
+ 🚀 **TezX - Build fast, scale faster.**