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.
- package/CHANGELOG.md +73 -0
- package/README.md +268 -315
- package/bin/baraqex.js +150 -12
- package/dist/browser.d.ts +1 -1
- package/dist/browser.d.ts.map +1 -1
- package/dist/browser.js +2319 -205
- package/dist/browser.js.map +4 -4
- package/dist/core/batch.d.ts +10 -0
- package/dist/core/batch.d.ts.map +1 -0
- package/dist/core/component.d.ts +69 -0
- package/dist/core/component.d.ts.map +1 -0
- package/dist/core/context.d.ts +22 -0
- package/dist/core/context.d.ts.map +1 -0
- package/dist/core/errors.d.ts +125 -0
- package/dist/core/errors.d.ts.map +1 -0
- package/dist/core/event-bus.d.ts +29 -0
- package/dist/core/event-bus.d.ts.map +1 -0
- package/dist/core/forms.d.ts +128 -0
- package/dist/core/forms.d.ts.map +1 -0
- package/dist/core/hooks.d.ts +84 -0
- package/dist/core/hooks.d.ts.map +1 -0
- package/dist/core/index.d.ts +23 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/jsx-runtime.d.ts +45 -0
- package/dist/core/jsx-runtime.d.ts.map +1 -0
- package/dist/core/lifecycle-events.d.ts +71 -0
- package/dist/core/lifecycle-events.d.ts.map +1 -0
- package/dist/core/renderer.d.ts +39 -0
- package/dist/core/renderer.d.ts.map +1 -0
- package/dist/core/router.d.ts +108 -0
- package/dist/core/router.d.ts.map +1 -0
- package/dist/core/server-renderer.d.ts +26 -0
- package/dist/core/server-renderer.d.ts.map +1 -0
- package/dist/core/store.d.ts +102 -0
- package/dist/core/store.d.ts.map +1 -0
- package/dist/core/types.d.ts +66 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/core/utils.d.ts +153 -0
- package/dist/core/utils.d.ts.map +1 -0
- package/dist/core/vdom.d.ts +29 -0
- package/dist/core/vdom.d.ts.map +1 -0
- package/dist/index.d.ts +39 -35
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2592 -508
- package/dist/index.js.map +4 -4
- package/dist/server/auth.d.ts +8 -3
- package/dist/server/auth.d.ts.map +1 -1
- package/dist/server/index.d.ts +2 -2
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +173 -112
- package/dist/server/index.js.map +4 -4
- package/dist/server/middleware.d.ts +10 -1
- package/dist/server/middleware.d.ts.map +1 -1
- package/package.json +224 -124
- package/templates/basic-app/src/main.jsx +336 -0
- package/templates/complete-app/api/hello.js +0 -0
- package/templates/complete-app/client.js +58 -0
- package/templates/complete-app/lib/frontend-hamroun.js +182 -0
- package/templates/complete-app/package.json +18 -0
- package/templates/complete-app/pages/about.js +119 -0
- package/templates/complete-app/pages/about.jsx +0 -0
- package/templates/complete-app/pages/index.js +157 -0
- package/templates/complete-app/pages/index.jsx +0 -0
- package/templates/complete-app/pages/wasm-demo.js +290 -0
- package/templates/complete-app/pages/wasm-demo.jsx +0 -0
- package/templates/complete-app/public/client.js +89 -0
- package/templates/complete-app/public/index.html +118 -0
- package/templates/complete-app/public/styles.css +76 -0
- package/templates/complete-app/readme.md +188 -0
- package/templates/complete-app/server.js +226 -0
- package/templates/complete-app/server.ts +275 -0
- package/templates/complete-app/src/App.tsx +59 -0
- package/templates/complete-app/src/client.ts +61 -0
- package/templates/complete-app/src/client.tsx +18 -0
- package/templates/complete-app/src/pages/index.tsx +51 -0
- package/templates/complete-app/src/server.ts +218 -0
- package/templates/complete-app/tsconfig.json +22 -0
- package/templates/complete-app/tsconfig.server.json +19 -0
- package/templates/complete-app/vite.config.js +57 -0
- package/templates/complete-app/vite.config.ts +30 -0
- package/templates/complete-app/wasm/build.bat +0 -0
- package/templates/complete-app/wasm/build.sh +0 -0
- package/templates/complete-app/wasm/example.go +0 -0
- package/templates/fullstack-app/README.md +37 -0
- package/templates/fullstack-app/api/hello.js +11 -0
- package/templates/fullstack-app/api/hello.ts +18 -0
- package/templates/fullstack-app/api/users/[id].ts +73 -0
- package/templates/fullstack-app/api/users/index.ts +32 -0
- package/templates/fullstack-app/build/main.css +874 -0
- package/templates/fullstack-app/build/main.css.map +7 -0
- package/templates/fullstack-app/build/main.js +967 -0
- package/templates/fullstack-app/build/main.js.map +7 -0
- package/templates/fullstack-app/build.ts +210 -0
- package/templates/fullstack-app/index.html +36 -0
- package/templates/fullstack-app/package.json +35 -0
- package/templates/fullstack-app/postcss.config.js +6 -0
- package/templates/fullstack-app/process-tailwind.js +45 -0
- package/templates/fullstack-app/public/_redirects +1 -0
- package/templates/fullstack-app/public/route-handler.js +47 -0
- package/templates/fullstack-app/public/spa-fix.html +17 -0
- package/templates/fullstack-app/public/styles.css +975 -0
- package/templates/fullstack-app/public/tailwind.css +15 -0
- package/templates/fullstack-app/server.js +267 -0
- package/templates/fullstack-app/server.ts +474 -0
- package/templates/fullstack-app/src/README.md +55 -0
- package/templates/fullstack-app/src/client.js +87 -0
- package/templates/fullstack-app/src/components/ClientHome.tsx +0 -0
- package/templates/fullstack-app/src/components/ErrorBoundary.tsx +36 -0
- package/templates/fullstack-app/src/components/Layout.tsx +42 -0
- package/templates/fullstack-app/src/components/StateDemo.tsx +207 -0
- package/templates/fullstack-app/src/components/UserList.tsx +44 -0
- package/templates/fullstack-app/src/config.ts +42 -0
- package/templates/fullstack-app/src/data/api.ts +206 -0
- package/templates/fullstack-app/src/main.tsx +155 -0
- package/templates/fullstack-app/src/middleware.ts +28 -0
- package/templates/fullstack-app/src/pages/404.tsx +28 -0
- package/templates/fullstack-app/src/pages/[id].tsx +0 -0
- package/templates/fullstack-app/src/pages/_app.tsx +11 -0
- package/templates/fullstack-app/src/pages/_document.tsx +25 -0
- package/templates/fullstack-app/src/pages/_error.tsx +45 -0
- package/templates/fullstack-app/src/pages/about/index.tsx +67 -0
- package/templates/fullstack-app/src/pages/about.tsx +71 -0
- package/templates/fullstack-app/src/pages/api/users/[id].ts +73 -0
- package/templates/fullstack-app/src/pages/api/users/index.ts +43 -0
- package/templates/fullstack-app/src/pages/index.tsx +110 -0
- package/templates/fullstack-app/src/pages/users/[id].tsx +153 -0
- package/templates/fullstack-app/src/pages/users.tsx +60 -0
- package/templates/fullstack-app/src/pages/wasm-demo.tsx +1 -0
- package/templates/fullstack-app/src/router.ts +255 -0
- package/templates/fullstack-app/src/styles.css +5 -0
- package/templates/fullstack-app/tailwind.config.js +11 -0
- package/templates/fullstack-app/tsconfig.json +18 -0
- package/templates/fullstack-app/vite.config.js +87 -0
- package/templates/go/build.bat +36 -0
- package/templates/go/build.sh +43 -0
- package/templates/go/example.go +205 -0
- package/templates/go-wasm-app/README.md +38 -0
- package/templates/go-wasm-app/babel.config.js +21 -0
- package/templates/go-wasm-app/build-client.js +49 -0
- package/templates/go-wasm-app/build-wasm.js +237 -0
- package/templates/go-wasm-app/build.config.js +62 -0
- package/templates/go-wasm-app/build.js +218 -0
- package/templates/go-wasm-app/package.json +32 -0
- package/templates/go-wasm-app/public/index.html +128 -0
- package/templates/go-wasm-app/public/styles.css +197 -0
- package/templates/go-wasm-app/public/wasm/example.wasm +0 -0
- package/templates/go-wasm-app/public/wasm/wasm_exec.js +561 -0
- package/templates/go-wasm-app/public/wasm/wasm_exec_node.js +39 -0
- package/templates/go-wasm-app/server.js +70 -0
- package/templates/go-wasm-app/src/App.jsx +38 -0
- package/templates/go-wasm-app/src/app.js +173 -0
- package/templates/go-wasm-app/src/client.js +57 -0
- package/templates/go-wasm-app/src/components/Footer.jsx +13 -0
- package/templates/go-wasm-app/src/components/Header.jsx +19 -0
- package/templates/go-wasm-app/src/components/WasmDemo.jsx +120 -0
- package/templates/go-wasm-app/src/main.jsx +12 -0
- package/templates/go-wasm-app/src/wasm/example.go +75 -0
- package/templates/go-wasm-app/tsconfig.server.json +18 -0
- package/templates/go-wasm-app/vite.config.js +45 -0
- package/dist/forms/index.d.ts +0 -2
- package/dist/forms/index.d.ts.map +0 -1
- package/dist/forms/types.d.ts +0 -2
- package/dist/forms/types.d.ts.map +0 -1
- package/dist/frontend/components/WasmLoader.d.ts +0 -2
- package/dist/frontend/components/WasmLoader.d.ts.map +0 -1
- package/dist/frontend/hooks/useWasm.d.ts +0 -2
- package/dist/frontend/hooks/useWasm.d.ts.map +0 -1
- package/dist/frontend/index.d.ts +0 -2
- package/dist/frontend/index.d.ts.map +0 -1
- package/dist/router/index.d.ts +0 -2
- package/dist/router/index.d.ts.map +0 -1
- package/dist/router/types.d.ts +0 -2
- package/dist/router/types.d.ts.map +0 -1
- package/dist/store/index.d.ts +0 -2
- package/dist/store/index.d.ts.map +0 -1
- package/dist/store/types.d.ts +0 -2
- package/dist/store/types.d.ts.map +0 -1
- package/templates/basic-app/package-lock.json +0 -7173
- package/templates/fullstack-template/package-lock.json +0 -3558
- package/templates/ssr-template/package-lock.json +0 -5380
- package/templates/wasm/package-lock.json +0 -5347
- package/templates/wasm/public/example.wasm +0 -0
package/README.md
CHANGED
|
@@ -1,442 +1,395 @@
|
|
|
1
1
|
<div align="center">
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
<img src="https://raw.githubusercontent.com/mohamedx2/baraqex/main/assets/logo.svg" alt="Baraqex Logo" width="180" height="180">
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
# Baraqex
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
[](https://github.com/hamroun/baraqex/actions)
|
|
9
|
-
[](https://opensource.org/licenses/MIT)
|
|
10
|
-
[](https://discord.gg/baraqex)
|
|
7
|
+
### โก The Full-Stack Framework with WASM Superpowers
|
|
11
8
|
|
|
12
|
-
|
|
9
|
+
Build universal web applications with React-like syntax and Go-powered performance.
|
|
10
|
+
|
|
11
|
+
[](https://www.npmjs.com/package/baraqex)
|
|
12
|
+
[](https://www.npmjs.com/package/baraqex)
|
|
13
|
+
[](https://github.com/mohamedx2/baraqex)
|
|
14
|
+
[](https://opensource.org/licenses/MIT)
|
|
15
|
+
[](https://www.typescriptlang.org/)
|
|
16
|
+
[](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
|
-
##
|
|
24
|
+
## Why Baraqex?
|
|
19
25
|
|
|
20
|
-
|
|
21
|
-
|
|
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
|
-
|
|
24
|
-
// Write this once, run everywhere! ๐
|
|
25
|
-
import { jsx, callWasmFunction } from 'baraqex';
|
|
34
|
+
---
|
|
26
35
|
|
|
27
|
-
|
|
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
|
-
**
|
|
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
|
-
|
|
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
|
-
##
|
|
42
|
-
|
|
43
|
-
<details>
|
|
44
|
-
<summary>๐ช <strong>Live Code Playground - Click to expand!</strong></summary>
|
|
52
|
+
## ๐ Quick Start
|
|
45
53
|
|
|
46
|
-
###
|
|
54
|
+
### Create a New Project
|
|
47
55
|
|
|
48
56
|
```bash
|
|
49
|
-
|
|
50
|
-
|
|
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
|
-
###
|
|
62
|
+
### Or Install Manually
|
|
56
63
|
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
|
|
64
|
+
```bash
|
|
65
|
+
npm install baraqex
|
|
66
|
+
```
|
|
60
67
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
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
|
|
73
|
-
<
|
|
74
|
-
<button onClick={
|
|
75
|
-
|
|
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
|
-
###
|
|
91
|
+
### Create an API Route
|
|
84
92
|
|
|
85
|
-
|
|
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
|
-
|
|
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
|
-
|
|
108
|
+
```jsx
|
|
109
|
+
import { loadGoWasm, callWasmFunction } from 'baraqex';
|
|
92
110
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
<td width="33%">
|
|
111
|
+
// Load your Go WASM module
|
|
112
|
+
await loadGoWasm('/math.wasm');
|
|
96
113
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
//
|
|
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
|
-
|
|
105
|
-
<td width="33%">
|
|
119
|
+
### Start a Server
|
|
106
120
|
|
|
107
|
-
### โก **WebAssembly Power**
|
|
108
121
|
```javascript
|
|
109
|
-
|
|
110
|
-
const result = callWasmFunction('goSort', bigArray);
|
|
111
|
-
```
|
|
112
|
-
**10-100x faster than pure JS!**
|
|
122
|
+
import { Server } from 'baraqex/server';
|
|
113
123
|
|
|
114
|
-
|
|
115
|
-
|
|
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
|
-
|
|
118
|
-
|
|
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
|
-
|
|
127
|
-
|
|
128
|
-
|
|
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
|
-
## ๐ฏ
|
|
191
|
+
## ๐ฏ Examples
|
|
133
192
|
|
|
134
|
-
|
|
135
|
-
<summary>๐จ <strong>Frontend Developer</strong> - Build amazing UIs</summary>
|
|
193
|
+
### Todo App with WASM
|
|
136
194
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
npm install baraqex
|
|
140
|
-
```
|
|
195
|
+
```jsx
|
|
196
|
+
import { jsx, useState, loadGoWasm, callWasmFunction } from 'baraqex';
|
|
141
197
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
198
|
+
function TodoApp() {
|
|
199
|
+
const [todos, setTodos] = useState([]);
|
|
200
|
+
const [input, setInput] = useState('');
|
|
145
201
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
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="
|
|
167
|
-
<h1
|
|
168
|
-
<
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
</
|
|
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
|
-
|
|
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
|
-
|
|
233
|
+
// server.js
|
|
234
|
+
import { Server } from 'baraqex/server';
|
|
194
235
|
|
|
195
|
-
|
|
196
|
-
const server = createServer({
|
|
236
|
+
const server = new Server({
|
|
197
237
|
port: 3000,
|
|
198
|
-
|
|
199
|
-
|
|
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
|
-
//
|
|
207
|
-
|
|
208
|
-
|
|
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()
|
|
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/
|
|
219
|
-
export async function get(req, res) {
|
|
220
|
-
const
|
|
221
|
-
res.json(
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
#
|
|
302
|
-
|
|
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
|
-
##
|
|
319
|
-
|
|
320
|
-
<details>
|
|
321
|
-
<summary>๐ <strong>Real Companies Using Baraqex</strong></summary>
|
|
283
|
+
## โก Performance
|
|
322
284
|
|
|
323
|
-
|
|
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
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
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
|
-
|
|
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
|
-
|
|
339
|
-
|
|
340
|
-
|
|
297
|
+
```bash
|
|
298
|
+
npm run benchmark
|
|
299
|
+
```
|
|
341
300
|
|
|
342
301
|
---
|
|
343
302
|
|
|
344
|
-
##
|
|
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
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
3. [๐ **Deployment Guide**](https://learn.baraqex.tech/deploy) - Go live!
|
|
305
|
+
```bash
|
|
306
|
+
# Run all tests
|
|
307
|
+
npm test
|
|
355
308
|
|
|
356
|
-
|
|
357
|
-
|
|
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
|
-
|
|
316
|
+
# Run benchmarks
|
|
317
|
+
npm run test:benchmarks
|
|
318
|
+
```
|
|
364
319
|
|
|
365
|
-
|
|
366
|
-
<summary>๐ <strong>Monthly Coding Challenges</strong> - Win prizes!</summary>
|
|
320
|
+
---
|
|
367
321
|
|
|
368
|
-
|
|
369
|
-
Build the fastest image processing app using Baraqex + WASM!
|
|
322
|
+
## ๐ค Contributing
|
|
370
323
|
|
|
371
|
-
|
|
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
|
-
|
|
326
|
+
```bash
|
|
327
|
+
# Clone the repo
|
|
328
|
+
git clone https://github.com/mohamedx2/baraqex.git
|
|
329
|
+
cd baraqex
|
|
377
330
|
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
- **February 2025:** Most Creative Use Case
|
|
381
|
-
- **March 2025:** Best Tutorial Creation
|
|
331
|
+
# Install dependencies
|
|
332
|
+
npm install
|
|
382
333
|
|
|
383
|
-
|
|
334
|
+
# Run tests
|
|
335
|
+
npm test
|
|
384
336
|
|
|
385
|
-
|
|
337
|
+
# Start development
|
|
338
|
+
npm run dev
|
|
339
|
+
```
|
|
386
340
|
|
|
387
341
|
---
|
|
388
342
|
|
|
389
|
-
##
|
|
343
|
+
## ๐ฆ Templates
|
|
390
344
|
|
|
391
|
-
|
|
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
|
-
#
|
|
401
|
-
npx create-baraqex-app my-app
|
|
348
|
+
# Basic app
|
|
349
|
+
npx create-baraqex-app my-app --template basic
|
|
402
350
|
|
|
403
|
-
#
|
|
404
|
-
|
|
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
|
-
#
|
|
407
|
-
|
|
357
|
+
# WASM-powered app
|
|
358
|
+
npx create-baraqex-app my-app --template wasm
|
|
408
359
|
```
|
|
409
360
|
|
|
410
|
-
|
|
361
|
+
---
|
|
411
362
|
|
|
412
|
-
|
|
363
|
+
## ๐บ๏ธ Roadmap
|
|
413
364
|
|
|
414
|
-
|
|
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
|
-
##
|
|
419
|
-
|
|
420
|
-
<div align="center">
|
|
379
|
+
## ๐ License
|
|
421
380
|
|
|
422
|
-
|
|
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
|
-
**
|
|
387
|
+
**[โฌ Back to Top](#baraqex)**
|
|
388
|
+
|
|
389
|
+
Made with โค๏ธ by the Baraqex team
|
|
437
390
|
|
|
438
|
-
|
|
391
|
+
**One Culture, One Framework** | **ุซูุงูุฉ ูุงุญุฏุฉุ ุฅุทุงุฑ ุนู
ู ูุงุญุฏ**
|
|
439
392
|
|
|
440
|
-
|
|
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>
|