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.
@@ -1,14 +1,16 @@
1
1
  {
2
- "name": "fullstack-ssr-app",
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 Full-Stack SSR Template
1
+ # Frontend Hamroun SSR Template
2
2
 
3
- This template demonstrates a comprehensive server-side rendering (SSR) application using the Frontend Hamroun framework, complete with authentication, protected routes, and API endpoints.
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 `http://localhost:3000`
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
- - **Admin User**:
32
- - Username: `admin`
33
- - Password: `admin123`
34
- - Roles: `['admin']`
19
+ ## How it Works
35
20
 
36
- - **Regular User**:
37
- - Username: `user`
38
- - Password: `user123`
39
- - Roles: `['user']`
21
+ This example demonstrates:
40
22
 
41
- In a production application, you would replace this with a real user database.
23
+ - Server-side rendering of components
24
+ - A simple API endpoint
25
+ - Basic client-side interactivity after SSR
42
26
 
43
- ## Available Routes
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
- - **/** - Home page with SSR
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
- ## Environmental Variables
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
- - **PORT** - Server port (default: 3000)
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
- ## Further Development
35
+ For more complex applications, you may want to:
57
36
 
58
- To extend this template:
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
- 1. Add more pages in the renderToString function or by creating separate components
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.