baraqex 1.0.64 → 1.0.65

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 (98) hide show
  1. package/bin/baraqex.js +1013 -1126
  2. package/dist/api/hello.d.ts +3 -0
  3. package/dist/api/hello.d.ts.map +1 -0
  4. package/dist/api/users/[id].d.ts +5 -0
  5. package/dist/api/users/[id].d.ts.map +1 -0
  6. package/dist/browser.d.ts +40 -0
  7. package/dist/browser.d.ts.map +1 -0
  8. package/dist/browser.js +407 -1
  9. package/dist/browser.js.map +4 -4
  10. package/dist/browser.package.json +4 -0
  11. package/dist/forms/index.d.ts +2 -0
  12. package/dist/forms/index.d.ts.map +1 -0
  13. package/dist/forms/types.d.ts +2 -0
  14. package/dist/forms/types.d.ts.map +1 -0
  15. package/dist/frontend/components/WasmLoader.d.ts +2 -0
  16. package/dist/frontend/components/WasmLoader.d.ts.map +1 -0
  17. package/dist/frontend/hooks/useWasm.d.ts +2 -0
  18. package/dist/frontend/hooks/useWasm.d.ts.map +1 -0
  19. package/dist/frontend/index.d.ts +2 -0
  20. package/dist/frontend/index.d.ts.map +1 -0
  21. package/dist/index.d.ts +38 -0
  22. package/dist/index.d.ts.map +1 -0
  23. package/dist/index.js +678 -317
  24. package/dist/index.js.map +4 -4
  25. package/dist/renderComponent.d.ts +9 -0
  26. package/dist/renderComponent.d.ts.map +1 -0
  27. package/dist/router/index.d.ts +2 -0
  28. package/dist/router/index.d.ts.map +1 -0
  29. package/dist/router/types.d.ts +2 -0
  30. package/dist/router/types.d.ts.map +1 -0
  31. package/dist/server/api-router.d.ts +16 -0
  32. package/dist/server/api-router.d.ts.map +1 -0
  33. package/dist/server/auth.d.ts +25 -0
  34. package/dist/server/auth.d.ts.map +1 -0
  35. package/dist/server/database.d.ts +22 -0
  36. package/dist/server/database.d.ts.map +1 -0
  37. package/dist/server/index.d.ts +116 -0
  38. package/dist/server/index.d.ts.map +1 -0
  39. package/dist/{server.js → server/index.js} +120 -23
  40. package/dist/server/index.js.map +7 -0
  41. package/dist/server/middleware.d.ts +11 -0
  42. package/dist/server/middleware.d.ts.map +1 -0
  43. package/dist/server/package.json +4 -0
  44. package/dist/server/templates.d.ts +31 -0
  45. package/dist/server/templates.d.ts.map +1 -0
  46. package/dist/server/types.d.ts +69 -0
  47. package/dist/server/types.d.ts.map +1 -0
  48. package/dist/server/utils.d.ts +70 -0
  49. package/dist/server/utils.d.ts.map +1 -0
  50. package/dist/server/wasm.d.ts +29 -0
  51. package/dist/server/wasm.d.ts.map +1 -0
  52. package/dist/server-renderer.d.ts +5 -0
  53. package/dist/server-renderer.d.ts.map +1 -0
  54. package/dist/store/index.d.ts +2 -0
  55. package/dist/store/index.d.ts.map +1 -0
  56. package/dist/store/types.d.ts +2 -0
  57. package/dist/store/types.d.ts.map +1 -0
  58. package/dist/wasm.d.ts +51 -0
  59. package/dist/wasm.d.ts.map +1 -0
  60. package/package.json +65 -56
  61. package/templates/basic-app/src/main.tsx +1 -0
  62. package/templates/fullstack-template/.env.example +42 -0
  63. package/templates/fullstack-template/README.md +38 -42
  64. package/templates/fullstack-template/package-lock.json +7932 -0
  65. package/templates/fullstack-template/package.json +58 -6
  66. package/templates/fullstack-template/server.js +28 -9
  67. package/templates/fullstack-template/src/App.tsx +94 -0
  68. package/templates/fullstack-template/src/api/auth/login.ts +75 -0
  69. package/templates/fullstack-template/src/api/auth/me.ts +66 -0
  70. package/templates/fullstack-template/src/api/auth/register.ts +59 -0
  71. package/templates/fullstack-template/src/api/todos/[id].ts +108 -0
  72. package/templates/fullstack-template/src/api/todos/index.ts +79 -0
  73. package/templates/fullstack-template/src/components/Dashboard.tsx +129 -0
  74. package/templates/fullstack-template/src/components/Header.tsx +76 -0
  75. package/templates/fullstack-template/src/contexts/ApiContext.tsx +69 -0
  76. package/templates/fullstack-template/src/contexts/AuthContext.tsx +155 -0
  77. package/templates/fullstack-template/src/server.ts +167 -0
  78. package/templates/fullstack-template/src/styles/App.css +446 -0
  79. package/templates/ssr-template/package-lock.json +38 -60
  80. package/templates/ssr-template/package.json +1 -1
  81. package/templates/ssr-template/src/App.tsx +4 -3
  82. package/templates/ssr-template/src/client.tsx +2 -1
  83. package/templates/wasm/App.tsx +564 -0
  84. package/templates/wasm/client.tsx +220 -0
  85. package/templates/wasm/index.tsx +21 -0
  86. package/templates/wasm/package-lock.json +5347 -5307
  87. package/templates/wasm/package.json +43 -25
  88. package/templates/wasm/public/example.wasm +0 -0
  89. package/templates/wasm/public/wasm_exec.js +1 -12
  90. package/templates/wasm/server.ts +145 -0
  91. package/templates/wasm/vite.config.ts +42 -24
  92. package/README_WASM.md +0 -472
  93. package/dist/server.js.map +0 -7
  94. package/templates/basic-app/src/App.jsx +0 -0
  95. package/templates/basic-app/src/App.tsx +0 -0
  96. package/templates/fullstack-template/src/api/hello.js +0 -17
  97. package/templates/fullstack-template/src/pages/index.js +0 -206
  98. /package/templates/{basic-app/server.js → wasm/go/wasm_exec.js} +0 -0
