baraqex 1.0.76 โ†’ 2.0.0

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 (182) hide show
  1. package/CHANGELOG.md +73 -0
  2. package/README.md +268 -315
  3. package/bin/baraqex.js +150 -12
  4. package/dist/browser.d.ts +1 -1
  5. package/dist/browser.d.ts.map +1 -1
  6. package/dist/browser.js +2319 -205
  7. package/dist/browser.js.map +4 -4
  8. package/dist/core/batch.d.ts +10 -0
  9. package/dist/core/batch.d.ts.map +1 -0
  10. package/dist/core/component.d.ts +69 -0
  11. package/dist/core/component.d.ts.map +1 -0
  12. package/dist/core/context.d.ts +22 -0
  13. package/dist/core/context.d.ts.map +1 -0
  14. package/dist/core/errors.d.ts +125 -0
  15. package/dist/core/errors.d.ts.map +1 -0
  16. package/dist/core/event-bus.d.ts +29 -0
  17. package/dist/core/event-bus.d.ts.map +1 -0
  18. package/dist/core/forms.d.ts +128 -0
  19. package/dist/core/forms.d.ts.map +1 -0
  20. package/dist/core/hooks.d.ts +84 -0
  21. package/dist/core/hooks.d.ts.map +1 -0
  22. package/dist/core/index.d.ts +23 -0
  23. package/dist/core/index.d.ts.map +1 -0
  24. package/dist/core/jsx-runtime.d.ts +45 -0
  25. package/dist/core/jsx-runtime.d.ts.map +1 -0
  26. package/dist/core/lifecycle-events.d.ts +71 -0
  27. package/dist/core/lifecycle-events.d.ts.map +1 -0
  28. package/dist/core/renderer.d.ts +39 -0
  29. package/dist/core/renderer.d.ts.map +1 -0
  30. package/dist/core/router.d.ts +108 -0
  31. package/dist/core/router.d.ts.map +1 -0
  32. package/dist/core/server-renderer.d.ts +26 -0
  33. package/dist/core/server-renderer.d.ts.map +1 -0
  34. package/dist/core/store.d.ts +102 -0
  35. package/dist/core/store.d.ts.map +1 -0
  36. package/dist/core/types.d.ts +66 -0
  37. package/dist/core/types.d.ts.map +1 -0
  38. package/dist/core/utils.d.ts +153 -0
  39. package/dist/core/utils.d.ts.map +1 -0
  40. package/dist/core/vdom.d.ts +29 -0
  41. package/dist/core/vdom.d.ts.map +1 -0
  42. package/dist/index.d.ts +39 -35
  43. package/dist/index.d.ts.map +1 -1
  44. package/dist/index.js +2592 -508
  45. package/dist/index.js.map +4 -4
  46. package/dist/server/auth.d.ts +8 -3
  47. package/dist/server/auth.d.ts.map +1 -1
  48. package/dist/server/index.d.ts +2 -2
  49. package/dist/server/index.d.ts.map +1 -1
  50. package/dist/server/index.js +173 -112
  51. package/dist/server/index.js.map +4 -4
  52. package/dist/server/middleware.d.ts +10 -1
  53. package/dist/server/middleware.d.ts.map +1 -1
  54. package/package.json +224 -124
  55. package/templates/basic-app/src/main.jsx +336 -0
  56. package/templates/complete-app/api/hello.js +0 -0
  57. package/templates/complete-app/client.js +58 -0
  58. package/templates/complete-app/lib/frontend-hamroun.js +182 -0
  59. package/templates/complete-app/package.json +18 -0
  60. package/templates/complete-app/pages/about.js +119 -0
  61. package/templates/complete-app/pages/about.jsx +0 -0
  62. package/templates/complete-app/pages/index.js +157 -0
  63. package/templates/complete-app/pages/index.jsx +0 -0
  64. package/templates/complete-app/pages/wasm-demo.js +290 -0
  65. package/templates/complete-app/pages/wasm-demo.jsx +0 -0
  66. package/templates/complete-app/public/client.js +89 -0
  67. package/templates/complete-app/public/index.html +118 -0
  68. package/templates/complete-app/public/styles.css +76 -0
  69. package/templates/complete-app/readme.md +188 -0
  70. package/templates/complete-app/server.js +226 -0
  71. package/templates/complete-app/server.ts +275 -0
  72. package/templates/complete-app/src/App.tsx +59 -0
  73. package/templates/complete-app/src/client.ts +61 -0
  74. package/templates/complete-app/src/client.tsx +18 -0
  75. package/templates/complete-app/src/pages/index.tsx +51 -0
  76. package/templates/complete-app/src/server.ts +218 -0
  77. package/templates/complete-app/tsconfig.json +22 -0
  78. package/templates/complete-app/tsconfig.server.json +19 -0
  79. package/templates/complete-app/vite.config.js +57 -0
  80. package/templates/complete-app/vite.config.ts +30 -0
  81. package/templates/complete-app/wasm/build.bat +0 -0
  82. package/templates/complete-app/wasm/build.sh +0 -0
  83. package/templates/complete-app/wasm/example.go +0 -0
  84. package/templates/fullstack-app/README.md +37 -0
  85. package/templates/fullstack-app/api/hello.js +11 -0
  86. package/templates/fullstack-app/api/hello.ts +18 -0
  87. package/templates/fullstack-app/api/users/[id].ts +73 -0
  88. package/templates/fullstack-app/api/users/index.ts +32 -0
  89. package/templates/fullstack-app/build/main.css +874 -0
  90. package/templates/fullstack-app/build/main.css.map +7 -0
  91. package/templates/fullstack-app/build/main.js +967 -0
  92. package/templates/fullstack-app/build/main.js.map +7 -0
  93. package/templates/fullstack-app/build.ts +210 -0
  94. package/templates/fullstack-app/index.html +36 -0
  95. package/templates/fullstack-app/package.json +35 -0
  96. package/templates/fullstack-app/postcss.config.js +6 -0
  97. package/templates/fullstack-app/process-tailwind.js +45 -0
  98. package/templates/fullstack-app/public/_redirects +1 -0
  99. package/templates/fullstack-app/public/route-handler.js +47 -0
  100. package/templates/fullstack-app/public/spa-fix.html +17 -0
  101. package/templates/fullstack-app/public/styles.css +975 -0
  102. package/templates/fullstack-app/public/tailwind.css +15 -0
  103. package/templates/fullstack-app/server.js +267 -0
  104. package/templates/fullstack-app/server.ts +474 -0
  105. package/templates/fullstack-app/src/README.md +55 -0
  106. package/templates/fullstack-app/src/client.js +87 -0
  107. package/templates/fullstack-app/src/components/ClientHome.tsx +0 -0
  108. package/templates/fullstack-app/src/components/ErrorBoundary.tsx +36 -0
  109. package/templates/fullstack-app/src/components/Layout.tsx +42 -0
  110. package/templates/fullstack-app/src/components/StateDemo.tsx +207 -0
  111. package/templates/fullstack-app/src/components/UserList.tsx +44 -0
  112. package/templates/fullstack-app/src/config.ts +42 -0
  113. package/templates/fullstack-app/src/data/api.ts +206 -0
  114. package/templates/fullstack-app/src/main.tsx +155 -0
  115. package/templates/fullstack-app/src/middleware.ts +28 -0
  116. package/templates/fullstack-app/src/pages/404.tsx +28 -0
  117. package/templates/fullstack-app/src/pages/[id].tsx +0 -0
  118. package/templates/fullstack-app/src/pages/_app.tsx +11 -0
  119. package/templates/fullstack-app/src/pages/_document.tsx +25 -0
  120. package/templates/fullstack-app/src/pages/_error.tsx +45 -0
  121. package/templates/fullstack-app/src/pages/about/index.tsx +67 -0
  122. package/templates/fullstack-app/src/pages/about.tsx +71 -0
  123. package/templates/fullstack-app/src/pages/api/users/[id].ts +73 -0
  124. package/templates/fullstack-app/src/pages/api/users/index.ts +43 -0
  125. package/templates/fullstack-app/src/pages/index.tsx +110 -0
  126. package/templates/fullstack-app/src/pages/users/[id].tsx +153 -0
  127. package/templates/fullstack-app/src/pages/users.tsx +60 -0
  128. package/templates/fullstack-app/src/pages/wasm-demo.tsx +1 -0
  129. package/templates/fullstack-app/src/router.ts +255 -0
  130. package/templates/fullstack-app/src/styles.css +5 -0
  131. package/templates/fullstack-app/tailwind.config.js +11 -0
  132. package/templates/fullstack-app/tsconfig.json +18 -0
  133. package/templates/fullstack-app/vite.config.js +87 -0
  134. package/templates/go/build.bat +36 -0
  135. package/templates/go/build.sh +43 -0
  136. package/templates/go/example.go +205 -0
  137. package/templates/go-wasm-app/README.md +38 -0
  138. package/templates/go-wasm-app/babel.config.js +21 -0
  139. package/templates/go-wasm-app/build-client.js +49 -0
  140. package/templates/go-wasm-app/build-wasm.js +237 -0
  141. package/templates/go-wasm-app/build.config.js +62 -0
  142. package/templates/go-wasm-app/build.js +218 -0
  143. package/templates/go-wasm-app/package.json +32 -0
  144. package/templates/go-wasm-app/public/index.html +128 -0
  145. package/templates/go-wasm-app/public/styles.css +197 -0
  146. package/templates/go-wasm-app/public/wasm/example.wasm +0 -0
  147. package/templates/go-wasm-app/public/wasm/wasm_exec.js +561 -0
  148. package/templates/go-wasm-app/public/wasm/wasm_exec_node.js +39 -0
  149. package/templates/go-wasm-app/server.js +70 -0
  150. package/templates/go-wasm-app/src/App.jsx +38 -0
  151. package/templates/go-wasm-app/src/app.js +173 -0
  152. package/templates/go-wasm-app/src/client.js +57 -0
  153. package/templates/go-wasm-app/src/components/Footer.jsx +13 -0
  154. package/templates/go-wasm-app/src/components/Header.jsx +19 -0
  155. package/templates/go-wasm-app/src/components/WasmDemo.jsx +120 -0
  156. package/templates/go-wasm-app/src/main.jsx +12 -0
  157. package/templates/go-wasm-app/src/wasm/example.go +75 -0
  158. package/templates/go-wasm-app/tsconfig.server.json +18 -0
  159. package/templates/go-wasm-app/vite.config.js +45 -0
  160. package/dist/forms/index.d.ts +0 -2
  161. package/dist/forms/index.d.ts.map +0 -1
  162. package/dist/forms/types.d.ts +0 -2
  163. package/dist/forms/types.d.ts.map +0 -1
  164. package/dist/frontend/components/WasmLoader.d.ts +0 -2
  165. package/dist/frontend/components/WasmLoader.d.ts.map +0 -1
  166. package/dist/frontend/hooks/useWasm.d.ts +0 -2
  167. package/dist/frontend/hooks/useWasm.d.ts.map +0 -1
  168. package/dist/frontend/index.d.ts +0 -2
  169. package/dist/frontend/index.d.ts.map +0 -1
  170. package/dist/router/index.d.ts +0 -2
  171. package/dist/router/index.d.ts.map +0 -1
  172. package/dist/router/types.d.ts +0 -2
  173. package/dist/router/types.d.ts.map +0 -1
  174. package/dist/store/index.d.ts +0 -2
  175. package/dist/store/index.d.ts.map +0 -1
  176. package/dist/store/types.d.ts +0 -2
  177. package/dist/store/types.d.ts.map +0 -1
  178. package/templates/basic-app/package-lock.json +0 -7173
  179. package/templates/fullstack-template/package-lock.json +0 -3558
  180. package/templates/ssr-template/package-lock.json +0 -5380
  181. package/templates/wasm/package-lock.json +0 -5347
  182. package/templates/wasm/public/example.wasm +0 -0
