frontend-hamroun 1.2.16 → 1.2.17
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 +4 -0
- package/bin/cli.js +673 -0
- package/dist/component.d.ts +1 -1
- package/dist/context.d.ts +4 -3
- package/dist/index.client.d.ts +11 -0
- package/dist/index.d.ts +9 -89
- package/dist/index.js +396 -67
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +392 -0
- package/dist/index.mjs.map +1 -0
- package/dist/jsx-runtime/jsx-runtime.d.ts +0 -1
- package/dist/jsx-runtime.d.ts +1 -1
- package/dist/renderer.d.ts +0 -10
- package/dist/server-renderer.d.ts +0 -3
- package/dist/server-types.d.ts +42 -0
- package/package.json +69 -41
- package/templates/basic-app/index.html +6 -6
- package/templates/basic-app/package.json +18 -7
- package/templates/basic-app/postcss.config.js +0 -1
- package/templates/basic-app/src/main.tsx +1 -10
- package/templates/basic-app/tailwind.config.js +2 -23
- package/templates/basic-app/tsconfig.json +4 -17
- package/templates/basic-app/vite.config.ts +3 -54
- package/templates/fullstack-app/api/hello.ts +18 -0
- package/templates/fullstack-app/api/users/[id].ts +73 -0
- package/templates/fullstack-app/api/users/index.ts +32 -0
- package/templates/fullstack-app/package.json +31 -0
- package/templates/fullstack-app/server.ts +46 -0
- package/templates/fullstack-app/src/pages/index.tsx +59 -0
- package/templates/ssr-template/vite.config.ts +1 -11
- package/bin/cli.cjs +0 -16
- package/bin/cli.mjs +0 -237
- package/dist/backend/api-utils.d.ts +0 -38
- package/dist/backend/api-utils.js +0 -135
- package/dist/backend/auth.d.ts +0 -134
- package/dist/backend/auth.js +0 -387
- package/dist/backend/database.d.ts +0 -27
- package/dist/backend/database.js +0 -91
- package/dist/backend/model.d.ts +0 -43
- package/dist/backend/model.js +0 -178
- package/dist/backend/router.d.ts +0 -27
- package/dist/backend/router.js +0 -137
- package/dist/backend/server.d.ts +0 -19
- package/dist/backend/server.js +0 -268
- package/dist/backend/types.d.ts +0 -217
- package/dist/backend/types.js +0 -1
- package/dist/batch.js +0 -22
- package/dist/cli/index.d.ts +0 -2
- package/dist/cli/index.js +0 -215
- package/dist/component.js +0 -84
- package/dist/components/Counter.js +0 -2
- package/dist/context.js +0 -18
- package/dist/frontend-hamroun.es.js +0 -1378
- package/dist/frontend-hamroun.umd.js +0 -66
- package/dist/hooks.js +0 -164
- package/dist/jsx-runtime/index.d.ts +0 -11
- package/dist/jsx-runtime/index.js +0 -19
- package/dist/jsx-runtime/jsx-dev-runtime.js +0 -1
- package/dist/jsx-runtime/jsx-runtime.js +0 -95
- package/dist/jsx-runtime.js +0 -192
- package/dist/renderer.js +0 -51
- package/dist/server-renderer.js +0 -102
- package/dist/types.js +0 -1
- package/dist/vdom.js +0 -27
- package/scripts/build-cli.js +0 -1199
- package/scripts/generate.js +0 -134
- package/src/backend/api-utils.ts +0 -178
- package/src/backend/auth.ts +0 -544
- package/src/backend/database.ts +0 -104
- package/src/backend/model.ts +0 -198
- package/src/backend/router.ts +0 -176
- package/src/backend/server.ts +0 -330
- package/src/backend/types.ts +0 -257
- package/src/batch.ts +0 -24
- package/src/cli/index.js +0 -554
- package/src/cli/index.ts +0 -257
- package/src/component.ts +0 -98
- package/src/components/Counter.tsx +0 -4
- package/src/context.ts +0 -29
- package/src/hooks.ts +0 -211
- package/src/index.ts +0 -144
- package/src/jsx-runtime/index.ts +0 -27
- package/src/jsx-runtime/jsx-dev-runtime.ts +0 -0
- package/src/jsx-runtime/jsx-runtime.ts +0 -104
- package/src/jsx-runtime.ts +0 -226
- package/src/renderer.ts +0 -55
- package/src/server-renderer.ts +0 -114
- package/src/shims.d.ts +0 -20
- package/src/types/bcrypt.d.ts +0 -30
- package/src/types/jsonwebtoken.d.ts +0 -55
- package/src/types.d.ts +0 -26
- package/src/types.ts +0 -21
- package/src/vdom.ts +0 -34
- package/templates/basic/.eslintignore +0 -5
- package/templates/basic/.eslintrc.json +0 -25
- package/templates/basic/docs/rapport_pfe.aux +0 -27
- package/templates/basic/docs/rapport_pfe.log +0 -399
- package/templates/basic/docs/rapport_pfe.out +0 -10
- package/templates/basic/docs/rapport_pfe.pdf +0 -0
- package/templates/basic/docs/rapport_pfe.tex +0 -68
- package/templates/basic/docs/rapport_pfe.toc +0 -14
- package/templates/basic/index.html +0 -12
- package/templates/basic/jsconfig.json +0 -14
- package/templates/basic/package.json +0 -18
- package/templates/basic/postcss.config.js +0 -7
- package/templates/basic/src/App.js +0 -105
- package/templates/basic/src/App.tsx +0 -65
- package/templates/basic/src/api.ts +0 -58
- package/templates/basic/src/components/Counter.tsx +0 -26
- package/templates/basic/src/components/Header.tsx +0 -9
- package/templates/basic/src/components/TodoList.tsx +0 -90
- package/templates/basic/src/main.css +0 -3
- package/templates/basic/src/main.js +0 -11
- package/templates/basic/src/main.ts +0 -20
- package/templates/basic/src/main.tsx +0 -144
- package/templates/basic/src/server.ts +0 -99
- package/templates/basic/tailwind.config.js +0 -32
- package/templates/basic/tsconfig.json +0 -20
- package/templates/basic/tsconfig.node.json +0 -10
- package/templates/basic/vite.config.js +0 -18
- package/templates/basic/vite.config.ts +0 -86
- package/templates/basic-app/src/App.js +0 -105
- package/templates/basic-app/src/App.tsx +0 -143
- package/templates/basic-app/src/api.ts +0 -58
- package/templates/basic-app/src/components/Counter.tsx +0 -26
- package/templates/basic-app/src/components/Header.tsx +0 -9
- package/templates/basic-app/src/components/TodoList.tsx +0 -90
- package/templates/basic-app/src/main.js +0 -10
- package/templates/basic-app/src/main.ts +0 -21
- package/templates/basic-app/src/react/index.ts +0 -35
- package/templates/basic-app/src/react/jsx-dev-runtime.ts +0 -13
- package/templates/basic-app/src/react/jsx-runtime.ts +0 -12
- package/templates/basic-app/src/server.ts +0 -99
- package/templates/basic-app/src/shims.ts +0 -9
- package/templates/basic-app/tsconfig.node.json +0 -10
- package/templates/basic-app/vite.config.js +0 -22
- package/templates/full-stack/.env.example +0 -11
- package/templates/full-stack/README.md +0 -51
- package/templates/full-stack/index.html +0 -12
- package/templates/full-stack/jsconfig.json +0 -14
- package/templates/full-stack/package.json +0 -21
- package/templates/full-stack/src/App.js +0 -105
- package/templates/full-stack/src/client/App.tsx +0 -50
- package/templates/full-stack/src/client/components/Header.tsx +0 -42
- package/templates/full-stack/src/client/components/UserList.tsx +0 -29
- package/templates/full-stack/src/client/main.tsx +0 -5
- package/templates/full-stack/src/main.css +0 -3
- package/templates/full-stack/src/main.js +0 -11
- package/templates/full-stack/src/main.ts +0 -20
- package/templates/full-stack/src/server/index.ts +0 -99
- package/templates/full-stack/src/server/routes/auth.ts +0 -39
- package/templates/full-stack/src/server/routes/users.ts +0 -48
- package/templates/full-stack/src/shims.ts +0 -9
- package/templates/full-stack/tsconfig.json +0 -20
- package/templates/full-stack/tsconfig.node.json +0 -10
- package/templates/full-stack/tsconfig.server.json +0 -15
- package/templates/full-stack/vite.config.js +0 -18
- package/templates/full-stack/vite.config.ts +0 -85
@@ -1,11 +0,0 @@
|
|
1
|
-
import { render } from 'frontend-hamroun';
|
2
|
-
import { App } from './App.js';
|
3
|
-
|
4
|
-
document.addEventListener('DOMContentLoaded', () => {
|
5
|
-
const rootElement = document.getElementById('app');
|
6
|
-
if (rootElement) {
|
7
|
-
// Call App as a function to create the VDOM structure
|
8
|
-
render(App(), rootElement);
|
9
|
-
console.log('App rendered successfully');
|
10
|
-
}
|
11
|
-
});
|
@@ -1,20 +0,0 @@
|
|
1
|
-
import './main.css';
|
2
|
-
import { render } from 'frontend-hamroun';
|
3
|
-
import { App } from './App';
|
4
|
-
import { createApiClient } from './api';
|
5
|
-
|
6
|
-
// Initialize API client
|
7
|
-
const api = createApiClient({
|
8
|
-
baseUrl: '/api'
|
9
|
-
});
|
10
|
-
|
11
|
-
// Render the app into the DOM
|
12
|
-
document.addEventListener('DOMContentLoaded', () => {
|
13
|
-
const rootElement = document.getElementById('app');
|
14
|
-
if (rootElement) {
|
15
|
-
render(<App api={api} />, rootElement);
|
16
|
-
console.log('App rendered successfully');
|
17
|
-
} else {
|
18
|
-
console.error('Root element #app not found');
|
19
|
-
}
|
20
|
-
});
|
@@ -1,99 +0,0 @@
|
|
1
|
-
import dotenv from 'dotenv';
|
2
|
-
import { createServer, createAuth } from 'frontend-hamroun';
|
3
|
-
import cookieParser from 'cookie-parser';
|
4
|
-
import userRoutes from './routes/users';
|
5
|
-
import authRoutes from './routes/auth';
|
6
|
-
|
7
|
-
// Load environment variables
|
8
|
-
dotenv.config();
|
9
|
-
|
10
|
-
// Create the server
|
11
|
-
const app = createServer({
|
12
|
-
port: parseInt(process.env.PORT || '3000'),
|
13
|
-
staticDir: 'dist/client',
|
14
|
-
ssrEnabled: process.env.NODE_ENV === 'production',
|
15
|
-
trustProxy: process.env.NODE_ENV === 'production'
|
16
|
-
});
|
17
|
-
|
18
|
-
// Add cookie parser middleware
|
19
|
-
app.use(cookieParser());
|
20
|
-
|
21
|
-
// Connect to database
|
22
|
-
if (process.env.MONGODB_URI) {
|
23
|
-
app.connectToDatabase({
|
24
|
-
uri: process.env.MONGODB_URI,
|
25
|
-
name: process.env.MONGODB_NAME || '{{projectName}}',
|
26
|
-
retryAttempts: 3
|
27
|
-
}).catch(err => {
|
28
|
-
console.error('Database connection error:', err);
|
29
|
-
});
|
30
|
-
}
|
31
|
-
|
32
|
-
// Create authentication service
|
33
|
-
const auth = createAuth({
|
34
|
-
jwtSecret: process.env.JWT_SECRET || 'your-secret-key-change-in-production',
|
35
|
-
refreshSecret: process.env.REFRESH_SECRET,
|
36
|
-
tokenExpiration: '15m',
|
37
|
-
refreshExpiration: '7d',
|
38
|
-
// Add user finder implementation
|
39
|
-
findUser: async (username) => {
|
40
|
-
// Implement user lookup logic with your user model
|
41
|
-
// For now, return a dummy user for testing
|
42
|
-
if (username === 'admin') {
|
43
|
-
return {
|
44
|
-
id: '1',
|
45
|
-
username: 'admin',
|
46
|
-
password: '$2b$10$...', // This should be a proper bcrypt hash
|
47
|
-
role: 'admin'
|
48
|
-
};
|
49
|
-
}
|
50
|
-
return null;
|
51
|
-
}
|
52
|
-
});
|
53
|
-
|
54
|
-
// Register API routes
|
55
|
-
app.registerApi('/users', userRoutes);
|
56
|
-
app.registerApi('/auth', authRoutes);
|
57
|
-
|
58
|
-
// Simple SSR for the homepage
|
59
|
-
app.registerSSR('/', (props) => {
|
60
|
-
return {
|
61
|
-
type: 'div',
|
62
|
-
props: {
|
63
|
-
children: [
|
64
|
-
{
|
65
|
-
type: 'h1',
|
66
|
-
props: {
|
67
|
-
children: '{{appName}} - Home Page'
|
68
|
-
}
|
69
|
-
},
|
70
|
-
{
|
71
|
-
type: 'p',
|
72
|
-
props: {
|
73
|
-
children: 'Welcome to your new Hamroun application!'
|
74
|
-
}
|
75
|
-
}
|
76
|
-
]
|
77
|
-
}
|
78
|
-
};
|
79
|
-
}, {
|
80
|
-
title: '{{appName}} - Home',
|
81
|
-
styles: `
|
82
|
-
body {
|
83
|
-
font-family: system-ui, sans-serif;
|
84
|
-
max-width: 800px;
|
85
|
-
margin: 0 auto;
|
86
|
-
padding: 20px;
|
87
|
-
}
|
88
|
-
h1 { color: #336699; }
|
89
|
-
`
|
90
|
-
});
|
91
|
-
|
92
|
-
// Start the server
|
93
|
-
app.start(() => {
|
94
|
-
console.log(`
|
95
|
-
🚀 Server is running!
|
96
|
-
🌐 API URL: http://localhost:${process.env.PORT || 3000}/api
|
97
|
-
📂 Static files: ${process.cwd()}/dist/client
|
98
|
-
`);
|
99
|
-
});
|
@@ -1,39 +0,0 @@
|
|
1
|
-
import { Router } from 'express';
|
2
|
-
import { createAuth } from 'frontend-hamroun';
|
3
|
-
import dotenv from 'dotenv';
|
4
|
-
|
5
|
-
dotenv.config();
|
6
|
-
|
7
|
-
const router = Router();
|
8
|
-
|
9
|
-
// Create auth service
|
10
|
-
const auth = createAuth({
|
11
|
-
jwtSecret: process.env.JWT_SECRET || 'your-secret-key-change-in-production',
|
12
|
-
refreshSecret: process.env.REFRESH_SECRET,
|
13
|
-
findUser: async (username) => {
|
14
|
-
// Implement user lookup logic with your user model
|
15
|
-
// This is a placeholder implementation
|
16
|
-
if (username === 'admin') {
|
17
|
-
return {
|
18
|
-
id: '1',
|
19
|
-
username: 'admin',
|
20
|
-
// This is a placeholder password hash - never hardcode passwords in real apps
|
21
|
-
password: '$2b$10$mLZFjL5CNXdT4l7aPaK2S.HsRCgkjqmZ3W8MxiZZ.caHrMEhR5Nba', // "password123"
|
22
|
-
role: 'admin'
|
23
|
-
};
|
24
|
-
}
|
25
|
-
return null;
|
26
|
-
}
|
27
|
-
});
|
28
|
-
|
29
|
-
// Auth routes
|
30
|
-
router.post('/login', auth.login);
|
31
|
-
router.post('/refresh', auth.refreshToken);
|
32
|
-
router.post('/logout', auth.logout);
|
33
|
-
|
34
|
-
// Protected route example
|
35
|
-
router.get('/profile', auth.authenticate, (req, res) => {
|
36
|
-
res.json({ user: (req as any).user });
|
37
|
-
});
|
38
|
-
|
39
|
-
export default router;
|
@@ -1,48 +0,0 @@
|
|
1
|
-
import { Router } from 'express';
|
2
|
-
import { asyncHandler, sendSuccess, sendError } from 'frontend-hamroun';
|
3
|
-
|
4
|
-
const router = Router();
|
5
|
-
|
6
|
-
// Sample users for demo purposes
|
7
|
-
const users = [
|
8
|
-
{ id: '1', name: 'John Doe', email: 'john@example.com', role: 'admin' },
|
9
|
-
{ id: '2', name: 'Jane Smith', email: 'jane@example.com', role: 'user' }
|
10
|
-
];
|
11
|
-
|
12
|
-
// Get all users
|
13
|
-
router.get('/', asyncHandler(async (req, res) => {
|
14
|
-
sendSuccess(res, users);
|
15
|
-
}));
|
16
|
-
|
17
|
-
// Get user by ID
|
18
|
-
router.get('/:id', asyncHandler(async (req, res) => {
|
19
|
-
const user = users.find(u => u.id === req.params.id);
|
20
|
-
|
21
|
-
if (!user) {
|
22
|
-
return sendError(res, 'User not found', 404);
|
23
|
-
}
|
24
|
-
|
25
|
-
sendSuccess(res, user);
|
26
|
-
}));
|
27
|
-
|
28
|
-
// Create user
|
29
|
-
router.post('/', asyncHandler(async (req, res) => {
|
30
|
-
const { name, email, role = 'user' } = req.body;
|
31
|
-
|
32
|
-
if (!name || !email) {
|
33
|
-
return sendError(res, 'Name and email are required', 400);
|
34
|
-
}
|
35
|
-
|
36
|
-
const newUser = {
|
37
|
-
id: (users.length + 1).toString(),
|
38
|
-
name,
|
39
|
-
email,
|
40
|
-
role
|
41
|
-
};
|
42
|
-
|
43
|
-
users.push(newUser);
|
44
|
-
|
45
|
-
sendSuccess(res, newUser, 'User created successfully', 201);
|
46
|
-
}));
|
47
|
-
|
48
|
-
export default router;
|
@@ -1,9 +0,0 @@
|
|
1
|
-
// This file provides compatibility shims for React JSX imports
|
2
|
-
|
3
|
-
import { jsx } from 'frontend-hamroun';
|
4
|
-
|
5
|
-
// Export the jsx function as jsxDEV for React compatibility
|
6
|
-
export const jsxDEV = jsx;
|
7
|
-
|
8
|
-
// Export a Fragment symbol
|
9
|
-
export const Fragment = Symbol('Fragment');
|
@@ -1,20 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"compilerOptions": {
|
3
|
-
"target": "ES2020",
|
4
|
-
"useDefineForClassFields": true,
|
5
|
-
"module": "ESNext",
|
6
|
-
"lib": ["ES2020", "DOM", "DOM.Iterable"],
|
7
|
-
"skipLibCheck": true,
|
8
|
-
"moduleResolution": "bundler",
|
9
|
-
"allowImportingTsExtensions": true,
|
10
|
-
"resolveJsonModule": true,
|
11
|
-
"isolatedModules": true,
|
12
|
-
"noEmit": true,
|
13
|
-
"strict": true,
|
14
|
-
"noUnusedLocals": true,
|
15
|
-
"noUnusedParameters": true,
|
16
|
-
"noFallthroughCasesInSwitch": true
|
17
|
-
},
|
18
|
-
"include": ["src"],
|
19
|
-
"references": [{ "path": "./tsconfig.node.json" }]
|
20
|
-
}
|
@@ -1,15 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"compilerOptions": {
|
3
|
-
"target": "ES2018",
|
4
|
-
"module": "ESNext",
|
5
|
-
"moduleResolution": "node",
|
6
|
-
"esModuleInterop": true,
|
7
|
-
"strict": true,
|
8
|
-
"skipLibCheck": true,
|
9
|
-
"forceConsistentCasingInFileNames": true,
|
10
|
-
"outDir": "dist",
|
11
|
-
"rootDir": "src"
|
12
|
-
},
|
13
|
-
"include": ["src/server/**/*"],
|
14
|
-
"exclude": ["node_modules", "dist"]
|
15
|
-
}
|
@@ -1,18 +0,0 @@
|
|
1
|
-
import { defineConfig } from 'vite';
|
2
|
-
import { nodePolyfills } from 'vite-plugin-node-polyfills';
|
3
|
-
|
4
|
-
export default defineConfig({
|
5
|
-
build: {
|
6
|
-
outDir: 'dist',
|
7
|
-
emptyOutDir: true
|
8
|
-
},
|
9
|
-
server: {
|
10
|
-
port: 3000,
|
11
|
-
open: true
|
12
|
-
},
|
13
|
-
plugins: [
|
14
|
-
nodePolyfills({
|
15
|
-
protocolImports: true,
|
16
|
-
}),
|
17
|
-
]
|
18
|
-
});
|
@@ -1,85 +0,0 @@
|
|
1
|
-
import { defineConfig } from 'vite';
|
2
|
-
import { nodePolyfills } from 'vite-plugin-node-polyfills';
|
3
|
-
import path from 'path';
|
4
|
-
|
5
|
-
export default defineConfig({
|
6
|
-
esbuild: {
|
7
|
-
jsxFactory: 'jsx',
|
8
|
-
jsxFragment: 'Fragment',
|
9
|
-
jsxInject: `import { jsx, Fragment } from 'frontend-hamroun'`
|
10
|
-
},
|
11
|
-
build: {
|
12
|
-
outDir: 'dist',
|
13
|
-
emptyOutDir: true,
|
14
|
-
rollupOptions: {
|
15
|
-
// Mark server-side dependencies as external
|
16
|
-
external: [
|
17
|
-
'express',
|
18
|
-
'compression',
|
19
|
-
'helmet',
|
20
|
-
'morgan',
|
21
|
-
'bcrypt',
|
22
|
-
'jsonwebtoken',
|
23
|
-
'mongoose',
|
24
|
-
'aws-sdk',
|
25
|
-
'nock',
|
26
|
-
'mock-aws-s3',
|
27
|
-
'@mswjs/interceptors',
|
28
|
-
/node:.*/
|
29
|
-
]
|
30
|
-
}
|
31
|
-
},
|
32
|
-
server: {
|
33
|
-
port: 3000,
|
34
|
-
open: true,
|
35
|
-
proxy: {
|
36
|
-
'/api': {
|
37
|
-
target: 'http://localhost:3001',
|
38
|
-
changeOrigin: true
|
39
|
-
}
|
40
|
-
}
|
41
|
-
},
|
42
|
-
optimizeDeps: {
|
43
|
-
esbuildOptions: {
|
44
|
-
define: {
|
45
|
-
global: 'globalThis'
|
46
|
-
},
|
47
|
-
plugins: [
|
48
|
-
{
|
49
|
-
name: 'node-modules-polyfill',
|
50
|
-
setup(build) {
|
51
|
-
build.onResolve({ filter: /^node:/ }, () => {
|
52
|
-
return { external: true };
|
53
|
-
});
|
54
|
-
build.onResolve({ filter: /\.html$/ }, () => {
|
55
|
-
return { external: true };
|
56
|
-
});
|
57
|
-
}
|
58
|
-
}
|
59
|
-
]
|
60
|
-
},
|
61
|
-
exclude: [
|
62
|
-
'mock-aws-s3',
|
63
|
-
'aws-sdk',
|
64
|
-
'nock',
|
65
|
-
'@mswjs/interceptors',
|
66
|
-
'node-pre-gyp',
|
67
|
-
'bcrypt'
|
68
|
-
]
|
69
|
-
},
|
70
|
-
plugins: [
|
71
|
-
nodePolyfills({
|
72
|
-
protocolImports: true,
|
73
|
-
}),
|
74
|
-
],
|
75
|
-
resolve: {
|
76
|
-
alias: {
|
77
|
-
'@mswjs/interceptors/presets/node': { find: /^@mswjs\/interceptors\/presets\/node/, replacement: '{}' },
|
78
|
-
'./util/nw-pre-gyp/index.html': { find: './util/nw-pre-gyp/index.html', replacement: '{}' },
|
79
|
-
'react/jsx-runtime': path.resolve(__dirname, 'src/shims.ts'),
|
80
|
-
'react/jsx-dev-runtime': path.resolve(__dirname, 'src/shims.ts'),
|
81
|
-
'react': path.resolve(__dirname, 'src/shims.ts'),
|
82
|
-
'react-dom': 'frontend-hamroun'
|
83
|
-
}
|
84
|
-
}
|
85
|
-
});
|