package/package.json CHANGED
@@ -1,56 +1,81 @@
1
1
  {
2
2
  "name": "baraqex",
3
- "version": "1.0.64",
4
- "description": "A powerful server-side framework built on Frontend Hamroun",
3
+ "version": "1.0.65",
4
+ "description": "A powerful full-stack framework for modern web development",
5
+ "main": "dist/index.js",
6
+ "module": "dist/index.js",
7
+ "types": "dist/index.d.ts",
5
8
  "type": "module",
6
- "main": "./dist/index.js",
7
- "types": "./dist/index.d.ts",
8
9
  "exports": {
9
10
  ".": {
10
- "types": "./dist/index.d.ts",
11
- "import": "./dist/index.js"
11
+ "browser": "./dist/browser.js",
12
+ "import": "./dist/index.js",
13
+ "require": "./dist/index.cjs",
14
+ "types": "./dist/index.d.ts"
12
15
  },
13
16
  "./browser": {
14
- "types": "./dist/browser.d.ts",
15
- "import": "./dist/browser.js"
17
+ "import": "./dist/browser.js",
18
+ "types": "./dist/browser.d.ts"
16
19
  },
17
20
  "./server": {
18
- "types": "./dist/server.d.ts",
19
- "import": "./dist/server.js"
20
- },
21
- "./wasm": {
22
- "types": "./dist/wasm.d.ts",
23
- "import": "./dist/wasm.js"
21
+ "import": "./dist/server.js",
22
+ "types": "./dist/server.d.ts"
24
23
  }
25
24
  },
25
+ "browser": {
26
+ "./dist/index.js": "./dist/browser.js",
27
+ "crypto": false,
28
+ "fs": false,
29
+ "path": false,
30
+ "http": false,
31
+ "https": false,
32
+ "express": false,
33
+ "cors": false,
34
+ "mongodb": false,
35
+ "mysql2": false,
36
+ "pg": false,
37
+ "bcryptjs": false,
38
+ "jsonwebtoken": false
39
+ },
26
40
  "files": [
27
41
  "dist/",
28
42
  "templates/",
29
43
  "bin/",
30
- "README.md",
31
- "README_WASM.md"
44
+ "README.md"
32
45
  ],
33
46
  "bin": {
34
47
  "baraqex": "./bin/baraqex.js"
35
48
  },
36
49
  "scripts": {
37
- "build": "npm run clean && npm run build:types && npm run build:js",
38
- "build:types": "tsc --declaration --emitDeclarationOnly --outDir dist",
39
- "build:js": "node build.js",
50
+ "build": "npm run clean && npm run build:esm",
51
+ "build:types": "tsc --emitDeclarationOnly",
52
+ "build:esm": "node build.mjs",
40
53
  "clean": "rimraf dist",
41
- "dev": "npm run build && node dev-server.js",
42
54
  "test": "jest",
43
- "test:watch": "jest --watch",
44
- "lint": "eslint src/**/*.ts",
45
- "lint:fix": "eslint src/**/*.ts --fix",
46
- "prepare": "npm run build"
55
+ "dev": "tsc --watch",
56
+ "prepublishOnly": "npm run build"
47
57
  },
58
+ "keywords": [
59
+ "framework",
60
+ "frontend",
61
+ "backend",
62
+ "fullstack",
63
+ "react",
64
+ "ssr",
65
+ "wasm",
66
+ "go"
67
+ ],
68
+ "author": "Mohamed X",
69
+ "license": "MIT",
48
70
  "dependencies": {
49
- "frontend-hamroun": "^1.2.35"
71
+ "chokidar": "^4.0.3",
72
+ "frontend-hamroun": "^1.2.35",
73
+ "open": "^10.1.2",
74
+ "ws": "^8.18.2"
50
75
  },
51
76
  "peerDependencies": {
52
- "express": ">=4.18.0",
53
- "cors": ">=2.8.0"
77
+ "cors": "^2.8.5",
78
+ "express": "^4.18.0"
54
79
  },
55
80
  "peerDependenciesMeta": {
56
81
  "express": {
@@ -76,39 +101,23 @@
76
101
  }
77
102
  },
78
103
  "devDependencies": {
104
+ "@types/bcryptjs": "^2.4.6",
105
+ "@types/cors": "^2.8.18",
106
+ "@types/express": "^5.0.2",
79
107
  "@types/node": "^20.0.0",
80
- "@types/express": "^4.17.0",
81
- "@types/cors": "^2.8.0",
82
- "@types/bcryptjs": "^2.4.0",
83
- "@types/jsonwebtoken": "^9.0.0",
84
- "@typescript-eslint/eslint-plugin": "^6.0.0",
85
- "@typescript-eslint/parser": "^6.0.0",
108
+ "@types/pg": "^8.15.4",
86
109
  "esbuild": "^0.19.0",
87
- "eslint": "^8.0.0",
88
110
  "jest": "^29.0.0",
89
111
  "rimraf": "^5.0.0",
90
112
  "typescript": "^5.0.0"
91
113
  },
92
- "keywords": [
93
- "frontend-hamroun",
94
- "server",
95
- "framework",
96
- "ssr",
97
- "fullstack",
98
- "webassembly",
99
- "wasm",
100
- "api",
101
- "database",
102
- "auth"
103
- ],
104
- "author": "Your Name",
105
- "license": "MIT",
106
- "repository": {
107
- "type": "git",
108
- "url": "https://github.com/mohamedx2/baraqex.git"
109
- },
110
- "bugs": {
111
- "url": "https://github.com/mohamedx2/baraqex/issues"
112
- },
113
- "homepage": "https://github.com/mohamedx2/baraqex#readme"
114
+ "optionalDependencies": {
115
+ "bcryptjs": "^2.4.3",
116
+ "cors": "^2.8.5",
117
+ "express": "^4.18.0",
118
+ "jsonwebtoken": "^9.0.0",
119
+ "mongodb": "^6.0.0",
120
+ "mysql2": "^3.6.0",
121
+ "pg": "^8.11.0"
122
+ }
114
123
  }
