frontend-hamroun 1.2.24 → 1.2.25
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 +3 -0
- package/package.json +1 -1
- package/templates/fullstack-app/api/hello.js +11 -0
- package/templates/fullstack-app/index.html +13 -0
- package/templates/fullstack-app/package-lock.json +3130 -0
- package/templates/fullstack-app/package.json +8 -19
- package/templates/fullstack-app/server.js +68 -0
- package/templates/fullstack-app/server.ts +70 -31
- package/templates/fullstack-app/src/client.js +20 -0
- package/templates/fullstack-app/src/main.tsx +9 -0
- package/templates/fullstack-app/src/pages/index.tsx +40 -36
- package/templates/fullstack-app/vite.config.js +40 -0
- package/templates/ssr-template/package-lock.json +95 -1161
- package/templates/ssr-template/package.json +6 -4
- package/templates/ssr-template/readme.md +17 -39
- package/templates/ssr-template/server.js +364 -549
- package/templates/ssr-template/tsconfig.json +2 -3
@@ -1,14 +1,16 @@
|
|
1
1
|
{
|
2
|
-
"name": "
|
3
|
-
"private": true,
|
2
|
+
"name": "ssr-app",
|
4
3
|
"version": "0.1.0",
|
5
4
|
"type": "module",
|
6
5
|
"scripts": {
|
7
6
|
"dev": "node server.js",
|
8
|
-
"start": "node server.js"
|
7
|
+
"start": "node server.js",
|
8
|
+
"build": "echo 'No build step required for this template'"
|
9
9
|
},
|
10
10
|
"dependencies": {
|
11
|
+
"dotenv": "^16.0.3",
|
11
12
|
"express": "^4.18.2",
|
12
|
-
"frontend-hamroun": "latest"
|
13
|
+
"frontend-hamroun": "latest",
|
14
|
+
"node-fetch": "^3.3.1"
|
13
15
|
}
|
14
16
|
}
|
@@ -1,14 +1,6 @@
|
|
1
|
-
# Frontend Hamroun
|
1
|
+
# Frontend Hamroun SSR Template
|
2
2
|
|
3
|
-
This
|
4
|
-
|
5
|
-
## Features
|
6
|
-
|
7
|
-
- **Server-Side Rendering**: Pages rendered on the server for optimal SEO and performance
|
8
|
-
- **Authentication**: JWT-based authentication system with login/logout functionality
|
9
|
-
- **Role-Based Authorization**: Different content for regular users and admins
|
10
|
-
- **Protected API Routes**: Secured endpoints that require authentication
|
11
|
-
- **Database Integration**: Optional connection to MongoDB, MySQL, or PostgreSQL
|
3
|
+
This is a simple server-side rendering (SSR) example using Frontend Hamroun.
|
12
4
|
|
13
5
|
## Getting Started
|
14
6
|
|
@@ -22,42 +14,28 @@ This template demonstrates a comprehensive server-side rendering (SSR) applicati
|
|
22
14
|
npm start
|
23
15
|
```
|
24
16
|
|
25
|
-
3. Open your browser at
|
26
|
-
|
27
|
-
## Authentication
|
28
|
-
|
29
|
-
This template includes a mock authentication system with two users:
|
17
|
+
3. Open your browser at http://localhost:3000
|
30
18
|
|
31
|
-
|
32
|
-
- Username: `admin`
|
33
|
-
- Password: `admin123`
|
34
|
-
- Roles: `['admin']`
|
19
|
+
## How it Works
|
35
20
|
|
36
|
-
|
37
|
-
- Username: `user`
|
38
|
-
- Password: `user123`
|
39
|
-
- Roles: `['user']`
|
21
|
+
This example demonstrates:
|
40
22
|
|
41
|
-
|
23
|
+
- Server-side rendering of components
|
24
|
+
- A simple API endpoint
|
25
|
+
- Basic client-side interactivity after SSR
|
42
26
|
|
43
|
-
|
27
|
+
The server renders the component on each request using `renderToString`, then sends the HTML to the client. A small script adds interactivity to the rendered HTML on the client side.
|
44
28
|
|
45
|
-
|
46
|
-
- **/api/auth/login** (POST) - Login endpoint
|
47
|
-
- **/api/protected** (GET) - Protected data (requires authentication)
|
48
|
-
- **/api/admin** (GET) - Admin-only data (requires admin role)
|
29
|
+
## Adding More Components
|
49
30
|
|
50
|
-
|
31
|
+
To add more components, create them directly in the server.js file or in separate files and import them. Use the `createElement` function from 'frontend-hamroun/jsx-runtime' to create elements.
|
51
32
|
|
52
|
-
|
53
|
-
- **JWT_SECRET** - Secret key for JWT tokens (default: 'your-development-secret-key')
|
54
|
-
- **DATABASE_URL** - Database connection string (if using database)
|
33
|
+
## Advanced Usage
|
55
34
|
|
56
|
-
|
35
|
+
For more complex applications, you may want to:
|
57
36
|
|
58
|
-
|
37
|
+
1. Add a build step with a bundler like Vite or Webpack
|
38
|
+
2. Use a routing solution for more complex page structures
|
39
|
+
3. Set up database connections and more robust API endpoints
|
59
40
|
|
60
|
-
|
61
|
-
2. Connect to a real database by uncommenting the database configuration
|
62
|
-
3. Add more API routes with different authentication requirements
|
63
|
-
4. Enhance the client-side JavaScript with more interactivity
|
41
|
+
Check the Frontend Hamroun documentation for more examples and advanced usage patterns.
|