package/README.md CHANGED
@@ -1,442 +1,395 @@
1
1
  <div align="center">
2
2
 
3
- # ๐Ÿš€ Baraqex
3
+ <img src="https://raw.githubusercontent.com/mohamedx2/baraqex/main/assets/logo.svg" alt="Baraqex Logo" width="180" height="180">
4
4
 
5
- **A powerful, modern JavaScript/TypeScript framework for building universal web applications**
5
+ # Baraqex
6
6
 
7
- [![npm version](https://img.shields.io/npm/v/baraqex.svg)](https://www.npmjs.com/package/baraqex)
8
- [![Build Status](https://img.shields.io/github/workflow/status/hamroun/baraqex/CI)](https://github.com/hamroun/baraqex/actions)
9
- [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
10
- [![Discord](https://img.shields.io/discord/123456789?color=7289da&label=Discord&logo=discord)](https://discord.gg/baraqex)
7
+ ### โšก The Full-Stack Framework with WASM Superpowers
11
8
 
12
- [๐ŸŽฎ Try Interactive Demo](https://demo.baraqex.tech) โ€ข [๐Ÿ“š Documentation](https://docs.baraqex.tech) โ€ข [๐Ÿ’ฌ Discord](https://discord.gg/baraqex) โ€ข [๐Ÿ› Report Bug](https://github.com/hamroun/baraqex/issues)
9
+ Build universal web applications with React-like syntax and Go-powered performance.
10
+
11
+ [![npm version](https://img.shields.io/npm/v/baraqex?color=blue&label=npm)](https://www.npmjs.com/package/baraqex)
12
+ [![npm downloads](https://img.shields.io/npm/dm/baraqex?color=blue)](https://www.npmjs.com/package/baraqex)
13
+ [![GitHub stars](https://img.shields.io/github/stars/mohamedx2/baraqex?style=social)](https://github.com/mohamedx2/baraqex)
14
+ [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/licenses/MIT)
15
+ [![TypeScript](https://img.shields.io/badge/TypeScript-Ready-blue?logo=typescript)](https://www.typescriptlang.org/)
16
+ [![Docs](https://img.shields.io/badge/Docs-baraqex.tech-blue)](https://www.baraqex.tech)
17
+
18
+ [Get Started](#-quick-start) ยท [Documentation](https://www.baraqex.tech/docs) ยท [Examples](#-examples) ยท [Contributing](#-contributing)
13
19
 
14
20
  </div>
15
21
 
16
22
  ---
17
23
 
18
- ## ๐ŸŽฏ **What makes Baraqex special?**
24
+ ## Why Baraqex?
19
25
 
20
- <details>
21
- <summary>๐Ÿ”ฅ <strong>Click to see the magic happen</strong></summary>
26
+ | Feature | Baraqex | Others |
27
+ |---------|---------|--------|
28
+ | ๐Ÿš€ **WASM Integration** | Native Go/WASM support | Manual setup required |
29
+ | ๐Ÿ”„ **Universal Rendering** | SSR + CSR + Static | Framework-specific |
30
+ | โšก **Zero Config** | Works out of the box | Complex configuration |
31
+ | ๐ŸŽฏ **Full-Stack** | Frontend + Backend + API | Separate tools needed |
32
+ | ๐Ÿ“ฆ **Tiny Bundle** | < 15KB gzipped | Often 50KB+ |
22
33
 
23
- ```javascript
24
- // Write this once, run everywhere! ๐ŸŒ
25
- import { jsx, callWasmFunction } from 'baraqex';
34
+ ---
26
35
 
27
- function SuperFastApp() {
28
- // This Go function runs at near-native speed! โšก
29
- const result = callWasmFunction('fibonacci', 1000000);
30
-
31
- return <div>Computed {result} in milliseconds! ๐Ÿš€</div>;
32
- }
33
- ```
36
+ ## โœจ Features
34
37
 
35
- **Result:** Your heavy computations run 10-100x faster than pure JavaScript! ๐Ÿ“ˆ
38
+ - **๐Ÿ”ฅ WebAssembly First** - Run Go code in the browser at near-native speed
39
+ - **โš›๏ธ React-like Syntax** - Familiar JSX with hooks (`useState`, `useEffect`, etc.)
40
+ - **๐ŸŒ Universal Rendering** - SSR, CSR, and Static Generation
41
+ - **๐Ÿ›ฃ๏ธ File-based Routing** - Automatic API routes from your file structure
42
+ - **๐Ÿ” Built-in Auth** - JWT authentication with password hashing
43
+ - **๐Ÿ—„๏ธ Database Adapters** - MongoDB, PostgreSQL, MySQL out of the box
44
+ - **๐Ÿ“ก Real-time** - WebSocket support for live updates
45
+ - **๐ŸŽจ TypeScript** - Full type safety and IntelliSense
46
+ - **๐Ÿงช Tested** - 140+ tests with 56% coverage
36
47
 
37
- </details>
48
+ > **Built on [frontend-hamroun](https://www.npmjs.com/package/frontend-hamroun)** - The lightweight React-like core (~8KB gzipped)
38
49
 
39
50
  ---
40
51
 
41
- ## ๐ŸŽฎ **Try It Now - Interactive Playground**
42
-
43
- <details>
44
- <summary>๐ŸŽช <strong>Live Code Playground - Click to expand!</strong></summary>
52
+ ## ๐Ÿš€ Quick Start
45
53
 
46
- ### 1๏ธโƒฃ **Quick Start (30 seconds)**
54
+ ### Create a New Project
47
55
 
48
56
  ```bash
49
- # ๐Ÿš€ One command to rule them all
50
- npx create-baraqex-app my-super-app
51
- cd my-super-app
57
+ npx create-baraqex-app my-app
58
+ cd my-app
52
59
  npm run dev
53
60
  ```
54
61
 
55
- ### 2๏ธโƒฃ **Add Some WebAssembly Magic**
62
+ ### Or Install Manually
56
63
 
57
- ```javascript
58
- // โœจ Your first WASM-powered component
59
- import { jsx, useState, loadGoWasm, callWasmFunction } from 'baraqex';
64
+ ```bash
65
+ npm install baraqex
66
+ ```
60
67
 
61
- function Calculator() {
62
- const [result, setResult] = useState(0);
63
-
64
- const handleCalculate = async () => {
65
- // ๐Ÿ”ฅ This runs Go code in the browser!
66
- await loadGoWasm('/calculator.wasm');
67
- const answer = callWasmFunction('complexMath', 42);
68
- setResult(answer);
69
- };
68
+ ---
69
+
70
+ ## ๐Ÿ“– Basic Usage
71
+
72
+ ### Create a Component
73
+
74
+ ```jsx
75
+ import { jsx, useState } from 'baraqex';
76
+
77
+ function Counter() {
78
+ const [count, setCount] = useState(0);
70
79
 
71
80
  return (
72
- <div className="calculator">
73
- <h2>๐Ÿงฎ WASM Calculator</h2>
74
- <button onClick={handleCalculate}>
75
- Calculate ฯ€ to 1M digits! ๐Ÿฅง
81
+ <div>
82
+ <h1>Count: {count}</h1>
83
+ <button onClick={() => setCount(count + 1)}>
84
+ Increment
76
85
  </button>
77
- <div>Result: {result}</div>
78
86
  </div>
79
87
  );
80
88
  }
81
89
  ```
82
90
 
83
- ### 3๏ธโƒฃ **See It In Action**
91
+ ### Create an API Route
84
92
 
85
- [๐ŸŽฎ **Open Interactive Demo**](https://stackblitz.com/edit/baraqex-playground?file=src%2FApp.jsx) โ† **Click here to play!**
93
+ ```javascript
94
+ // api/users.js - automatically becomes /api/users
95
+ export async function get(req, res) {
96
+ const users = await db.query('SELECT * FROM users');
97
+ res.json(users);
98
+ }
86
99
 
87
- </details>
100
+ export async function post(req, res) {
101
+ const user = await db.insert('users', req.body);
102
+ res.status(201).json(user);
103
+ }
104
+ ```
88
105
 
89
- ---
106
+ ### Use WebAssembly
90
107
 
91
- ## โœจ **Feature Showcase**
108
+ ```jsx
109
+ import { loadGoWasm, callWasmFunction } from 'baraqex';
92
110
 
93
- <table>
94
- <tr>
95
- <td width="33%">
111
+ // Load your Go WASM module
112
+ await loadGoWasm('/math.wasm');
96
113
 
97
- ### ๐ŸŽญ **Universal JSX**
98
- ```jsx
99
- // Same code, everywhere!
100
- <MyComponent server={true} client={true} />
114
+ // Call Go functions from JavaScript
115
+ const result = callWasmFunction('fibonacci', 1000000);
116
+ console.log(result); // Computed in milliseconds!
101
117
  ```
102
- **No React dependency needed!**
103
118
 
104
- </td>
105
- <td width="33%">
119
+ ### Start a Server
106
120
 
107
- ### โšก **WebAssembly Power**
108
121
  ```javascript
109
- // Go functions in JavaScript!
110
- const result = callWasmFunction('goSort', bigArray);
111
- ```
112
- **10-100x faster than pure JS!**
122
+ import { Server } from 'baraqex/server';
113
123
 
114
- </td>
115
- <td width="33%">
124
+ const server = new Server({
125
+ port: 3000,
126
+ apiDir: './api',
127
+ pagesDir: './pages',
128
+ db: {
129
+ type: 'postgres',
130
+ url: process.env.DATABASE_URL
131
+ },
132
+ auth: {
133
+ secret: process.env.JWT_SECRET
134
+ }
135
+ });
116
136
 
117
- ### ๐Ÿ—๏ธ **Full-Stack Ready**
118
- ```javascript
119
- // API routes made simple
120
- export async function get(req, res) {
121
- res.json({ hello: 'world' });
122
- }
137
+ await server.start();
138
+ // ๐Ÿš€ Server running at http://localhost:3000
123
139
  ```
124
- **Zero configuration needed!**
125
140
 
126
- </td>
127
- </tr>
128
- </table>
141
+ ---
142
+
143
+ ## ๐Ÿ“š Documentation
144
+
145
+ ### Core Concepts
146
+
147
+ | Topic | Description |
148
+ |-------|-------------|
149
+ | [Components](docs/components.md) | Creating and composing components |
150
+ | [Hooks](docs/hooks.md) | useState, useEffect, useContext, and more |
151
+ | [Routing](docs/routing.md) | File-based and programmatic routing |
152
+ | [Server](docs/server.md) | Express-based server with middleware |
153
+ | [Database](docs/database.md) | MongoDB, PostgreSQL, MySQL adapters |
154
+ | [Authentication](docs/auth.md) | JWT tokens and password hashing |
155
+ | [WebAssembly](docs/wasm.md) | Go WASM integration guide |
156
+ | [SSR](docs/ssr.md) | Server-side rendering |
157
+
158
+ ### API Reference
159
+
160
+ ```typescript
161
+ // Browser APIs
162
+ import {
163
+ jsx,
164
+ Fragment,
165
+ render,
166
+ useState,
167
+ useEffect,
168
+ useContext,
169
+ useRef,
170
+ useMemo,
171
+ useCallback,
172
+ loadGoWasm,
173
+ callWasmFunction,
174
+ getWasmExports
175
+ } from 'baraqex';
176
+
177
+ // Server APIs
178
+ import {
179
+ Server,
180
+ Database,
181
+ AuthService,
182
+ ApiRouter,
183
+ rateLimit,
184
+ requestLogger,
185
+ errorHandler
186
+ } from 'baraqex/server';
187
+ ```
129
188
 
130
189
  ---
131
190
 
132
- ## ๐ŸŽฏ **Choose Your Adventure**
191
+ ## ๐ŸŽฏ Examples
133
192
 
134
- <details>
135
- <summary>๐ŸŽจ <strong>Frontend Developer</strong> - Build amazing UIs</summary>
193
+ ### Todo App with WASM
136
194
 
137
- ### **Quick Setup**
138
- ```bash
139
- npm install baraqex
140
- ```
195
+ ```jsx
196
+ import { jsx, useState, loadGoWasm, callWasmFunction } from 'baraqex';
141
197
 
142
- ### **Your First Component**
143
- ```javascript
144
- import { jsx, useState, useEffect } from 'baraqex';
198
+ function TodoApp() {
199
+ const [todos, setTodos] = useState([]);
200
+ const [input, setInput] = useState('');
145
201
 
146
- function CoolCounter() {
147
- const [count, setCount] = useState(0);
148
- const [wasmPowered, setWasmPowered] = useState(false);
149
-
150
- useEffect(() => {
151
- // Load your Go WASM module
152
- loadGoWasm('/math.wasm').then(() => {
153
- setWasmPowered(true);
154
- });
155
- }, []);
156
-
157
- const handleSuperCalculation = () => {
158
- if (wasmPowered) {
159
- // This runs your Go code!
160
- const result = callWasmFunction('fibonacci', count);
161
- console.log(`Fibonacci(${count}) = ${result}`);
202
+ const addTodo = () => {
203
+ // Use WASM for validation/processing
204
+ const validated = callWasmFunction('validateTodo', input);
205
+ if (validated) {
206
+ setTodos([...todos, { id: Date.now(), text: input }]);
207
+ setInput('');
162
208
  }
163
209
  };
164
-
210
+
165
211
  return (
166
- <div className="counter">
167
- <h1>๐Ÿš€ Super Counter</h1>
168
- <p>Count: {count}</p>
169
- <button onClick={() => setCount(count + 1)}>
170
- โž• Increment
171
- </button>
172
- <button
173
- onClick={handleSuperCalculation}
174
- disabled={!wasmPowered}
175
- className={wasmPowered ? 'ready' : 'loading'}
176
- >
177
- {wasmPowered ? 'โšก Calculate with WASM' : 'โณ Loading WASM...'}
178
- </button>
212
+ <div className="todo-app">
213
+ <h1>๐Ÿ“ WASM Todo</h1>
214
+ <input
215
+ value={input}
216
+ onChange={(e) => setInput(e.target.value)}
217
+ placeholder="Add a todo..."
218
+ />
219
+ <button onClick={addTodo}>Add</button>
220
+ <ul>
221
+ {todos.map(todo => (
222
+ <li key={todo.id}>{todo.text}</li>
223
+ ))}
224
+ </ul>
179
225
  </div>
180
226
  );
181
227
  }
182
228
  ```
183
229
 
184
- **[๐Ÿ“บ Watch Video Tutorial](https://youtube.com/watch?v=baraqex-frontend)** | **[๐ŸŽฎ Try Live Demo](https://demo.baraqex.tech/frontend)**
230
+ ### Full-Stack API
185
231
 
186
- </details>
187
-
188
- <details>
189
- <summary>๐Ÿ”ง <strong>Backend Developer</strong> - Build robust APIs</summary>
190
-
191
- ### **Server Setup**
192
232
  ```javascript
193
- import { createServer, Database, AuthService } from 'baraqex/server';
233
+ // server.js
234
+ import { Server } from 'baraqex/server';
194
235
 
195
- // ๐Ÿš€ Everything configured for you!
196
- const server = createServer({
236
+ const server = new Server({
197
237
  port: 3000,
198
- apiDir: './api', // File-based routing
199
- staticDir: './public', // Static file serving
200
- database: {
201
- type: 'mongodb',
202
- url: process.env.DATABASE_URL
203
- }
238
+ db: { type: 'mongodb', url: 'mongodb://localhost:27017/myapp' },
239
+ auth: { secret: 'your-secret-key' }
204
240
  });
205
241
 
206
- // ๐Ÿ” Built-in auth
207
- const auth = new AuthService({
208
- secret: process.env.JWT_SECRET
242
+ // Custom middleware
243
+ server.use((req, res, next) => {
244
+ console.log(`${req.method} ${req.url}`);
245
+ next();
209
246
  });
210
247
 
211
- server.start().then(() => {
212
- console.log('๐ŸŽ‰ Server running on http://localhost:3000');
213
- });
248
+ await server.start();
214
249
  ```
215
250
 
216
- ### **API Routes (File-based)**
217
251
  ```javascript
218
- // api/users.js - Becomes /api/users
219
- export async function get(req, res) {
220
- const users = await User.find({});
221
- res.json({ users });
222
- }
223
-
224
- export async function post(req, res) {
225
- const user = await User.create(req.body);
226
- res.json({ user });
227
- }
228
-
229
- // api/users/[id].js - Becomes /api/users/:id
230
- export async function get(req, res) {
231
- const user = await User.findById(req.params.id);
232
- res.json({ user });
252
+ // api/posts/[id].js - Dynamic routes
253
+ export async function get(req, res, { db }) {
254
+ const post = await db.query(`SELECT * FROM posts WHERE id = $1`, [req.params.id]);
255
+ res.json(post);
233
256
  }
234
257
  ```
235
258
 
236
- **[๐Ÿ“บ Watch Video Tutorial](https://youtube.com/watch?v=baraqex-backend)** | **[๐ŸŽฎ Try Live Demo](https://demo.baraqex.tech/backend)**
237
-
238
- </details>
239
-
240
- <details>
241
- <summary>โšก <strong>Performance Engineer</strong> - Supercharge with WebAssembly</summary>
242
-
243
- ### **Go WASM Module**
244
- ```go
245
- // wasm/math.go
246
- package main
247
-
248
- import (
249
- "fmt"
250
- "syscall/js"
251
- )
252
-
253
- func fibonacci(this js.Value, args []js.Value) interface{} {
254
- n := args[0].Int()
255
-
256
- if n <= 1 {
257
- return n
258
- }
259
-
260
- a, b := 0, 1
261
- for i := 2; i <= n; i++ {
262
- a, b = b, a+b
263
- }
264
-
265
- return b
266
- }
259
+ ---
267
260
 
268
- func isPrime(this js.Value, args []js.Value) interface{} {
269
- n := args[0].Int()
270
-
271
- if n < 2 {
272
- return false
273
- }
274
-
275
- for i := 2; i*i <= n; i++ {
276
- if n%i == 0 {
277
- return false
278
- }
279
- }
280
-
281
- return true
282
- }
261
+ ## ๐Ÿ—๏ธ Project Structure
283
262
 
284
- func main() {
285
- // Register functions for JavaScript
286
- js.Global().Set("fibonacci", js.FuncOf(fibonacci))
287
- js.Global().Set("isPrime", js.FuncOf(isPrime))
288
-
289
- fmt.Println("๐Ÿ”ฅ Go WASM module loaded!")
290
-
291
- // Keep the program running
292
- select {}
293
- }
294
263
  ```
295
-
296
- ### **Build & Use**
297
- ```bash
298
- # Build WASM module
299
- GOOS=js GOARCH=wasm go build -o public/math.wasm wasm/math.go
300
-
301
- # Use in your app
302
- npm run dev
264
+ my-app/
265
+ โ”œโ”€โ”€ api/ # API routes (file-based)
266
+ โ”‚ โ”œโ”€โ”€ users.js # โ†’ /api/users
267
+ โ”‚ โ””โ”€โ”€ posts/
268
+ โ”‚ โ”œโ”€โ”€ index.js # โ†’ /api/posts
269
+ โ”‚ โ””โ”€โ”€ [id].js # โ†’ /api/posts/:id
270
+ โ”œโ”€โ”€ pages/ # Page components
271
+ โ”‚ โ”œโ”€โ”€ index.jsx # โ†’ /
272
+ โ”‚ โ””โ”€โ”€ about.jsx # โ†’ /about
273
+ โ”œโ”€โ”€ public/ # Static assets
274
+ โ”œโ”€โ”€ src/
275
+ โ”‚ โ”œโ”€โ”€ components/ # Reusable components
276
+ โ”‚ โ””โ”€โ”€ wasm/ # Go WASM source files
277
+ โ”œโ”€โ”€ package.json
278
+ โ””โ”€โ”€ baraqex.config.js # Optional configuration
303
279
  ```
304
280
 
305
- ### **Performance Comparison**
306
- | Operation | JavaScript | Baraqex + WASM | Speedup |
307
- |-----------|------------|----------------|---------|
308
- | Fibonacci(40) | 1.2s | 0.08s | **15x faster** |
309
- | Prime check(1M) | 450ms | 45ms | **10x faster** |
310
- | Image processing | 2.1s | 0.3s | **7x faster** |
311
-
312
- **[๐Ÿ“บ Watch Performance Demo](https://youtube.com/watch?v=baraqex-performance)** | **[๐ŸŽฎ Try Benchmark](https://demo.baraqex.tech/benchmark)**
313
-
314
- </details>
315
-
316
281
  ---
317
282
 
318
- ## ๐Ÿ† **Success Stories**
319
-
320
- <details>
321
- <summary>๐Ÿ“ˆ <strong>Real Companies Using Baraqex</strong></summary>
283
+ ## โšก Performance
322
284
 
323
- ### ๐Ÿš€ **TechCorp Inc.**
324
- > *"Baraqex helped us reduce our computation time from 30 seconds to 3 seconds. Our users love the speed!"*
325
- >
326
- > **โ€” Sarah Johnson, CTO**
285
+ Baraqex is designed for speed:
327
286
 
328
- ### ๐Ÿ’ฐ **FinanceApp Ltd.**
329
- > *"The WebAssembly integration allowed us to run complex financial models directly in the browser. Game changer!"*
330
- >
331
- > **โ€” Mike Chen, Lead Developer**
287
+ | Metric | Value |
288
+ |--------|-------|
289
+ | Bundle Size | 14.2 KB (gzipped) |
290
+ | First Paint | < 50ms |
291
+ | Server Start | < 200ms |
292
+ | WASM Load | < 100ms |
293
+ | Rate Limit Check | < 0.01ms |
332
294
 
333
- ### ๐ŸŽฎ **GameStudio XYZ**
334
- > *"Our browser-based game now runs at 60fps thanks to Baraqex's WASM support."*
335
- >
336
- > **โ€” Alex Rodriguez, Technical Director**
295
+ Run benchmarks yourself:
337
296
 
338
- **[๐Ÿ“– Read More Success Stories](https://baraqex.tech/success-stories)**
339
-
340
- </details>
297
+ ```bash
298
+ npm run benchmark
299
+ ```
341
300
 
342
301
  ---
343
302
 
344
- ## ๐ŸŽ“ **Learning Path**
345
-
346
- ### ๐Ÿฅ‡ **Beginner Track** (30 minutes)
347
- 1. [๐ŸŽฎ **Interactive Tutorial**](https://learn.baraqex.tech/beginner) - Learn by building
348
- 2. [๐Ÿ“บ **Video Series**](https://youtube.com/playlist?list=baraqex-basics) - Step-by-step guides
349
- 3. [๐Ÿ’ฌ **Ask Questions**](https://discord.gg/baraqex) - Get help from the community
303
+ ## ๐Ÿงช Testing
350
304
 
351
- ### ๐Ÿฅˆ **Intermediate Track** (2 hours)
352
- 1. [๐Ÿ”ง **Full-Stack Workshop**](https://learn.baraqex.tech/fullstack) - Build a complete app
353
- 2. [โšก **WASM Deep Dive**](https://learn.baraqex.tech/wasm) - Master WebAssembly
354
- 3. [๐Ÿš€ **Deployment Guide**](https://learn.baraqex.tech/deploy) - Go live!
305
+ ```bash
306
+ # Run all tests
307
+ npm test
355
308
 
356
- ### ๐Ÿฅ‰ **Advanced Track** (1 day)
357
- 1. [๐Ÿ—๏ธ **Architecture Patterns**](https://learn.baraqex.tech/patterns) - Best practices
358
- 2. [๐Ÿ“Š **Performance Optimization**](https://learn.baraqex.tech/performance) - Make it fast
359
- 3. [๐Ÿ”ฌ **Contributing Guide**](https://learn.baraqex.tech/contributing) - Join the team
309
+ # Run with coverage
310
+ npm run test:coverage
360
311
 
361
- ---
312
+ # Run specific tests
313
+ npm run test:unit
314
+ npm run test:integration
362
315
 
363
- ## ๐ŸŽช **Community Challenges**
316
+ # Run benchmarks
317
+ npm run test:benchmarks
318
+ ```
364
319
 
365
- <details>
366
- <summary>๐Ÿ† <strong>Monthly Coding Challenges</strong> - Win prizes!</summary>
320
+ ---
367
321
 
368
- ### ๐ŸŽฏ **December 2024: Speed Challenge**
369
- Build the fastest image processing app using Baraqex + WASM!
322
+ ## ๐Ÿค Contributing
370
323
 
371
- **Prizes:**
372
- - ๐Ÿฅ‡ **1st Place:** $500 + Baraqex Pro License
373
- - ๐Ÿฅˆ **2nd Place:** $300 + Swag Pack
374
- - ๐Ÿฅ‰ **3rd Place:** $100 + Stickers
324
+ We love contributions! See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
375
325
 
376
- **[๐ŸŽฎ Join Challenge](https://challenges.baraqex.tech/speed-2024)**
326
+ ```bash
327
+ # Clone the repo
328
+ git clone https://github.com/mohamedx2/baraqex.git
329
+ cd baraqex
377
330
 
378
- ### ๐Ÿ“… **Upcoming Challenges**
379
- - **January 2025:** Best UI/UX Design
380
- - **February 2025:** Most Creative Use Case
381
- - **March 2025:** Best Tutorial Creation
331
+ # Install dependencies
332
+ npm install
382
333
 
383
- **[๐Ÿ“ง Get Notified](https://baraqex.tech/challenges/subscribe)**
334
+ # Run tests
335
+ npm test
384
336
 
385
- </details>
337
+ # Start development
338
+ npm run dev
339
+ ```
386
340
 
387
341
  ---
388
342
 
389
- ## ๐Ÿš€ **Get Started Now!**
343
+ ## ๐Ÿ“ฆ Templates
390
344
 
391
- <div align="center">
392
-
393
- ### Choose your starting point:
394
-
395
- **[๐ŸŽฎ Interactive Tutorial](https://learn.baraqex.tech)** | **[๐Ÿ“บ Video Course](https://youtube.com/baraqex)** | **[๐Ÿ’ฌ Join Discord](https://discord.gg/baraqex)**
396
-
397
- ### Quick Commands:
345
+ Create projects with pre-configured templates:
398
346
 
399
347
  ```bash
400
- # ๐Ÿš€ Create new project
401
- npx create-baraqex-app my-app
348
+ # Basic app
349
+ npx create-baraqex-app my-app --template basic
402
350
 
403
- # ๐Ÿ“ฆ Add to existing project
404
- npm install baraqex
351
+ # Full-stack with database
352
+ npx create-baraqex-app my-app --template fullstack
353
+
354
+ # SSR application
355
+ npx create-baraqex-app my-app --template ssr
405
356
 
406
- # ๐ŸŽฎ Try online playground
407
- open https://stackblitz.com/edit/baraqex-playground
357
+ # WASM-powered app
358
+ npx create-baraqex-app my-app --template wasm
408
359
  ```
409
360
 
410
- ### ๐ŸŒŸ **Star us on GitHub if you like what you see!**
361
+ ---
411
362
 
412
- [![GitHub stars](https://img.shields.io/github/stars/hamroun/baraqex.svg?style=social&label=Star)](https://github.com/hamroun/baraqex)
363
+ ## ๐Ÿ—บ๏ธ Roadmap
413
364
 
414
- </div>
365
+ - [x] Core framework with JSX support
366
+ - [x] WebAssembly integration
367
+ - [x] Server-side rendering
368
+ - [x] Database adapters (MongoDB, PostgreSQL, MySQL)
369
+ - [x] Authentication system
370
+ - [x] CLI with project scaffolding
371
+ - [ ] Edge runtime support
372
+ - [ ] GraphQL integration
373
+ - [ ] React Server Components
374
+ - [ ] Incremental Static Regeneration
375
+ - [ ] Built-in caching layer
415
376
 
416
377
  ---
417
378
 
418
- ## ๐Ÿ“ฑ **Stay Connected**
419
-
420
- <div align="center">
379
+ ## ๐Ÿ“„ License
421
380
 
422
- | Platform | Link | Purpose |
423
- |----------|------|---------|
424
- | ๐ŸŒ **Website** | [baraqex.tech](https://baraqex.tech) | Official docs & news |
425
- | ๐Ÿ’ฌ **Discord** | [Join Chat](https://discord.gg/baraqex) | Real-time help & community |
426
- | ๐Ÿฆ **Twitter** | [@baraqexjs](https://twitter.com/baraqexjs) | Updates & tips |
427
- | ๐Ÿ“บ **YouTube** | [Baraqex Channel](https://youtube.com/baraqex) | Tutorials & demos |
428
- | ๐Ÿ“ง **Newsletter** | [Subscribe](https://baraqex.tech/newsletter) | Monthly updates |
429
-
430
- </div>
381
+ MIT ยฉ [Mohamed X](https://github.com/mohamedx2)
431
382
 
432
383
  ---
433
384
 
434
385
  <div align="center">
435
386
 
436
- **Made with โค๏ธ by the Baraqex community**
387
+ **[โฌ† Back to Top](#baraqex)**
388
+
389
+ Made with โค๏ธ by the Baraqex team
437
390
 
438
- *Build the future of web applications with WebAssembly and modern JavaScript.*
391
+ **One Culture, One Framework** | **ุซู‚ุงูุฉ ูˆุงุญุฏุฉุŒ ุฅุทุงุฑ ุนู…ู„ ูˆุงุญุฏ**
439
392
 
440
- **[๐Ÿš€ Start Building Now](https://learn.baraqex.tech)** โ€ข **[๐Ÿ’– Sponsor Project](https://github.com/sponsors/hamroun)**
393
+ [Website](https://www.baraqex.tech) ยท [Docs](https://www.baraqex.tech/docs) ยท [GitHub](https://github.com/mohamedx2/baraqex) ยท [npm](https://www.npmjs.com/package/baraqex) ยท [Arabic Community](https://www.baraqex.tech/arabic)
441
394
 
442
395
  </div>