frontend-hamroun 1.2.15 → 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 -50
- package/templates/basic-app/index.html +6 -6
- package/templates/basic-app/package.json +15 -11
- 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 -1107
- 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 -20
- 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 -20
- 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
package/src/backend/types.ts
DELETED
@@ -1,257 +0,0 @@
|
|
1
|
-
import { Request, Response, NextFunction, RequestHandler } from 'express';
|
2
|
-
import { DatabaseConnector } from './database';
|
3
|
-
|
4
|
-
/**
|
5
|
-
* Options for configuring a Hamroun server
|
6
|
-
*/
|
7
|
-
export interface HamrounServerOptions {
|
8
|
-
/**
|
9
|
-
* Port to run the server on (default: 3000)
|
10
|
-
*/
|
11
|
-
port?: number;
|
12
|
-
|
13
|
-
/**
|
14
|
-
* Directory to serve static files from (default: 'public')
|
15
|
-
*/
|
16
|
-
staticDir?: string;
|
17
|
-
|
18
|
-
/**
|
19
|
-
* Enable CORS headers (default: true)
|
20
|
-
*/
|
21
|
-
enableCors?: boolean;
|
22
|
-
|
23
|
-
/**
|
24
|
-
* Prefix for API routes (default: '/api')
|
25
|
-
*/
|
26
|
-
apiPrefix?: string;
|
27
|
-
|
28
|
-
/**
|
29
|
-
* Enable server-side rendering (default: true)
|
30
|
-
*/
|
31
|
-
ssrEnabled?: boolean;
|
32
|
-
|
33
|
-
/**
|
34
|
-
* Additional Express middleware to apply
|
35
|
-
*/
|
36
|
-
middlewares?: RequestHandler[];
|
37
|
-
|
38
|
-
/**
|
39
|
-
* Enable response compression (default: true)
|
40
|
-
*/
|
41
|
-
enableCompression?: boolean;
|
42
|
-
|
43
|
-
/**
|
44
|
-
* Enable helmet security headers (default: true)
|
45
|
-
*/
|
46
|
-
enableHelmet?: boolean;
|
47
|
-
|
48
|
-
/**
|
49
|
-
* Disable Content Security Policy (default: false)
|
50
|
-
*/
|
51
|
-
disableCSP?: boolean;
|
52
|
-
|
53
|
-
/**
|
54
|
-
* Logging format for Morgan (default: 'dev')
|
55
|
-
*/
|
56
|
-
logFormat?: string | null;
|
57
|
-
|
58
|
-
/**
|
59
|
-
* Trust proxy headers (default: false)
|
60
|
-
*/
|
61
|
-
trustProxy?: boolean | string | number | string[] | number[];
|
62
|
-
|
63
|
-
/**
|
64
|
-
* Static file cache age (default: '1d')
|
65
|
-
*/
|
66
|
-
staticCacheAge?: string;
|
67
|
-
|
68
|
-
/**
|
69
|
-
* Show detailed error information in responses (default: false)
|
70
|
-
*/
|
71
|
-
showErrorDetails?: boolean;
|
72
|
-
}
|
73
|
-
|
74
|
-
/**
|
75
|
-
* Options for router configuration
|
76
|
-
*/
|
77
|
-
export interface RouterOptions {
|
78
|
-
/**
|
79
|
-
* Prefix to apply to all routes (overrides server apiPrefix)
|
80
|
-
*/
|
81
|
-
prefix?: string;
|
82
|
-
|
83
|
-
/**
|
84
|
-
* Enable authentication for all routes in this router
|
85
|
-
*/
|
86
|
-
requireAuth?: boolean;
|
87
|
-
|
88
|
-
/**
|
89
|
-
* Required role for all routes in this router
|
90
|
-
*/
|
91
|
-
requiredRole?: string | string[];
|
92
|
-
|
93
|
-
/**
|
94
|
-
* Enable rate limiting for this router
|
95
|
-
*/
|
96
|
-
rateLimit?: {
|
97
|
-
windowMs: number;
|
98
|
-
max: number;
|
99
|
-
message?: string;
|
100
|
-
};
|
101
|
-
}
|
102
|
-
|
103
|
-
/**
|
104
|
-
* Context provided to route handlers
|
105
|
-
*/
|
106
|
-
export interface RouteContext {
|
107
|
-
req: Request;
|
108
|
-
res: Response;
|
109
|
-
next: NextFunction;
|
110
|
-
params: any;
|
111
|
-
query: any;
|
112
|
-
body: any;
|
113
|
-
user?: any;
|
114
|
-
}
|
115
|
-
|
116
|
-
/**
|
117
|
-
* Pagination options
|
118
|
-
*/
|
119
|
-
export interface PaginationOptions {
|
120
|
-
page: number;
|
121
|
-
limit: number;
|
122
|
-
sort?: string;
|
123
|
-
order?: 'asc' | 'desc';
|
124
|
-
}
|
125
|
-
|
126
|
-
/**
|
127
|
-
* Paginated result
|
128
|
-
*/
|
129
|
-
export interface PaginatedResult<T> {
|
130
|
-
data: T[];
|
131
|
-
pagination: {
|
132
|
-
total: number;
|
133
|
-
totalPages: number;
|
134
|
-
currentPage: number;
|
135
|
-
limit: number;
|
136
|
-
hasNextPage: boolean;
|
137
|
-
hasPrevPage: boolean;
|
138
|
-
};
|
139
|
-
}
|
140
|
-
|
141
|
-
/**
|
142
|
-
* Database connection options
|
143
|
-
*/
|
144
|
-
export interface DatabaseOptions {
|
145
|
-
/**
|
146
|
-
* URI to connect to the database
|
147
|
-
*/
|
148
|
-
uri: string;
|
149
|
-
|
150
|
-
/**
|
151
|
-
* Database name
|
152
|
-
*/
|
153
|
-
name: string;
|
154
|
-
|
155
|
-
/**
|
156
|
-
* Connection options
|
157
|
-
*/
|
158
|
-
options?: Record<string, any>;
|
159
|
-
|
160
|
-
/**
|
161
|
-
* Number of retry attempts (default: 3)
|
162
|
-
*/
|
163
|
-
retryAttempts?: number;
|
164
|
-
|
165
|
-
/**
|
166
|
-
* Retry delay in ms (default: 1000)
|
167
|
-
*/
|
168
|
-
retryDelay?: number;
|
169
|
-
|
170
|
-
/**
|
171
|
-
* Connection timeout in ms (default: 10000)
|
172
|
-
*/
|
173
|
-
connectionTimeout?: number;
|
174
|
-
|
175
|
-
/**
|
176
|
-
* Auto-index creation (default: true)
|
177
|
-
*/
|
178
|
-
autoIndex?: boolean;
|
179
|
-
}
|
180
|
-
|
181
|
-
/**
|
182
|
-
* Data model structure
|
183
|
-
*/
|
184
|
-
export interface Model<T> {
|
185
|
-
/**
|
186
|
-
* Get all documents
|
187
|
-
*/
|
188
|
-
getAll: (options?: PaginationOptions) => Promise<PaginatedResult<T>>;
|
189
|
-
|
190
|
-
/**
|
191
|
-
* Get document by ID
|
192
|
-
*/
|
193
|
-
getById: (id: string) => Promise<T | null>;
|
194
|
-
|
195
|
-
/**
|
196
|
-
* Create a new document
|
197
|
-
*/
|
198
|
-
create: (data: Partial<T>) => Promise<T>;
|
199
|
-
|
200
|
-
/**
|
201
|
-
* Create multiple documents
|
202
|
-
*/
|
203
|
-
createMany: (data: Partial<T>[]) => Promise<T[]>;
|
204
|
-
|
205
|
-
/**
|
206
|
-
* Update a document
|
207
|
-
*/
|
208
|
-
update: (id: string, data: Partial<T>) => Promise<T | null>;
|
209
|
-
|
210
|
-
/**
|
211
|
-
* Delete a document
|
212
|
-
*/
|
213
|
-
delete: (id: string) => Promise<boolean>;
|
214
|
-
|
215
|
-
/**
|
216
|
-
* Find documents by custom query
|
217
|
-
*/
|
218
|
-
find: (query: Record<string, any>, options?: PaginationOptions) => Promise<PaginatedResult<T>>;
|
219
|
-
|
220
|
-
/**
|
221
|
-
* Count documents matching query
|
222
|
-
*/
|
223
|
-
count: (query?: Record<string, any>) => Promise<number>;
|
224
|
-
|
225
|
-
/**
|
226
|
-
* Find one document
|
227
|
-
*/
|
228
|
-
findOne: (query: Record<string, any>) => Promise<T | null>;
|
229
|
-
}
|
230
|
-
|
231
|
-
/**
|
232
|
-
* API response format
|
233
|
-
*/
|
234
|
-
export interface ApiResponse<T = any> {
|
235
|
-
success: boolean;
|
236
|
-
data?: T;
|
237
|
-
error?: string;
|
238
|
-
message?: string;
|
239
|
-
meta?: Record<string, any>;
|
240
|
-
}
|
241
|
-
|
242
|
-
// Extend Express Application interface
|
243
|
-
declare global {
|
244
|
-
namespace Express {
|
245
|
-
interface Application {
|
246
|
-
registerApi: (routePath: string, router: any, options?: RouterOptions) => Application;
|
247
|
-
registerSSR: (routePath: string, component: any, options?: any) => Application;
|
248
|
-
start: (callback?: () => void) => any;
|
249
|
-
connectToDatabase: (dbOptions: DatabaseOptions) => Promise<DatabaseConnector>;
|
250
|
-
}
|
251
|
-
|
252
|
-
interface Request {
|
253
|
-
user?: any;
|
254
|
-
pagination?: PaginationOptions;
|
255
|
-
}
|
256
|
-
}
|
257
|
-
}
|
package/src/batch.ts
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
export let isBatching = false;
|
2
|
-
const queue: Function[] = [];
|
3
|
-
|
4
|
-
export function batchUpdates(fn: Function) {
|
5
|
-
if (isBatching) {
|
6
|
-
queue.push(fn);
|
7
|
-
return;
|
8
|
-
}
|
9
|
-
|
10
|
-
isBatching = true;
|
11
|
-
try {
|
12
|
-
fn();
|
13
|
-
while (queue.length > 0) {
|
14
|
-
const nextFn = queue.shift();
|
15
|
-
nextFn?.();
|
16
|
-
}
|
17
|
-
} finally {
|
18
|
-
isBatching = false;
|
19
|
-
}
|
20
|
-
}
|
21
|
-
|
22
|
-
export function getIsBatching() {
|
23
|
-
return isBatching;
|
24
|
-
}
|