baraqex 1.0.45 โ 1.0.47
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/dist/index.js +18 -3
- package/dist/index.js.map +2 -2
- package/dist/server.js +18 -3
- package/dist/server.js.map +2 -2
- package/package.json +1 -1
- package/templates/fullstack-template/package-lock.json +968 -0
- package/templates/fullstack-template/package.json +21 -5
- package/templates/fullstack-template/public/client.js +17 -0
- package/templates/fullstack-template/server.js +39 -11
- package/templates/fullstack-template/src/api/hello.js +11 -9
- package/templates/fullstack-template/src/api/users/index.js +43 -0
- package/templates/fullstack-template/src/pages/index.js +114 -196
- package/templates/wasm/package.json +2 -1
|
@@ -1,14 +1,30 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fullstack-app",
|
|
3
3
|
"version": "1.0.0",
|
|
4
|
+
"description": "A fullstack application built with Baraqex",
|
|
4
5
|
"type": "module",
|
|
6
|
+
"main": "server.js",
|
|
5
7
|
"scripts": {
|
|
6
8
|
"dev": "node server.js",
|
|
7
|
-
"start": "node server.js",
|
|
8
|
-
"build": "echo
|
|
9
|
+
"start": "NODE_ENV=production node server.js",
|
|
10
|
+
"build": "echo 'No build step required for this template'",
|
|
11
|
+
"test": "echo 'No tests specified' && exit 0"
|
|
9
12
|
},
|
|
10
13
|
"dependencies": {
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
-
|
|
14
|
+
"baraqex": "file:../../",
|
|
15
|
+
"express": "^4.18.2",
|
|
16
|
+
"cors": "^2.8.5"
|
|
17
|
+
},
|
|
18
|
+
"devDependencies": {
|
|
19
|
+
"@types/express": "^4.17.17",
|
|
20
|
+
"@types/cors": "^2.8.13"
|
|
21
|
+
},
|
|
22
|
+
"keywords": [
|
|
23
|
+
"baraqex",
|
|
24
|
+
"fullstack",
|
|
25
|
+
"express",
|
|
26
|
+
"api"
|
|
27
|
+
],
|
|
28
|
+
"author": "",
|
|
29
|
+
"license": "MIT"
|
|
14
30
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
|
|
2
|
+
// Auto-generated hydration script
|
|
3
|
+
import { hydrate } from 'frontend-hamroun';
|
|
4
|
+
|
|
5
|
+
// Find SSR content and hydrate it
|
|
6
|
+
document.addEventListener('DOMContentLoaded', () => {
|
|
7
|
+
const ssrRoots = document.querySelectorAll('[data-ssr-root]');
|
|
8
|
+
ssrRoots.forEach(root => {
|
|
9
|
+
const componentPath = root.getAttribute('data-component');
|
|
10
|
+
if (componentPath) {
|
|
11
|
+
import(componentPath).then(module => {
|
|
12
|
+
hydrate(module.default, root);
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
|
|
@@ -1,16 +1,44 @@
|
|
|
1
|
-
import { createDevServer } from 'baraqex
|
|
1
|
+
import { createDevServer } from 'baraqex';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
async function startServer() {
|
|
4
|
+
try {
|
|
5
|
+
console.log('Starting fullstack server...');
|
|
6
|
+
|
|
7
|
+
const server = createDevServer({
|
|
8
|
+
port: process.env.PORT || 3000,
|
|
9
|
+
enableCors: true
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
// Wait for server to start
|
|
13
|
+
await server.start();
|
|
14
|
+
|
|
15
|
+
console.log('โ
Fullstack server is running!');
|
|
16
|
+
console.log('๐ API routes available at /api/*');
|
|
17
|
+
console.log('๐ Pages available at /*');
|
|
18
|
+
console.log('๐ Static files served from /public');
|
|
19
|
+
|
|
20
|
+
} catch (error) {
|
|
21
|
+
console.error('โ Failed to start server:', error.message);
|
|
22
|
+
|
|
23
|
+
// Provide helpful error messages
|
|
24
|
+
if (error.message.includes('Express not installed')) {
|
|
25
|
+
console.error('\n๐ก Quick fix: npm install express @types/express');
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
process.exit(1);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// Handle graceful shutdown
|
|
33
|
+
process.on('SIGINT', () => {
|
|
34
|
+
console.log('\n๐ Shutting down server...');
|
|
35
|
+
process.exit(0);
|
|
6
36
|
});
|
|
7
37
|
|
|
8
|
-
|
|
9
|
-
|
|
38
|
+
process.on('SIGTERM', () => {
|
|
39
|
+
console.log('\n๐ Server terminated');
|
|
40
|
+
process.exit(0);
|
|
41
|
+
});
|
|
10
42
|
|
|
11
43
|
// Start the server
|
|
12
|
-
|
|
13
|
-
console.log('Full-stack server started!');
|
|
14
|
-
console.log('Visit http://localhost:3000');
|
|
15
|
-
console.log('API available at http://localhost:3000/api');
|
|
16
|
-
});
|
|
44
|
+
startServer();
|
|
@@ -1,17 +1,19 @@
|
|
|
1
|
-
export function get(req, res) {
|
|
2
|
-
res.json({
|
|
3
|
-
message: 'Hello from API!',
|
|
1
|
+
export async function get(req, res) {
|
|
2
|
+
res.json({
|
|
3
|
+
message: 'Hello from Baraqex API!',
|
|
4
4
|
timestamp: new Date().toISOString(),
|
|
5
|
-
method: 'GET'
|
|
5
|
+
method: 'GET',
|
|
6
|
+
path: req.path
|
|
6
7
|
});
|
|
7
8
|
}
|
|
8
9
|
|
|
9
|
-
export function post(req, res) {
|
|
10
|
-
const { name } = req.body;
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
export async function post(req, res) {
|
|
11
|
+
const { name = 'World' } = req.body;
|
|
12
|
+
|
|
13
|
+
res.json({
|
|
14
|
+
message: `Hello ${name} from Baraqex API!`,
|
|
13
15
|
timestamp: new Date().toISOString(),
|
|
14
16
|
method: 'POST',
|
|
15
|
-
|
|
17
|
+
body: req.body
|
|
16
18
|
});
|
|
17
19
|
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
// Example API route: /api/users
|
|
2
|
+
|
|
3
|
+
// Mock user data
|
|
4
|
+
const users = [
|
|
5
|
+
{ id: 1, name: 'John Doe', email: 'john@example.com' },
|
|
6
|
+
{ id: 2, name: 'Jane Smith', email: 'jane@example.com' },
|
|
7
|
+
{ id: 3, name: 'Bob Johnson', email: 'bob@example.com' }
|
|
8
|
+
];
|
|
9
|
+
|
|
10
|
+
export async function get(req, res) {
|
|
11
|
+
// GET /api/users - Get all users
|
|
12
|
+
res.json({
|
|
13
|
+
success: true,
|
|
14
|
+
data: users,
|
|
15
|
+
count: users.length
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export async function post(req, res) {
|
|
20
|
+
// POST /api/users - Create a new user
|
|
21
|
+
const { name, email } = req.body;
|
|
22
|
+
|
|
23
|
+
if (!name || !email) {
|
|
24
|
+
return res.status(400).json({
|
|
25
|
+
success: false,
|
|
26
|
+
message: 'Name and email are required'
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const newUser = {
|
|
31
|
+
id: users.length + 1,
|
|
32
|
+
name,
|
|
33
|
+
email
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
users.push(newUser);
|
|
37
|
+
|
|
38
|
+
res.status(201).json({
|
|
39
|
+
success: true,
|
|
40
|
+
message: 'User created successfully',
|
|
41
|
+
data: newUser
|
|
42
|
+
});
|
|
43
|
+
}
|
|
@@ -1,206 +1,124 @@
|
|
|
1
|
-
import { jsx
|
|
1
|
+
import { jsx } from 'baraqex';
|
|
2
2
|
|
|
3
3
|
export default function HomePage(props) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
style: {
|
|
8
|
-
padding: '2rem',
|
|
9
|
-
textAlign: 'center',
|
|
10
|
-
fontFamily: 'system-ui',
|
|
4
|
+
return jsx('div', {
|
|
5
|
+
style: {
|
|
6
|
+
fontFamily: 'Arial, sans-serif',
|
|
11
7
|
maxWidth: '800px',
|
|
12
|
-
margin: '0 auto'
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
jsx('h1', {
|
|
16
|
-
style: {
|
|
17
|
-
color: '#2c3e50',
|
|
18
|
-
marginBottom: '1rem',
|
|
19
|
-
fontSize: '2.5rem'
|
|
20
|
-
}
|
|
21
|
-
}, 'Welcome to Your Baraqex Full-Stack App! ๐'),
|
|
22
|
-
|
|
23
|
-
jsx('div', {
|
|
24
|
-
style: {
|
|
25
|
-
background: '#f8f9fa',
|
|
26
|
-
padding: '2rem',
|
|
27
|
-
borderRadius: '12px',
|
|
28
|
-
margin: '2rem 0',
|
|
29
|
-
border: '1px solid #dee2e6'
|
|
30
|
-
}
|
|
8
|
+
margin: '0 auto',
|
|
9
|
+
padding: '20px',
|
|
10
|
+
lineHeight: '1.6'
|
|
31
11
|
},
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
margin: '0 0 1rem 0'
|
|
38
|
-
}
|
|
39
|
-
}, `Counter: ${count}`),
|
|
12
|
+
children: [
|
|
13
|
+
jsx('h1', {
|
|
14
|
+
style: { color: '#333', textAlign: 'center' },
|
|
15
|
+
children: '๐ Baraqex Fullstack App'
|
|
16
|
+
}),
|
|
40
17
|
|
|
41
|
-
jsx('
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
background: '#007acc',
|
|
48
|
-
color: 'white',
|
|
49
|
-
border: 'none',
|
|
50
|
-
borderRadius: '6px',
|
|
51
|
-
cursor: 'pointer',
|
|
52
|
-
fontSize: '1rem',
|
|
53
|
-
fontWeight: '500',
|
|
54
|
-
transition: 'all 0.2s ease'
|
|
55
|
-
}
|
|
56
|
-
}, 'Increment'),
|
|
57
|
-
jsx('button', {
|
|
58
|
-
onclick: () => setCount(count - 1),
|
|
59
|
-
style: {
|
|
60
|
-
padding: '0.75rem 1.5rem',
|
|
61
|
-
margin: '0.5rem',
|
|
62
|
-
background: '#e74c3c',
|
|
63
|
-
color: 'white',
|
|
64
|
-
border: 'none',
|
|
65
|
-
borderRadius: '6px',
|
|
66
|
-
cursor: 'pointer',
|
|
67
|
-
fontSize: '1rem',
|
|
68
|
-
fontWeight: '500',
|
|
69
|
-
transition: 'all 0.2s ease'
|
|
70
|
-
}
|
|
71
|
-
}, 'Decrement'),
|
|
72
|
-
jsx('button', {
|
|
73
|
-
onclick: () => setCount(0),
|
|
74
|
-
style: {
|
|
75
|
-
padding: '0.75rem 1.5rem',
|
|
76
|
-
margin: '0.5rem',
|
|
77
|
-
background: '#95a5a6',
|
|
78
|
-
color: 'white',
|
|
79
|
-
border: 'none',
|
|
80
|
-
borderRadius: '6px',
|
|
81
|
-
cursor: 'pointer',
|
|
82
|
-
fontSize: '1rem',
|
|
83
|
-
fontWeight: '500',
|
|
84
|
-
transition: 'all 0.2s ease'
|
|
85
|
-
}
|
|
86
|
-
}, 'Reset')
|
|
87
|
-
)
|
|
88
|
-
),
|
|
89
|
-
|
|
90
|
-
jsx('div', {
|
|
91
|
-
style: {
|
|
92
|
-
marginTop: '2rem',
|
|
93
|
-
padding: '1.5rem',
|
|
94
|
-
background: '#e8f5e8',
|
|
95
|
-
borderRadius: '8px',
|
|
96
|
-
border: '1px solid #c3e6c3'
|
|
97
|
-
}
|
|
98
|
-
},
|
|
99
|
-
jsx('h3', {
|
|
100
|
-
style: {
|
|
101
|
-
margin: '0 0 1rem 0',
|
|
102
|
-
color: '#155724'
|
|
103
|
-
}
|
|
104
|
-
}, '๐ฏ Features Included:'),
|
|
105
|
-
jsx('ul', {
|
|
106
|
-
style: {
|
|
107
|
-
textAlign: 'left',
|
|
108
|
-
maxWidth: '500px',
|
|
109
|
-
margin: '0 auto',
|
|
110
|
-
listStyle: 'none',
|
|
111
|
-
padding: 0
|
|
112
|
-
}
|
|
113
|
-
},
|
|
114
|
-
jsx('li', {
|
|
115
|
-
style: {
|
|
116
|
-
padding: '0.5rem 0',
|
|
117
|
-
borderBottom: '1px solid rgba(0,0,0,0.1)'
|
|
118
|
-
}
|
|
119
|
-
}, 'โ
Server-side rendering with ESBuild'),
|
|
120
|
-
jsx('li', {
|
|
121
|
-
style: {
|
|
122
|
-
padding: '0.5rem 0',
|
|
123
|
-
borderBottom: '1px solid rgba(0,0,0,0.1)'
|
|
124
|
-
}
|
|
125
|
-
}, 'โ
API routes in src/api/'),
|
|
126
|
-
jsx('li', {
|
|
127
|
-
style: {
|
|
128
|
-
padding: '0.5rem 0',
|
|
129
|
-
borderBottom: '1px solid rgba(0,0,0,0.1)'
|
|
130
|
-
}
|
|
131
|
-
}, 'โ
Page-based routing'),
|
|
132
|
-
jsx('li', {
|
|
133
|
-
style: {
|
|
134
|
-
padding: '0.5rem 0',
|
|
135
|
-
borderBottom: '1px solid rgba(0,0,0,0.1)'
|
|
136
|
-
}
|
|
137
|
-
}, 'โ
Client-side hydration'),
|
|
138
|
-
jsx('li', {
|
|
139
|
-
style: {
|
|
140
|
-
padding: '0.5rem 0'
|
|
141
|
-
}
|
|
142
|
-
}, 'โ
Frontend Hamroun hooks')
|
|
143
|
-
)
|
|
144
|
-
),
|
|
145
|
-
|
|
146
|
-
jsx('div', {
|
|
147
|
-
style: {
|
|
148
|
-
marginTop: '2rem',
|
|
149
|
-
padding: '1.5rem',
|
|
150
|
-
background: '#fff3cd',
|
|
151
|
-
borderRadius: '8px',
|
|
152
|
-
border: '1px solid #ffeaa7'
|
|
153
|
-
}
|
|
154
|
-
},
|
|
155
|
-
jsx('h3', {
|
|
18
|
+
jsx('p', {
|
|
19
|
+
style: { textAlign: 'center', color: '#666', fontSize: '18px' },
|
|
20
|
+
children: 'Welcome to your fullstack application!'
|
|
21
|
+
}),
|
|
22
|
+
|
|
23
|
+
jsx('div', {
|
|
156
24
|
style: {
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
25
|
+
display: 'grid',
|
|
26
|
+
gap: '20px',
|
|
27
|
+
gridTemplateColumns: 'repeat(auto-fit, minmax(250px, 1fr))',
|
|
28
|
+
marginTop: '30px'
|
|
29
|
+
},
|
|
30
|
+
children: [
|
|
31
|
+
jsx('div', {
|
|
32
|
+
style: {
|
|
33
|
+
border: '1px solid #ddd',
|
|
34
|
+
borderRadius: '8px',
|
|
35
|
+
padding: '20px',
|
|
36
|
+
backgroundColor: '#f9f9f9'
|
|
37
|
+
},
|
|
38
|
+
children: [
|
|
39
|
+
jsx('h3', { children: '๐ก API Routes' }),
|
|
40
|
+
jsx('p', { children: 'Your API endpoints are ready:' }),
|
|
41
|
+
jsx('ul', {
|
|
42
|
+
children: [
|
|
43
|
+
jsx('li', { children: jsx('code', { children: 'GET /api/hello' }) }),
|
|
44
|
+
jsx('li', { children: jsx('code', { children: 'POST /api/hello' }) }),
|
|
45
|
+
jsx('li', { children: jsx('code', { children: 'GET /api/users' }) }),
|
|
46
|
+
jsx('li', { children: jsx('code', { children: 'POST /api/users' }) })
|
|
47
|
+
]
|
|
48
|
+
})
|
|
49
|
+
]
|
|
50
|
+
}),
|
|
51
|
+
|
|
52
|
+
jsx('div', {
|
|
53
|
+
style: {
|
|
54
|
+
border: '1px solid #ddd',
|
|
55
|
+
borderRadius: '8px',
|
|
56
|
+
padding: '20px',
|
|
57
|
+
backgroundColor: '#f9f9f9'
|
|
58
|
+
},
|
|
59
|
+
children: [
|
|
60
|
+
jsx('h3', { children: '๐ Server-Side Rendering' }),
|
|
61
|
+
jsx('p', { children: 'This page is rendered on the server!' }),
|
|
62
|
+
jsx('p', {
|
|
63
|
+
children: `Server time: ${props.api?.serverTime || 'N/A'}`
|
|
64
|
+
})
|
|
65
|
+
]
|
|
66
|
+
}),
|
|
67
|
+
|
|
68
|
+
jsx('div', {
|
|
69
|
+
style: {
|
|
70
|
+
border: '1px solid #ddd',
|
|
71
|
+
borderRadius: '8px',
|
|
72
|
+
padding: '20px',
|
|
73
|
+
backgroundColor: '#f9f9f9'
|
|
74
|
+
},
|
|
75
|
+
children: [
|
|
76
|
+
jsx('h3', { children: '๐ ๏ธ Features' }),
|
|
77
|
+
jsx('ul', {
|
|
78
|
+
children: [
|
|
79
|
+
jsx('li', { children: 'Express.js backend' }),
|
|
80
|
+
jsx('li', { children: 'File-based API routing' }),
|
|
81
|
+
jsx('li', { children: 'Server-side rendering' }),
|
|
82
|
+
jsx('li', { children: 'Static file serving' }),
|
|
83
|
+
jsx('li', { children: 'CORS enabled' })
|
|
84
|
+
]
|
|
85
|
+
})
|
|
86
|
+
]
|
|
87
|
+
})
|
|
88
|
+
]
|
|
89
|
+
}),
|
|
90
|
+
|
|
161
91
|
jsx('div', {
|
|
162
92
|
style: {
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
}, 'API Docs')
|
|
191
|
-
)
|
|
192
|
-
),
|
|
193
|
-
|
|
194
|
-
jsx('p', {
|
|
195
|
-
style: {
|
|
196
|
-
marginTop: '2rem',
|
|
197
|
-
color: '#6c757d',
|
|
198
|
-
fontSize: '0.9rem'
|
|
199
|
-
}
|
|
200
|
-
}, 'Edit src/pages/index.js to customize this page')
|
|
201
|
-
);
|
|
93
|
+
marginTop: '40px',
|
|
94
|
+
textAlign: 'center',
|
|
95
|
+
padding: '20px',
|
|
96
|
+
backgroundColor: '#e3f2fd',
|
|
97
|
+
borderRadius: '8px'
|
|
98
|
+
},
|
|
99
|
+
children: [
|
|
100
|
+
jsx('h3', { children: '๐งช Test Your API' }),
|
|
101
|
+
jsx('p', { children: 'Try these commands in your terminal:' }),
|
|
102
|
+
jsx('pre', {
|
|
103
|
+
style: {
|
|
104
|
+
backgroundColor: '#333',
|
|
105
|
+
color: '#fff',
|
|
106
|
+
padding: '10px',
|
|
107
|
+
borderRadius: '4px',
|
|
108
|
+
textAlign: 'left',
|
|
109
|
+
overflow: 'auto'
|
|
110
|
+
},
|
|
111
|
+
children: `curl http://localhost:3000/api/hello
|
|
112
|
+
curl -X POST http://localhost:3000/api/hello \\
|
|
113
|
+
-H "Content-Type: application/json" \\
|
|
114
|
+
-d '{"name":"Developer"}'`
|
|
115
|
+
})
|
|
116
|
+
]
|
|
117
|
+
})
|
|
118
|
+
]
|
|
119
|
+
});
|
|
202
120
|
}
|
|
203
121
|
|
|
204
|
-
// Optional: Add metadata for
|
|
205
|
-
HomePage.
|
|
206
|
-
HomePage.
|
|
122
|
+
// Optional: Add metadata for the page
|
|
123
|
+
HomePage.getTitle = () => 'Baraqex Fullstack App';
|
|
124
|
+
HomePage.getDescription = () => 'A fullstack application with API routes and server-side rendering';
|