create-aziz-app 2.0.14 → 3.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/README.md +227 -0
- package/bin/create-aziz-app.js +9 -9
- package/package.json +10 -11
- package/template/README.md +862 -138
- package/template/_framework/boot.js +36 -0
- package/template/_framework/hooks.js +207 -0
- package/template/{modules → _framework}/next-response.js +5 -13
- package/template/_framework/router.js +279 -0
- package/template/_framework/runtime.js +86 -0
- package/template/api/createUser.js +1 -1
- package/template/api/hello.js +8 -17
- package/template/api/loginUser.js +1 -1
- package/template/api/users.js +38 -134
- package/template/app/about/page.js +45 -0
- package/template/app/layout.js +23 -0
- package/template/app/page.js +54 -0
- package/template/app/test/page.js +55 -0
- package/template/components/Footer.js +10 -0
- package/template/components/Navbar.js +30 -0
- package/template/index.html +24 -0
- package/template/package.json +5 -14
- package/template/scripts/dev-server.js +330 -302
- package/template/scripts/live-reload-client.js +0 -1
- package/template/.vscode/settings.json +0 -15
- package/template/api/getUser.js +0 -60
- package/template/api/getUserWithDB.js +0 -65
- package/template/app.config.js +0 -41
- package/template/app.html +0 -55
- package/template/components/Counter.jsx +0 -36
- package/template/components/Footer.jsx +0 -9
- package/template/components/Navbar.jsx +0 -17
- package/template/docs/API-GUIDE.md +0 -196
- package/template/docs/API-ROUTES.md +0 -538
- package/template/docs/AUTO-IMPORT.md +0 -99
- package/template/docs/AUTO-REGISTRATION.md +0 -248
- package/template/docs/CSS-FRAMEWORKS.md +0 -221
- package/template/docs/DEV-SERVER.md +0 -184
- package/template/docs/GETTING-STARTED.md +0 -205
- package/template/docs/HOW-IT-WORKS.md +0 -362
- package/template/docs/NEXTJS-APP-ROUTER.md +0 -536
- package/template/docs/NEXTJS-COMPARISON.md +0 -473
- package/template/docs/QUICK-START.md +0 -111
- package/template/docs/STYLING.md +0 -269
- package/template/docs/TROUBLESHOOTING.md +0 -282
- package/template/modules/README.md +0 -129
- package/template/modules/api.js +0 -44
- package/template/modules/auto-import.js +0 -130
- package/template/modules/router.js +0 -218
- package/template/modules/state.js +0 -248
- package/template/package-lock.json +0 -13
- package/template/pages/About.jsx +0 -48
- package/template/pages/ApiDemo.jsx +0 -209
- package/template/pages/Contact.jsx +0 -25
- package/template/pages/Example.jsx +0 -59
- package/template/pages/Home.jsx +0 -39
- package/template/pages/HooksDemo.jsx +0 -194
- package/template/pages/test.jsx +0 -72
- package/template/scripts/build.js +0 -81
- package/template/scripts/generate-imports.js +0 -88
- package/template/tailwind.config.js +0 -17
|
@@ -1,248 +0,0 @@
|
|
|
1
|
-
# Auto-Registration Guide
|
|
2
|
-
|
|
3
|
-
## Overview
|
|
4
|
-
|
|
5
|
-
Pages automatically register themselves based on their function name. No need to call `registerPage()` manually!
|
|
6
|
-
|
|
7
|
-
## How It Works
|
|
8
|
-
|
|
9
|
-
### ✨ Automatic Registration
|
|
10
|
-
|
|
11
|
-
Just name your page function with "Page" at the end:
|
|
12
|
-
|
|
13
|
-
```jsx
|
|
14
|
-
/** @jsx h */
|
|
15
|
-
|
|
16
|
-
// That's it! Automatically becomes route "#/example"
|
|
17
|
-
function ExamplePage() {
|
|
18
|
-
return (
|
|
19
|
-
<div>
|
|
20
|
-
<h1>Example Page</h1>
|
|
21
|
-
<p>This page auto-registered!</p>
|
|
22
|
-
</div>
|
|
23
|
-
);
|
|
24
|
-
}
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
### Function Name → Route Mapping
|
|
28
|
-
|
|
29
|
-
The system converts your function name to a route:
|
|
30
|
-
|
|
31
|
-
| Function Name | Auto Route | URL |
|
|
32
|
-
|--------------|------------|-----|
|
|
33
|
-
| `HomePage()` | `home` | `#/home` |
|
|
34
|
-
| `AboutPage()` | `about` | `#/about` |
|
|
35
|
-
| `ContactPage()` | `contact` | `#/contact` |
|
|
36
|
-
| `UserProfilePage()` | `userprofile` | `#/userprofile` |
|
|
37
|
-
| `MyAwesomePage()` | `myawesome` | `#/myawesome` |
|
|
38
|
-
|
|
39
|
-
**Rule:** Remove "Page" suffix and convert to lowercase.
|
|
40
|
-
|
|
41
|
-
## Manual Registration (Optional)
|
|
42
|
-
|
|
43
|
-
You can still manually register for custom route names:
|
|
44
|
-
|
|
45
|
-
```jsx
|
|
46
|
-
/** @jsx h */
|
|
47
|
-
|
|
48
|
-
// Custom route name with dashes or different naming
|
|
49
|
-
registerPage("user-profile", UserProfilePage);
|
|
50
|
-
|
|
51
|
-
function UserProfilePage() {
|
|
52
|
-
return <div><h1>User Profile</h1></div>;
|
|
53
|
-
}
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
### When to Use Manual Registration
|
|
57
|
-
|
|
58
|
-
- **Custom route names** with dashes: `"api-demo"`, `"user-settings"`
|
|
59
|
-
- **Multiple routes** pointing to same component
|
|
60
|
-
- **Override auto-registration** with different name
|
|
61
|
-
|
|
62
|
-
## Examples
|
|
63
|
-
|
|
64
|
-
### Example 1: Simple Auto Page
|
|
65
|
-
|
|
66
|
-
```jsx
|
|
67
|
-
/** @jsx h */
|
|
68
|
-
|
|
69
|
-
function ProductsPage() {
|
|
70
|
-
return (
|
|
71
|
-
<div>
|
|
72
|
-
<h1>Products</h1>
|
|
73
|
-
<p>Browse our products</p>
|
|
74
|
-
</div>
|
|
75
|
-
);
|
|
76
|
-
}
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
Access at: `#/products`
|
|
80
|
-
|
|
81
|
-
### Example 2: With State
|
|
82
|
-
|
|
83
|
-
```jsx
|
|
84
|
-
/** @jsx h */
|
|
85
|
-
|
|
86
|
-
function DashboardPage() {
|
|
87
|
-
const [count, setCount] = useState(0);
|
|
88
|
-
|
|
89
|
-
return (
|
|
90
|
-
<div>
|
|
91
|
-
<h1>Dashboard</h1>
|
|
92
|
-
<p>Count: {count}</p>
|
|
93
|
-
<button onClick={() => setCount(count + 1)}>
|
|
94
|
-
Increment
|
|
95
|
-
</button>
|
|
96
|
-
</div>
|
|
97
|
-
);
|
|
98
|
-
}
|
|
99
|
-
```
|
|
100
|
-
|
|
101
|
-
Access at: `#/dashboard`
|
|
102
|
-
|
|
103
|
-
### Example 3: Manual Registration
|
|
104
|
-
|
|
105
|
-
```jsx
|
|
106
|
-
/** @jsx h */
|
|
107
|
-
|
|
108
|
-
// Want route "#/user-settings" instead of "#/usersettings"
|
|
109
|
-
registerPage("user-settings", UserSettingsPage);
|
|
110
|
-
|
|
111
|
-
function UserSettingsPage() {
|
|
112
|
-
return (
|
|
113
|
-
<div>
|
|
114
|
-
<h1>User Settings</h1>
|
|
115
|
-
</div>
|
|
116
|
-
);
|
|
117
|
-
}
|
|
118
|
-
```
|
|
119
|
-
|
|
120
|
-
Access at: `#/user-settings`
|
|
121
|
-
|
|
122
|
-
## Creating a New Page
|
|
123
|
-
|
|
124
|
-
### Step 1: Create the file
|
|
125
|
-
|
|
126
|
-
Create `pages/MyNewPage.jsx`:
|
|
127
|
-
|
|
128
|
-
```jsx
|
|
129
|
-
/** @jsx h */
|
|
130
|
-
|
|
131
|
-
function MyNewPage() {
|
|
132
|
-
return (
|
|
133
|
-
<div>
|
|
134
|
-
<h1>My New Page</h1>
|
|
135
|
-
<div class="card">
|
|
136
|
-
<p>This is my new page!</p>
|
|
137
|
-
</div>
|
|
138
|
-
</div>
|
|
139
|
-
);
|
|
140
|
-
}
|
|
141
|
-
```
|
|
142
|
-
|
|
143
|
-
### Step 2: That's it!
|
|
144
|
-
|
|
145
|
-
The dev server will:
|
|
146
|
-
1. Detect the new file
|
|
147
|
-
2. Auto-generate the import in `app.html`
|
|
148
|
-
3. Auto-register the route as `#/mynew`
|
|
149
|
-
4. Reload the browser
|
|
150
|
-
|
|
151
|
-
Navigate to `#/mynew` and your page appears!
|
|
152
|
-
|
|
153
|
-
## Debugging
|
|
154
|
-
|
|
155
|
-
### Check Auto-Registration
|
|
156
|
-
|
|
157
|
-
Open browser console when the app starts. You'll see:
|
|
158
|
-
|
|
159
|
-
```
|
|
160
|
-
📄 Auto-registered: home → HomePage()
|
|
161
|
-
📄 Auto-registered: about → AboutPage()
|
|
162
|
-
📄 Auto-registered: contact → ContactPage()
|
|
163
|
-
📄 Auto-registered: mynew → MyNewPage()
|
|
164
|
-
```
|
|
165
|
-
|
|
166
|
-
### Page Not Found?
|
|
167
|
-
|
|
168
|
-
1. **Check function name** - Must end with "Page"
|
|
169
|
-
2. **Check file is loaded** - Look in `app.html` for the script tag
|
|
170
|
-
3. **Check console** - Look for auto-registration message
|
|
171
|
-
4. **Try manual registration** - Use `registerPage("route", ComponentPage)`
|
|
172
|
-
|
|
173
|
-
## Best Practices
|
|
174
|
-
|
|
175
|
-
### ✅ Do This
|
|
176
|
-
|
|
177
|
-
```jsx
|
|
178
|
-
// Clear, descriptive names
|
|
179
|
-
function HomePage() { }
|
|
180
|
-
function AboutPage() { }
|
|
181
|
-
function ContactPage() { }
|
|
182
|
-
function UserProfilePage() { }
|
|
183
|
-
```
|
|
184
|
-
|
|
185
|
-
### ❌ Avoid This
|
|
186
|
-
|
|
187
|
-
```jsx
|
|
188
|
-
// Won't auto-register (missing "Page" suffix)
|
|
189
|
-
function Home() { }
|
|
190
|
-
function About() { }
|
|
191
|
-
|
|
192
|
-
// Will create weird routes
|
|
193
|
-
function Page() { } // route: "" (empty)
|
|
194
|
-
function MyPage() { } // route: "my" (too generic)
|
|
195
|
-
```
|
|
196
|
-
|
|
197
|
-
## Migration Guide
|
|
198
|
-
|
|
199
|
-
### Old Way (Still Works)
|
|
200
|
-
|
|
201
|
-
```jsx
|
|
202
|
-
/** @jsx h */
|
|
203
|
-
|
|
204
|
-
registerPage("about", AboutPage);
|
|
205
|
-
|
|
206
|
-
function AboutPage() {
|
|
207
|
-
return <div><h1>About</h1></div>;
|
|
208
|
-
}
|
|
209
|
-
```
|
|
210
|
-
|
|
211
|
-
### New Way (Simpler)
|
|
212
|
-
|
|
213
|
-
```jsx
|
|
214
|
-
/** @jsx h */
|
|
215
|
-
|
|
216
|
-
function AboutPage() {
|
|
217
|
-
return <div><h1>About</h1></div>;
|
|
218
|
-
}
|
|
219
|
-
```
|
|
220
|
-
|
|
221
|
-
Both work! The new way is just less code.
|
|
222
|
-
|
|
223
|
-
## Advanced: Multiple Routes
|
|
224
|
-
|
|
225
|
-
Point multiple routes to the same component:
|
|
226
|
-
|
|
227
|
-
```jsx
|
|
228
|
-
/** @jsx h */
|
|
229
|
-
|
|
230
|
-
// Auto-registers as "dashboard"
|
|
231
|
-
function DashboardPage() {
|
|
232
|
-
return <div><h1>Dashboard</h1></div>;
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
// Also register as "home" and "index"
|
|
236
|
-
registerPage("home", DashboardPage);
|
|
237
|
-
registerPage("index", DashboardPage);
|
|
238
|
-
```
|
|
239
|
-
|
|
240
|
-
Now `#/dashboard`, `#/home`, and `#/index` all show the same page!
|
|
241
|
-
|
|
242
|
-
## Summary
|
|
243
|
-
|
|
244
|
-
- **Function name ends with "Page"** → Auto-registers
|
|
245
|
-
- **Route name** = function name without "Page", lowercase
|
|
246
|
-
- **Manual registration** still available for custom names
|
|
247
|
-
- **Dev server** handles everything automatically
|
|
248
|
-
- **Zero configuration** needed for basic pages
|
|
@@ -1,221 +0,0 @@
|
|
|
1
|
-
# CSS Frameworks Guide
|
|
2
|
-
|
|
3
|
-
## Overview
|
|
4
|
-
|
|
5
|
-
Aziz App supports three CSS options:
|
|
6
|
-
1. **Custom CSS** - Built-in custom styles
|
|
7
|
-
2. **Bootstrap 5** - Popular component framework
|
|
8
|
-
3. **Tailwind CSS** - Utility-first framework
|
|
9
|
-
|
|
10
|
-
## Bootstrap 5
|
|
11
|
-
|
|
12
|
-
### What's Included
|
|
13
|
-
|
|
14
|
-
When you choose Bootstrap, the CLI automatically adds:
|
|
15
|
-
- Bootstrap 5.3.2 CSS (CDN)
|
|
16
|
-
- Bootstrap Icons
|
|
17
|
-
- Bootstrap 5 JS Bundle
|
|
18
|
-
- Updated Navbar with Bootstrap classes
|
|
19
|
-
- Updated Footer with Bootstrap classes
|
|
20
|
-
|
|
21
|
-
### Using Bootstrap
|
|
22
|
-
|
|
23
|
-
```javascript
|
|
24
|
-
// Example: Bootstrap Button
|
|
25
|
-
<button class="btn btn-primary">Click Me</button>
|
|
26
|
-
|
|
27
|
-
// Example: Bootstrap Card
|
|
28
|
-
<div class="card">
|
|
29
|
-
<div class="card-body">
|
|
30
|
-
<h5 class="card-title">Card Title</h5>
|
|
31
|
-
<p class="card-text">Some content</p>
|
|
32
|
-
</div>
|
|
33
|
-
</div>
|
|
34
|
-
|
|
35
|
-
// Example: Bootstrap Grid
|
|
36
|
-
<div class="container">
|
|
37
|
-
<div class="row">
|
|
38
|
-
<div class="col-md-6">Column 1</div>
|
|
39
|
-
<div class="col-md-6">Column 2</div>
|
|
40
|
-
</div>
|
|
41
|
-
</div>
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
### Bootstrap Components
|
|
45
|
-
|
|
46
|
-
Available components:
|
|
47
|
-
- Buttons, Cards, Modals
|
|
48
|
-
- Forms, Inputs, Validation
|
|
49
|
-
- Navbar, Dropdowns, Tabs
|
|
50
|
-
- Alerts, Badges, Progress bars
|
|
51
|
-
- Grid system, Flexbox utilities
|
|
52
|
-
|
|
53
|
-
### Resources
|
|
54
|
-
|
|
55
|
-
- [Bootstrap Docs](https://getbootstrap.com/docs/5.3/)
|
|
56
|
-
- [Bootstrap Icons](https://icons.getbootstrap.com/)
|
|
57
|
-
- [Bootstrap Examples](https://getbootstrap.com/docs/5.3/examples/)
|
|
58
|
-
|
|
59
|
-
## Tailwind CSS
|
|
60
|
-
|
|
61
|
-
### What's Included
|
|
62
|
-
|
|
63
|
-
When you choose Tailwind, the CLI automatically adds:
|
|
64
|
-
- Tailwind CSS CDN (Play CDN)
|
|
65
|
-
- Custom color configuration
|
|
66
|
-
- Updated Navbar with Tailwind classes
|
|
67
|
-
- Updated Footer with Tailwind classes
|
|
68
|
-
|
|
69
|
-
### Using Tailwind
|
|
70
|
-
|
|
71
|
-
```javascript
|
|
72
|
-
// Example: Tailwind Button
|
|
73
|
-
<button class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded">
|
|
74
|
-
Click Me
|
|
75
|
-
</button>
|
|
76
|
-
|
|
77
|
-
// Example: Tailwind Card
|
|
78
|
-
<div class="bg-white shadow-lg rounded-lg p-6">
|
|
79
|
-
<h2 class="text-2xl font-bold mb-4">Card Title</h2>
|
|
80
|
-
<p class="text-gray-700">Some content</p>
|
|
81
|
-
</div>
|
|
82
|
-
|
|
83
|
-
// Example: Tailwind Grid
|
|
84
|
-
<div class="container mx-auto">
|
|
85
|
-
<div class="grid grid-cols-2 gap-4">
|
|
86
|
-
<div>Column 1</div>
|
|
87
|
-
<div>Column 2</div>
|
|
88
|
-
</div>
|
|
89
|
-
</div>
|
|
90
|
-
```
|
|
91
|
-
|
|
92
|
-
### Tailwind Utilities
|
|
93
|
-
|
|
94
|
-
Common utilities:
|
|
95
|
-
- Layout: `flex`, `grid`, `container`
|
|
96
|
-
- Spacing: `p-4`, `m-2`, `space-x-4`
|
|
97
|
-
- Colors: `bg-blue-500`, `text-red-600`
|
|
98
|
-
- Typography: `text-xl`, `font-bold`
|
|
99
|
-
- Effects: `shadow-lg`, `rounded-lg`
|
|
100
|
-
|
|
101
|
-
### Custom Colors
|
|
102
|
-
|
|
103
|
-
Pre-configured colors:
|
|
104
|
-
- `primary` - #61dafb (Aziz blue)
|
|
105
|
-
- `dark` - #282c34 (Dark background)
|
|
106
|
-
|
|
107
|
-
```javascript
|
|
108
|
-
<div class="bg-primary text-dark">Custom colors!</div>
|
|
109
|
-
```
|
|
110
|
-
|
|
111
|
-
### Resources
|
|
112
|
-
|
|
113
|
-
- [Tailwind Docs](https://tailwindcss.com/docs)
|
|
114
|
-
- [Tailwind Cheat Sheet](https://nerdcave.com/tailwind-cheat-sheet)
|
|
115
|
-
- [Tailwind Components](https://tailwindui.com/components)
|
|
116
|
-
|
|
117
|
-
## Custom CSS
|
|
118
|
-
|
|
119
|
-
### What's Included
|
|
120
|
-
|
|
121
|
-
The default custom CSS includes:
|
|
122
|
-
- Reset styles
|
|
123
|
-
- Navbar and Footer styles
|
|
124
|
-
- Card, Button, Form styles
|
|
125
|
-
- Utility classes
|
|
126
|
-
- Responsive design
|
|
127
|
-
|
|
128
|
-
### Using Custom CSS
|
|
129
|
-
|
|
130
|
-
```javascript
|
|
131
|
-
// Example: Custom Button
|
|
132
|
-
<button class="btn btn-primary">Click Me</button>
|
|
133
|
-
|
|
134
|
-
// Example: Custom Card
|
|
135
|
-
<div class="card">
|
|
136
|
-
<h2>Card Title</h2>
|
|
137
|
-
<p>Some content</p>
|
|
138
|
-
</div>
|
|
139
|
-
|
|
140
|
-
// Example: Custom Form
|
|
141
|
-
<form>
|
|
142
|
-
<input type="text" placeholder="Enter text" />
|
|
143
|
-
<button class="btn btn-primary">Submit</button>
|
|
144
|
-
</form>
|
|
145
|
-
```
|
|
146
|
-
|
|
147
|
-
### Available Classes
|
|
148
|
-
|
|
149
|
-
**Buttons:**
|
|
150
|
-
- `.btn` - Base button
|
|
151
|
-
- `.btn-primary` - Primary button (blue)
|
|
152
|
-
- `.btn-danger` - Danger button (red)
|
|
153
|
-
- `.btn-grey` - Grey button
|
|
154
|
-
|
|
155
|
-
**Layout:**
|
|
156
|
-
- `.card` - Card container
|
|
157
|
-
- `.count-display` - Large number display
|
|
158
|
-
- `.counter-actions` - Button group
|
|
159
|
-
|
|
160
|
-
**Forms:**
|
|
161
|
-
- `input`, `textarea` - Styled inputs
|
|
162
|
-
- `form` - Styled form
|
|
163
|
-
|
|
164
|
-
## Switching Frameworks
|
|
165
|
-
|
|
166
|
-
### After Project Creation
|
|
167
|
-
|
|
168
|
-
If you want to switch frameworks after creating your project:
|
|
169
|
-
|
|
170
|
-
**To Bootstrap:**
|
|
171
|
-
1. Add Bootstrap CDN to `app.html`:
|
|
172
|
-
```html
|
|
173
|
-
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
|
|
174
|
-
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
|
|
175
|
-
```
|
|
176
|
-
|
|
177
|
-
2. Update your components with Bootstrap classes
|
|
178
|
-
|
|
179
|
-
**To Tailwind:**
|
|
180
|
-
1. Add Tailwind CDN to `app.html`:
|
|
181
|
-
```html
|
|
182
|
-
<script src="https://cdn.tailwindcss.com"></script>
|
|
183
|
-
```
|
|
184
|
-
|
|
185
|
-
2. Update your components with Tailwind classes
|
|
186
|
-
|
|
187
|
-
**To Custom CSS:**
|
|
188
|
-
1. Remove framework CDN links from `app.html`
|
|
189
|
-
2. Update your components with custom classes
|
|
190
|
-
|
|
191
|
-
## Best Practices
|
|
192
|
-
|
|
193
|
-
### Bootstrap
|
|
194
|
-
- Use semantic HTML with Bootstrap classes
|
|
195
|
-
- Leverage Bootstrap's grid system
|
|
196
|
-
- Use Bootstrap components for consistency
|
|
197
|
-
- Customize with Bootstrap variables
|
|
198
|
-
|
|
199
|
-
### Tailwind
|
|
200
|
-
- Use utility classes directly in JSX
|
|
201
|
-
- Combine utilities for complex designs
|
|
202
|
-
- Use responsive prefixes (`md:`, `lg:`)
|
|
203
|
-
- Extract common patterns into components
|
|
204
|
-
|
|
205
|
-
### Custom CSS
|
|
206
|
-
- Keep styles in `<style>` tag in `app.html`
|
|
207
|
-
- Use BEM naming convention
|
|
208
|
-
- Create reusable utility classes
|
|
209
|
-
- Keep specificity low
|
|
210
|
-
|
|
211
|
-
## Tips
|
|
212
|
-
|
|
213
|
-
1. **Consistency** - Stick to one framework per project
|
|
214
|
-
2. **Performance** - CDN links are cached by browsers
|
|
215
|
-
3. **Customization** - All frameworks can be customized
|
|
216
|
-
4. **Learning** - Start with one framework and master it
|
|
217
|
-
5. **Components** - Build reusable components regardless of framework
|
|
218
|
-
|
|
219
|
-
## Examples
|
|
220
|
-
|
|
221
|
-
Check the example pages in your project to see the chosen framework in action!
|
|
@@ -1,184 +0,0 @@
|
|
|
1
|
-
# Dev Server Guide
|
|
2
|
-
|
|
3
|
-
## Overview
|
|
4
|
-
|
|
5
|
-
The dev server provides a smooth development experience with live reload using WebSocket, automatic import generation, and file watching.
|
|
6
|
-
|
|
7
|
-
## Features
|
|
8
|
-
|
|
9
|
-
### 🔄 Live Reload (WebSocket-based)
|
|
10
|
-
- **Automatic browser refresh** when you save files
|
|
11
|
-
- **Visual indicator** in bottom-right corner shows connection status
|
|
12
|
-
- **WebSocket connection** - reliable, fast, no caching issues
|
|
13
|
-
- **CSS hot reload** - instant updates without regenerating imports
|
|
14
|
-
- **Always loaded** - script is part of your HTML, not injected
|
|
15
|
-
|
|
16
|
-
### 👀 File Watching
|
|
17
|
-
The dev server watches these directories:
|
|
18
|
-
- `api/` - API route files
|
|
19
|
-
- `components/` - React-like components
|
|
20
|
-
- `pages/` - Page components
|
|
21
|
-
- `modules/` - Core system modules
|
|
22
|
-
- `styles/` - CSS files
|
|
23
|
-
|
|
24
|
-
### 🚀 Auto Import Generation
|
|
25
|
-
- Automatically generates script tags in `app.html`
|
|
26
|
-
- Runs on startup and whenever JS/JSX files change
|
|
27
|
-
- No need to manually add imports
|
|
28
|
-
|
|
29
|
-
### 🎯 Smart Port Selection
|
|
30
|
-
- Defaults to port 3000
|
|
31
|
-
- Automatically finds next available port if 3000 is busy
|
|
32
|
-
- Shows the actual URL in console
|
|
33
|
-
|
|
34
|
-
## Usage
|
|
35
|
-
|
|
36
|
-
```bash
|
|
37
|
-
npm run dev
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
Then open the URL shown in console (usually `http://localhost:3000/`)
|
|
41
|
-
|
|
42
|
-
## Visual Indicators
|
|
43
|
-
|
|
44
|
-
The live reload indicator in the bottom-right corner shows:
|
|
45
|
-
- 🔌 **Connecting...** - Initial connection (gray/green)
|
|
46
|
-
- ✅ **Live Reload** - Connected and watching (green, fades to 30%)
|
|
47
|
-
- 🔄 **Reloading...** - Changes detected, refreshing page (blue)
|
|
48
|
-
- ⚠️ **Disconnected** - Connection lost, attempting to reconnect (orange)
|
|
49
|
-
- ❌ **Offline** - Max reconnection attempts reached (red)
|
|
50
|
-
|
|
51
|
-
**Click the indicator** to manually reload the page.
|
|
52
|
-
|
|
53
|
-
Hover over the indicator to make it fully visible.
|
|
54
|
-
|
|
55
|
-
## How It Works
|
|
56
|
-
|
|
57
|
-
1. **Server starts** and generates initial imports
|
|
58
|
-
2. **Browser loads** `live-reload-client.js` (always in HTML)
|
|
59
|
-
3. **WebSocket connects** to dev server
|
|
60
|
-
4. **File watcher** detects changes in watched directories
|
|
61
|
-
5. **Debouncing** prevents multiple rapid reloads (300ms for CSS, 500ms for JS)
|
|
62
|
-
6. **Import regeneration** (for JS/JSX changes only)
|
|
63
|
-
7. **WebSocket message** sent to all connected browsers
|
|
64
|
-
8. **Page reload** happens immediately
|
|
65
|
-
|
|
66
|
-
## Why WebSocket?
|
|
67
|
-
|
|
68
|
-
Previous versions used Server-Sent Events (SSE) with runtime injection, which had caching issues. The new approach:
|
|
69
|
-
|
|
70
|
-
- ✅ **Always loaded** - Script is in HTML, not injected at runtime
|
|
71
|
-
- ✅ **No caching issues** - Browser always has the script
|
|
72
|
-
- ✅ **Bidirectional** - WebSocket allows two-way communication
|
|
73
|
-
- ✅ **Reliable** - Built-in reconnection logic
|
|
74
|
-
- ✅ **Fast** - Instant notifications, no polling
|
|
75
|
-
|
|
76
|
-
## Cache Control
|
|
77
|
-
|
|
78
|
-
The dev server sends these headers to prevent caching:
|
|
79
|
-
```
|
|
80
|
-
Cache-Control: no-cache, no-store, must-revalidate
|
|
81
|
-
Pragma: no-cache
|
|
82
|
-
Expires: 0
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
Plus, `app.html` has meta tags:
|
|
86
|
-
```html
|
|
87
|
-
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate">
|
|
88
|
-
<meta http-equiv="Pragma" content="no-cache">
|
|
89
|
-
<meta http-equiv="Expires" content="0">
|
|
90
|
-
```
|
|
91
|
-
|
|
92
|
-
## Troubleshooting
|
|
93
|
-
|
|
94
|
-
### Indicator stuck on "Connecting..."?
|
|
95
|
-
|
|
96
|
-
1. **Check dev server is running** - Terminal should show "✅ Dev server running"
|
|
97
|
-
2. **Check browser console** (F12) - Look for WebSocket errors
|
|
98
|
-
3. **Check port** - Browser URL should match server URL
|
|
99
|
-
4. **Firewall** - Allow Node.js through firewall
|
|
100
|
-
5. **Try different browser** - Rule out browser-specific issues
|
|
101
|
-
|
|
102
|
-
### Changes not showing?
|
|
103
|
-
|
|
104
|
-
1. **Check indicator is green** - "✅ Live Reload"
|
|
105
|
-
2. **Check terminal** - Should show "📝 Detected change: ..."
|
|
106
|
-
3. **Check file was saved** - No unsaved indicator in editor
|
|
107
|
-
4. **Check file location** - Must be in watched directories
|
|
108
|
-
5. **Check for errors** - Browser console (F12) for JavaScript errors
|
|
109
|
-
|
|
110
|
-
### WebSocket connection failed?
|
|
111
|
-
|
|
112
|
-
1. **Port mismatch** - Check browser URL matches server port
|
|
113
|
-
2. **Proxy/VPN** - May block WebSocket connections
|
|
114
|
-
3. **Browser extension** - Ad blockers can interfere
|
|
115
|
-
4. **Try incognito mode** - Rule out extensions
|
|
116
|
-
|
|
117
|
-
### Port already in use?
|
|
118
|
-
|
|
119
|
-
The server automatically tries the next port. Check terminal for actual port:
|
|
120
|
-
```
|
|
121
|
-
🌐 Server running at http://localhost:3001/
|
|
122
|
-
```
|
|
123
|
-
|
|
124
|
-
## Performance
|
|
125
|
-
|
|
126
|
-
- **Debouncing** prevents reload spam when saving multiple files
|
|
127
|
-
- **CSS-only changes** skip import regeneration for faster updates
|
|
128
|
-
- **WebSocket** is lightweight and efficient
|
|
129
|
-
- **Multiple browsers** can connect simultaneously
|
|
130
|
-
- **Automatic reconnection** if connection drops
|
|
131
|
-
|
|
132
|
-
## Development Tips
|
|
133
|
-
|
|
134
|
-
1. Keep the terminal visible to see file change notifications
|
|
135
|
-
2. The visual indicator helps confirm live reload is working
|
|
136
|
-
3. CSS changes are faster than JS changes (no import regeneration)
|
|
137
|
-
4. Multiple browser tabs will all reload simultaneously
|
|
138
|
-
5. Click the indicator to manually reload if needed
|
|
139
|
-
|
|
140
|
-
## Production
|
|
141
|
-
|
|
142
|
-
The live reload script only runs in development (localhost). In production:
|
|
143
|
-
- Script detects non-localhost hostname
|
|
144
|
-
- Exits immediately without connecting
|
|
145
|
-
- No performance impact
|
|
146
|
-
- No visual indicator
|
|
147
|
-
|
|
148
|
-
## Technical Details
|
|
149
|
-
|
|
150
|
-
### WebSocket Protocol
|
|
151
|
-
|
|
152
|
-
The dev server implements a simple WebSocket server without external dependencies:
|
|
153
|
-
- Uses Node.js `http` module's `upgrade` event
|
|
154
|
-
- Performs WebSocket handshake manually
|
|
155
|
-
- Sends text frames to connected clients
|
|
156
|
-
- Handles connection cleanup automatically
|
|
157
|
-
|
|
158
|
-
### Message Format
|
|
159
|
-
|
|
160
|
-
Server sends a single message type:
|
|
161
|
-
- `"reload"` - Triggers browser reload
|
|
162
|
-
|
|
163
|
-
### Reconnection Logic
|
|
164
|
-
|
|
165
|
-
Client attempts to reconnect:
|
|
166
|
-
- Max 10 attempts
|
|
167
|
-
- 2-second delay between attempts
|
|
168
|
-
- Exponential backoff could be added if needed
|
|
169
|
-
|
|
170
|
-
## Comparison with Other Tools
|
|
171
|
-
|
|
172
|
-
| Feature | Aziz App | Live Server | Vite |
|
|
173
|
-
|---------|----------|-------------|------|
|
|
174
|
-
| Setup | Zero config | Zero config | Config file |
|
|
175
|
-
| Speed | Fast | Fast | Very fast |
|
|
176
|
-
| WebSocket | ✅ | ✅ | ✅ |
|
|
177
|
-
| Auto-import | ✅ | ❌ | ✅ |
|
|
178
|
-
| Visual indicator | ✅ | ❌ | ❌ |
|
|
179
|
-
| Dependencies | None | None | Many |
|
|
180
|
-
|
|
181
|
-
## Summary
|
|
182
|
-
|
|
183
|
-
The dev server provides a reliable, fast live reload experience using WebSocket. The script is always loaded (not injected), eliminating caching issues. File watching, debouncing, and automatic reconnection make development smooth and efficient.
|
|
184
|
-
|