@@ -3,6 +3,7 @@ import './main.css';
3
3
 
4
4
  // JSX type declarations
5
5
  declare global {
6
+ // eslint-disable-next-line @typescript-eslint/no-namespace
6
7
  namespace JSX {
7
8
  interface IntrinsicElements {
8
9
  [elemName: string]: any;
@@ -0,0 +1,42 @@
1
+ # Server Configuration
2
+ PORT=3000
3
+ NODE_ENV=development
4
+
5
+ # Authentication
6
+ JWT_SECRET=your-super-secret-jwt-key-change-in-production
7
+ JWT_EXPIRES_IN=7d
8
+
9
+ # Database Configuration (optional)
10
+ # DATABASE_URL=mongodb://localhost:27017/fullstack_app
11
+ # DATABASE_TYPE=mongodb
12
+
13
+ # For PostgreSQL:
14
+ # DATABASE_URL=postgresql://username:password@localhost:5432/fullstack_app
15
+ # DATABASE_TYPE=postgres
16
+
17
+ # For MySQL:
18
+ # DATABASE_URL=mysql://username:password@localhost:3306/fullstack_app
19
+ # DATABASE_TYPE=mysql
20
+
21
+ # Frontend URL (for CORS in production)
22
+ FRONTEND_URL=http://localhost:3000
23
+
24
+ # Session Configuration
25
+ SESSION_SECRET=your-session-secret-key
26
+
27
+ # Email Configuration (for future features)
28
+ # SMTP_HOST=smtp.gmail.com
29
+ # SMTP_PORT=587
30
+ # SMTP_USER=your-email@gmail.com
31
+ # SMTP_PASS=your-app-password
32
+
33
+ # File Upload Configuration
34
+ MAX_FILE_SIZE=5MB
35
+ UPLOAD_DIR=uploads
36
+
37
+ # Redis Configuration (for caching/sessions)
38
+ # REDIS_URL=redis://localhost:6379
39
+
40
+ # API Rate Limiting
41
+ RATE_LIMIT_WINDOW_MS=900000
42
+ RATE_LIMIT_MAX_REQUESTS=100
@@ -1,56 +1,52 @@
1
- # Full-Stack Frontend Hamroun App
1
+ # Fullstack Baraqex Application
2
2
 
3
- A complete full-stack application with API routes and SSR.
3
+ A complete fullstack application template built with the Baraqex framework, featuring authentication, API integration, and modern development practices.
4
4
 
5
- ## Features
5
+ ## 🚀 Features
6
6
 
7
- - ✅ Server-side rendering with hydration
8
- - ✅ API routes in `src/api/`
9
- - ✅ Page-based routing in `src/pages/`
10
- - ✅ Frontend Hamroun hooks support
11
- - ✅ Express.js backend
12
- - ✅ Static file serving
7
+ - **Full-Stack Architecture**: Complete frontend and backend integration
8
+ - **Authentication System**: JWT-based auth with login/register
9
+ - **RESTful API**: Well-structured API endpoints with middleware
10
+ - **Database Support**: MongoDB, MySQL, and PostgreSQL options
11
+ - **Real-time Updates**: Modern state management
12
+ - **Security**: Built-in security headers, rate limiting, CORS
13
+ - **Developer Experience**: Hot reload, TypeScript, ESLint, Prettier
14
+ - **Production Ready**: Environment configuration, logging, error handling
13
15
 
14
- ## Getting Started
16
+ ## 📋 Prerequisites
15
17
 
16
- ```bash
17
- npm install
18
- npm run dev
19
- ```
18
+ - Node.js 16+
19
+ - npm, yarn, or pnpm
20
+ - Database (optional - works with in-memory storage for demo)
20
21
 
21
- ## Project Structure
22
+ ## 🛠️ Quick Start
22
23
 
23
- ```
24
- src/
25
- ├── pages/ # Page components (SSR)
26
- │ └── index.js # Homepage
27
- └── api/ # API routes
28
- └── hello.js # Example API endpoint
29
- ```
24
+ 1. **Install dependencies**
25
+ ```bash
26
+ npm install
27
+ ```
30
28
 
31
- ## Available Endpoints
29
+ 2. **Environment setup**
30
+ ```bash
31
+ cp .env.example .env
32
+ # Edit .env with your configuration
33
+ ```
32
34
 
33
- - **Homepage**: http://localhost:3000
34
- - **API Hello**: http://localhost:3000/api/hello
35
+ 3. **Start development server**
36
+ ```bash
37
+ npm run dev
38
+ ```
35
39
 
36
- ## Adding Pages
40
+ 4. **Open your browser**
41
+ - Frontend: http://localhost:3000
42
+ - API: http://localhost:3000/api
43
+ - API Docs: http://localhost:3000/api-docs
37
44
 
38
- Create new files in `src/pages/`:
39
- - `src/pages/about.js` → `/about`
40
- - `src/pages/contact.js` → `/contact`
41
- - `src/pages/blog/index.js` → `/blog`
45
+ ## 🎯 Default Credentials
42
46
 
43
- ## Adding API Routes
47
+ For demo purposes, you can login with:
48
+ - **Username**: `admin` or `user`
49
+ - **Password**: `password`
44
50
 
45
- Create new files in `src/api/`:
46
- - `src/api/users.js` → `/api/users`
47
- - `src/api/posts/index.js` → `/api/posts`
48
- - `src/api/posts/[id].js` → `/api/posts/:id`
51
+ ## 📁 Project Structure
49
52
 
50
- Each API file should export functions named after HTTP methods:
51
- ```javascript
52
- export function get(req, res) { /* ... */ }
53
- export function post(req, res) { /* ... */ }
54
- export function put(req, res) { /* ... */ }
55
- export function delete(req, res) { /* ... */ }
56
- ```