princejs 1.7.1 β†’ 1.7.3

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.
Files changed (3) hide show
  1. package/Readme.md +45 -122
  2. package/dist/create.js +1 -1
  3. package/package.json +1 -1
package/Readme.md CHANGED
@@ -1,12 +1,15 @@
1
- # PrinceJS β€” The Fastest Bun Framework in History
1
+ # πŸ‘‘ **PrinceJS**
2
2
 
3
- **2.8 kB gzipped** β€’ **19,200 req/s** β€’ **Built by a 13yo Nigerian**
3
+ ### ⚑ Ultra-clean, modern & minimal Bun web framework. Among the top three in performance.
4
4
 
5
- > *"I didn't beat Elysia. I destroyed it."* β€” @Lil_Prince_1218
5
+ ![npm](https://img.shields.io/npm/v/princejs)
6
+ ![stars](https://img.shields.io/github/stars/MatthewTheCoder1218/princejs)
7
+ ![downloads](https://img.shields.io/npm/dt/princejs)
8
+ ![license](https://img.shields.io/github/license/MatthewTheCoder1218/princejs)
6
9
 
7
10
  ---
8
11
 
9
- ## πŸ† World Record: Fastest Framework Under 3 kB
12
+ ## πŸš€ Quick Start
10
13
 
11
14
  ```bash
12
15
  bun create princejs my-app
@@ -31,60 +34,6 @@ app.listen(3000);
31
34
 
32
35
  ---
33
36
 
34
- ## βš”οΈ Size War (Gzipped β€” Real World)
35
-
36
- | Framework | Gzipped | Minified | vs PrinceJS |
37
- | ------------ | ---------- | -------- | --------------- |
38
- | **PrinceJS** | **2.8 kB** | 7.8 kB | β€” |
39
- | Hono | 7.3 kB | 18.7 kB | **2.6Γ— bigger** |
40
- | Elysia | 62.5 kB | 245 kB | **22Γ— bigger** |
41
-
42
- PrinceJS fits in a tweet. Elysia needs a ZIP file.
43
-
44
- ---
45
-
46
- ## ⚑ Benchmarks (autocannon -c 100 -d 30)
47
-
48
- **Windows 11 β€’ November 15, 2025 β€’ 100 connections β€’ 30 seconds**
49
- **Route:** `GET /users/:id`
50
-
51
- | Rank | Framework | Req/s | Requests (30s) | Throughput |
52
- | --------------- | ---------- | ----- | -------------- | ---------- |
53
- | πŸ₯‡ **PrinceJS** | **19,200** | 576k | 2.34 MB/s | |
54
- | πŸ₯ˆ Hono | 16,212 | 486k | 1.98 MB/s | |
55
- | πŸ₯‰ Elysia | 15,862 | 476k | 1.94 MB/s | |
56
- | 4️⃣ Express | 9,325 | 280k | 1.84 MB/s | |
57
-
58
- ### Summary
59
-
60
- * PrinceJS beats **Elysia by 21%** (3,338 more req/s)
61
- * PrinceJS beats **Hono by 18%** (2,988 more req/s)
62
- * PrinceJS beats **Express by 106%** (over 2Γ— faster)
63
-
64
- > PrinceJS is the FASTEST framework under 10 kB. Period.
65
-
66
- ---
67
-
68
- ## πŸ”₯ Why PrinceJS Wins
69
-
70
- ### 1. **Trie-Based Router (Cached)**
71
-
72
- Most frameworks rebuild routes on every request. PrinceJS builds once and caches.
73
-
74
- ### 2. **Zero Overhead Middleware**
75
-
76
- Middleware tracking prevents duplicate execution. No wasted cycles.
77
-
78
- ### 3. **Optimized for Bun**
79
-
80
- Native `Bun.serve()` with WebSocket support. No abstraction layers.
81
-
82
- ### 4. **Smart Body Parsing**
83
-
84
- Only parses body when needed. GET requests skip parsing entirely.
85
-
86
- ---
87
-
88
37
  ## 🧰 Features
89
38
 
90
39
  ```ts
@@ -94,7 +43,7 @@ import { z } from "zod";
94
43
 
95
44
  app
96
45
  .use(cors())
97
- .use(logger({ format: "dev" }))
46
+ .use(logger())
98
47
  .use(rateLimit({ max: 100, window: 60 }))
99
48
  .use(serve({ root: "./public" }))
100
49
  .use(validate(z.object({
@@ -110,9 +59,7 @@ app
110
59
  * Rate Limiting
111
60
  * Static Files
112
61
 
113
- ### βœ“ Validation
114
-
115
- * Zod schema validation
62
+ ### βœ“ Validation (Zod)
116
63
 
117
64
  ### βœ“ WebSocket Support
118
65
 
@@ -124,32 +71,31 @@ app
124
71
 
125
72
  ---
126
73
 
127
- ## New Tree-Shakable Features
74
+ ## New Tree‑Shakable Features
128
75
 
129
76
  ```ts
130
77
  import { cache, email, upload } from "princejs/helpers";
131
78
  import { cron, openapi } from "princejs/scheduler";
132
79
  ```
133
80
 
134
- * `cache(60)(handler)` β€” In-memory cache
135
- * `email(to, subject, html)` β€” Resend.com
136
- * `upload()` β€” 1-line file upload
137
- * `cron("*/2 * * * *", task)` β€” Cron support
81
+ * `cache(60)(handler)` β€” In‑memory cache
82
+ * `email(to, subject, html)` β€” Email helper
83
+ * `upload()` β€” One‑line file upload
84
+ * `cron("*/2 * * * *", task)` β€” Cron jobs
138
85
  * `openapi({ title, version })` β€” Auto docs
139
86
 
140
- **Tree-shakable = only what you import gets bundled**
141
-
142
87
  ---
143
88
 
144
- ## πŸ“¦ Installation
89
+ ## Performance With Oha (oha -c 100 -z 30s)
145
90
 
146
- ```bash
147
- npm install princejs
148
- # or
149
- bun add princejs
150
- # or
151
- yarn add princejs
152
- ```
91
+ | Framework | Req/s | Total |
92
+ |-----------|----------------|--------|
93
+ | Elysia | 25,312 req/s | 759k |
94
+ | Hono | 22,124 req/s | 664k |
95
+ | PrinceJS | 21,748 req/s | 653k |
96
+ | Express | 9,325 req/s | 280k |
97
+
98
+ ### Among the top three
153
99
 
154
100
  ---
155
101
 
@@ -163,47 +109,29 @@ import { cache, ai, upload } from "princejs/helpers";
163
109
  import { cron } from "princejs/scheduler";
164
110
  import { z } from "zod";
165
111
 
166
- const app = prince(true); // dev mode
112
+ const app = prince(true);
167
113
 
168
- // Middleware
169
114
  app.use(cors());
170
115
  app.use(logger());
171
116
  app.use(rateLimit({ max: 100, window: 60 }));
172
117
 
173
- // Validation
174
118
  app.use(validate(z.object({ name: z.string() })));
175
119
 
176
- // Routes
177
- app.get("/", () => ({
178
- message: "Welcome to PrinceJS",
179
- version: "3.3.1"
180
- }));
120
+ app.get("/", () => ({ message: "Welcome to PrinceJS" }));
181
121
 
182
- app.get("/users/:id", (req) => ({
183
- id: req.params.id,
184
- name: "John Doe"
185
- }));
122
+ app.get("/users/:id", (req) => ({ id: req.params.id }));
186
123
 
187
- // New: Cache
188
124
  app.get("/data", cache(60)(() => ({ time: Date.now() })));
189
125
 
190
- // New: AI
191
126
  app.post("/ai", async (req) => ({ reply: await ai(req.body.q) }));
192
127
 
193
- // New: Upload
194
- app.post("/upload", upload(), (req) => ({
195
- files: Object.keys(req.files || {}),
196
- body: req.body
197
- }));
128
+ app.post("/upload", upload(), (req) => ({ files: Object.keys(req.files || {}) }));
198
129
 
199
- // New: Cron
200
130
  cron("*/1 * * * *", () => console.log("PrinceJS heartbeat"));
201
131
 
202
- // WebSocket
203
132
  app.ws("/chat", {
204
133
  open: (ws) => ws.send("Welcome!"),
205
- message: (ws, msg) => ws.send(`Echo: ${msg}`),
206
- close: () => console.log("Disconnected")
134
+ message: (ws, msg) => ws.send(`Echo: ${msg}`)
207
135
  });
208
136
 
209
137
  app.listen(3000);
@@ -211,6 +139,18 @@ app.listen(3000);
211
139
 
212
140
  ---
213
141
 
142
+ ## πŸ“¦ Installation
143
+
144
+ ```bash
145
+ npm install princejs
146
+ # or
147
+ bun add princejs
148
+ # or
149
+ yarn add princejs
150
+ ```
151
+
152
+ ---
153
+
214
154
  ## πŸ“š Documentation
215
155
 
216
156
  Visit: **princejs.vercel.app**
@@ -219,8 +159,6 @@ Visit: **princejs.vercel.app**
219
159
 
220
160
  ## 🀝 Contributing
221
161
 
222
- Issues and PRs welcome!
223
-
224
162
  ```bash
225
163
  git clone https://github.com/MatthewTheCoder1218/princejs
226
164
  cd princejs
@@ -230,35 +168,20 @@ bun test
230
168
 
231
169
  ---
232
170
 
233
- ## πŸ‡³πŸ‡¬ Built in Nigeria
234
-
235
- Made by **@Lil_Prince_1218 β€” Age 13**
236
- *"2.8 kB. 19,200 req/s. The fastest framework under 10 kB."*
237
-
238
- Inspired by the greats (Express, Hono, Elysia) but built to win.
239
-
240
- ---
241
-
242
- ## πŸ“„ License
243
-
244
- MIT Β© 2025 **Matthew Michael**
245
-
246
- ---
247
-
248
171
  ## ⭐ Star This Repo
249
172
 
250
173
  If PrinceJS helped you, star the repo!
251
174
 
252
- GitHub: [github.com/MatthewTheCoder1218/princejs](https://github.com/MatthewTheCoder1218/princejs)
175
+ GitHub: [https://github.com/MatthewTheCoder1218/princejs](https://github.com/MatthewTheCoder1218/princejs)
253
176
 
254
177
  ---
255
178
 
256
179
  ## πŸ”— Links
257
180
 
258
- - [npm](https://www.npmjs.com/package/princejs)
259
- - [GitHub](https://github.com/MatthewTheCoder1218/princejs)
260
- - [Twitter](https://twitter.com/Lil_Prince_1218)
181
+ * npm: [https://www.npmjs.com/package/princejs](https://www.npmjs.com/package/princejs)
182
+ * GitHub: [https://github.com/MatthewTheCoder1218/princejs](https://github.com/MatthewTheCoder1218/princejs)
183
+ * Twitter: [https://twitter.com/Lil_Prince_1218](https://twitter.com/Lil_Prince_1218)
261
184
 
262
185
  ---
263
186
 
264
- **PrinceJS: Small in size. Giant in speed. πŸš€**
187
+ **PrinceJS: Small in size. Giant in capability. πŸš€**
package/dist/create.js CHANGED
@@ -7,7 +7,7 @@ import { join } from "path";
7
7
  var name = Bun.argv[2];
8
8
  if (!name) {
9
9
  console.error("\u274C Error: Please provide a project name");
10
- console.log("Usage: bunx create-princejs <project-name>");
10
+ console.log("Usage: bun create-princejs <project-name>");
11
11
  process.exit(1);
12
12
  }
13
13
  if (existsSync(name)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "princejs",
3
- "version": "1.7.1",
3
+ "version": "1.7.3",
4
4
  "description": "An easy and fast backend framework β€” by a 13yo developer, for developers.",
5
5
  "main": "dist/prince.js",
6
6
  "types": "dist/prince.d.ts",