frontend-hamroun 1.2.9 → 1.2.10
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/dist/frontend-hamroun.es.js +182 -179
- package/dist/frontend-hamroun.umd.js +9 -9
- package/dist/index.d.ts +4 -2
- package/dist/index.js +4 -2
- package/dist/jsx-runtime/index.d.ts +4 -2
- package/dist/jsx-runtime/index.js +5 -2
- package/dist/jsx-runtime/jsx-runtime.d.ts +1 -0
- package/dist/jsx-runtime/jsx-runtime.js +4 -0
- package/package.json +1 -1
- package/src/index.ts +3 -1
- package/src/jsx-runtime/index.ts +4 -1
- package/src/jsx-runtime/jsx-runtime.ts +5 -0
- package/templates/basic-app/src/main.ts +2 -1
- package/templates/basic-app/tsconfig.json +7 -1
- package/templates/basic-app/vite.config.ts +10 -1
@@ -1,40 +1,40 @@
|
|
1
1
|
import O, { Router as ye } from "express";
|
2
2
|
import de from "path";
|
3
|
-
import
|
4
|
-
import
|
3
|
+
import Oe from "compression";
|
4
|
+
import De from "helmet";
|
5
5
|
import Pe from "morgan";
|
6
|
-
import
|
7
|
-
import
|
8
|
-
import
|
6
|
+
import j from "mongoose";
|
7
|
+
import Me from "fs";
|
8
|
+
import X from "jsonwebtoken";
|
9
9
|
import * as fe from "bcrypt";
|
10
|
-
import
|
10
|
+
import Fe from "crypto";
|
11
11
|
const he = globalThis || void 0 || self;
|
12
|
-
function
|
12
|
+
function Le(r) {
|
13
13
|
return r && r.__esModule && Object.prototype.hasOwnProperty.call(r, "default") ? r.default : r;
|
14
14
|
}
|
15
15
|
var ge = { exports: {} }, m = ge.exports = {}, k, v;
|
16
|
-
function
|
16
|
+
function re() {
|
17
17
|
throw new Error("setTimeout has not been defined");
|
18
18
|
}
|
19
|
-
function
|
19
|
+
function se() {
|
20
20
|
throw new Error("clearTimeout has not been defined");
|
21
21
|
}
|
22
22
|
(function() {
|
23
23
|
try {
|
24
|
-
typeof setTimeout == "function" ? k = setTimeout : k =
|
24
|
+
typeof setTimeout == "function" ? k = setTimeout : k = re;
|
25
25
|
} catch {
|
26
|
-
k =
|
26
|
+
k = re;
|
27
27
|
}
|
28
28
|
try {
|
29
|
-
typeof clearTimeout == "function" ? v = clearTimeout : v =
|
29
|
+
typeof clearTimeout == "function" ? v = clearTimeout : v = se;
|
30
30
|
} catch {
|
31
|
-
v =
|
31
|
+
v = se;
|
32
32
|
}
|
33
33
|
})();
|
34
34
|
function we(r) {
|
35
35
|
if (k === setTimeout)
|
36
36
|
return setTimeout(r, 0);
|
37
|
-
if ((k ===
|
37
|
+
if ((k === re || !k) && setTimeout)
|
38
38
|
return k = setTimeout, setTimeout(r, 0);
|
39
39
|
try {
|
40
40
|
return k(r, 0);
|
@@ -46,10 +46,10 @@ function we(r) {
|
|
46
46
|
}
|
47
47
|
}
|
48
48
|
}
|
49
|
-
function
|
49
|
+
function Ve(r) {
|
50
50
|
if (v === clearTimeout)
|
51
51
|
return clearTimeout(r);
|
52
|
-
if ((v ===
|
52
|
+
if ((v === se || !v) && clearTimeout)
|
53
53
|
return v = clearTimeout, clearTimeout(r);
|
54
54
|
try {
|
55
55
|
return v(r);
|
@@ -61,20 +61,20 @@ function Le(r) {
|
|
61
61
|
}
|
62
62
|
}
|
63
63
|
}
|
64
|
-
var
|
65
|
-
function
|
66
|
-
!
|
64
|
+
var x = [], P = !1, _, B = -1;
|
65
|
+
function Be() {
|
66
|
+
!P || !_ || (P = !1, _.length ? x = _.concat(x) : B = -1, x.length && Ee());
|
67
67
|
}
|
68
68
|
function Ee() {
|
69
|
-
if (!
|
70
|
-
var r = we(
|
71
|
-
|
72
|
-
for (var t =
|
73
|
-
for (_ =
|
69
|
+
if (!P) {
|
70
|
+
var r = we(Be);
|
71
|
+
P = !0;
|
72
|
+
for (var t = x.length; t; ) {
|
73
|
+
for (_ = x, x = []; ++B < t; )
|
74
74
|
_ && _[B].run();
|
75
|
-
B = -1, t =
|
75
|
+
B = -1, t = x.length;
|
76
76
|
}
|
77
|
-
_ = null,
|
77
|
+
_ = null, P = !1, Ve(r);
|
78
78
|
}
|
79
79
|
}
|
80
80
|
m.nextTick = function(r) {
|
@@ -82,7 +82,7 @@ m.nextTick = function(r) {
|
|
82
82
|
if (arguments.length > 1)
|
83
83
|
for (var e = 1; e < arguments.length; e++)
|
84
84
|
t[e - 1] = arguments[e];
|
85
|
-
|
85
|
+
x.push(new be(r, t)), x.length === 1 && !P && we(Ee);
|
86
86
|
};
|
87
87
|
function be(r, t) {
|
88
88
|
this.fun = r, this.array = t;
|
@@ -96,17 +96,17 @@ m.env = {};
|
|
96
96
|
m.argv = [];
|
97
97
|
m.version = "";
|
98
98
|
m.versions = {};
|
99
|
-
function
|
99
|
+
function A() {
|
100
100
|
}
|
101
|
-
m.on =
|
102
|
-
m.addListener =
|
103
|
-
m.once =
|
104
|
-
m.off =
|
105
|
-
m.removeListener =
|
106
|
-
m.removeAllListeners =
|
107
|
-
m.emit =
|
108
|
-
m.prependListener =
|
109
|
-
m.prependOnceListener =
|
101
|
+
m.on = A;
|
102
|
+
m.addListener = A;
|
103
|
+
m.once = A;
|
104
|
+
m.off = A;
|
105
|
+
m.removeListener = A;
|
106
|
+
m.removeAllListeners = A;
|
107
|
+
m.emit = A;
|
108
|
+
m.prependListener = A;
|
109
|
+
m.prependOnceListener = A;
|
110
110
|
m.listeners = function(r) {
|
111
111
|
return [];
|
112
112
|
};
|
@@ -122,9 +122,9 @@ m.chdir = function(r) {
|
|
122
122
|
m.umask = function() {
|
123
123
|
return 0;
|
124
124
|
};
|
125
|
-
var
|
126
|
-
const w = /* @__PURE__ */
|
127
|
-
function
|
125
|
+
var He = ge.exports;
|
126
|
+
const w = /* @__PURE__ */ Le(He), $ = typeof window < "u" ? window : typeof he < "u" ? he : {};
|
127
|
+
function J(r, t, e) {
|
128
128
|
return {
|
129
129
|
type: r,
|
130
130
|
props: t || {},
|
@@ -132,22 +132,22 @@ function ae(r, t, e) {
|
|
132
132
|
};
|
133
133
|
}
|
134
134
|
function Te(r, t, e) {
|
135
|
-
return
|
135
|
+
return J(r, t, e);
|
136
136
|
}
|
137
|
-
function
|
137
|
+
function ne(r) {
|
138
138
|
if (typeof r == "string" || typeof r == "number")
|
139
139
|
return document.createTextNode(String(r));
|
140
140
|
if (typeof r.type == "function") {
|
141
141
|
const e = r.type(r.props);
|
142
|
-
return
|
142
|
+
return ne(e);
|
143
143
|
}
|
144
144
|
const t = document.createElement(r.type);
|
145
145
|
return Object.entries(r.props || {}).forEach(([e, s]) => {
|
146
146
|
if (e === "children")
|
147
147
|
(Array.isArray(s) ? s : [s]).forEach((i) => {
|
148
148
|
if (i != null) {
|
149
|
-
const o =
|
150
|
-
w.env.NODE_ENV === "test" && typeof window < "u" && (
|
149
|
+
const o = ne(i);
|
150
|
+
w.env.NODE_ENV === "test" && typeof window < "u" && ($.__renderStats || ($.__renderStats = {
|
151
151
|
elementsCreated: 0,
|
152
152
|
textNodesCreated: 0,
|
153
153
|
eventsAttached: 0,
|
@@ -155,27 +155,27 @@ function se(r) {
|
|
155
155
|
}, typeof afterAll == "function" && afterAll(() => {
|
156
156
|
try {
|
157
157
|
const a = require("fs"), d = require("path").resolve(w.cwd(), "jsx-runtime-stats.json");
|
158
|
-
a.writeFileSync(d, JSON.stringify(
|
158
|
+
a.writeFileSync(d, JSON.stringify($.__renderStats, null, 2)), console.log(`JSX runtime stats written to ${d}`);
|
159
159
|
} catch (a) {
|
160
160
|
console.error("Failed to write stats file:", a);
|
161
161
|
}
|
162
|
-
})), o instanceof Text ?
|
162
|
+
})), o instanceof Text ? $.__renderStats.textNodesCreated++ : $.__renderStats.elementsCreated++), t.appendChild(o);
|
163
163
|
}
|
164
164
|
});
|
165
165
|
else if (e.startsWith("on")) {
|
166
166
|
const n = e.toLowerCase().substring(2);
|
167
|
-
t.addEventListener(n, s), w.env.NODE_ENV === "test" && typeof window < "u" &&
|
167
|
+
t.addEventListener(n, s), w.env.NODE_ENV === "test" && typeof window < "u" && $.__renderStats && $.__renderStats.eventsAttached++;
|
168
168
|
} else e === "className" ? t.setAttribute("class", s) : e === "style" && typeof s == "object" ? Object.entries(s).forEach(([n, i]) => {
|
169
169
|
t.style[n] = String(i);
|
170
170
|
}) : t.setAttribute(e, s);
|
171
171
|
}), t;
|
172
172
|
}
|
173
|
-
const ke = Symbol("Fragment");
|
174
|
-
typeof window < "u" && (window.jsx =
|
175
|
-
const
|
173
|
+
const ke = Symbol("Fragment"), ve = J;
|
174
|
+
typeof window < "u" && (window.jsx = J, window.jsxs = Te, window.jsxDEV = ve, window.Fragment = ke);
|
175
|
+
const We = typeof window < "u" && typeof document < "u";
|
176
176
|
async function C(r) {
|
177
177
|
var t;
|
178
|
-
if (console.log("Creating element from:", r), !
|
178
|
+
if (console.log("Creating element from:", r), !We) {
|
179
179
|
if (r == null)
|
180
180
|
return { nodeType: 3, textContent: "" };
|
181
181
|
if (typeof r == "boolean")
|
@@ -270,7 +270,7 @@ async function C(r) {
|
|
270
270
|
}
|
271
271
|
return document.createTextNode(String(r));
|
272
272
|
}
|
273
|
-
class
|
273
|
+
class Ue {
|
274
274
|
constructor(t = {}) {
|
275
275
|
this.state = {}, this.element = null, this._mounted = !1, this.props = t;
|
276
276
|
}
|
@@ -315,16 +315,16 @@ class We {
|
|
315
315
|
}
|
316
316
|
}
|
317
317
|
let H = !1;
|
318
|
-
const
|
318
|
+
const Z = [];
|
319
319
|
function ce(r) {
|
320
320
|
if (H) {
|
321
|
-
|
321
|
+
Z.push(r);
|
322
322
|
return;
|
323
323
|
}
|
324
324
|
H = !0;
|
325
325
|
try {
|
326
|
-
for (r();
|
327
|
-
const t =
|
326
|
+
for (r(); Z.length > 0; ) {
|
327
|
+
const t = Z.shift();
|
328
328
|
t == null || t();
|
329
329
|
}
|
330
330
|
} finally {
|
@@ -332,22 +332,22 @@ function ce(r) {
|
|
332
332
|
}
|
333
333
|
}
|
334
334
|
let u = 0;
|
335
|
-
const
|
336
|
-
let
|
337
|
-
const
|
338
|
-
function
|
339
|
-
|
335
|
+
const K = /* @__PURE__ */ new Map(), b = /* @__PURE__ */ new Map(), L = /* @__PURE__ */ new Map(), ee = /* @__PURE__ */ new Map(), te = /* @__PURE__ */ new Map();
|
336
|
+
let oe = null, ie = null, ae = null;
|
337
|
+
const Se = typeof window > "u", W = /* @__PURE__ */ new Map();
|
338
|
+
function xe(r, t, e) {
|
339
|
+
oe = r, ie = e, ae = t;
|
340
340
|
}
|
341
341
|
function U() {
|
342
342
|
return u++, b.set(u, 0), u;
|
343
343
|
}
|
344
344
|
function q() {
|
345
|
-
|
345
|
+
Se && W.delete(u), u = 0;
|
346
346
|
}
|
347
347
|
function Ae(r) {
|
348
348
|
if (!u)
|
349
349
|
throw new Error("useState must be called within a render");
|
350
|
-
if (
|
350
|
+
if (Se) {
|
351
351
|
W.has(u) || W.set(u, /* @__PURE__ */ new Map());
|
352
352
|
const i = W.get(u), o = b.get(u) || 0;
|
353
353
|
i.has(o) || i.set(o, r);
|
@@ -355,8 +355,8 @@ function Ae(r) {
|
|
355
355
|
};
|
356
356
|
return b.set(u, o + 1), [a, c];
|
357
357
|
}
|
358
|
-
|
359
|
-
const t =
|
358
|
+
K.has(u) || K.set(u, []);
|
359
|
+
const t = K.get(u), e = b.get(u);
|
360
360
|
e >= t.length && t.push(r);
|
361
361
|
const s = t[e], n = (i) => {
|
362
362
|
const o = typeof i == "function" ? i(t[e]) : i;
|
@@ -364,7 +364,7 @@ function Ae(r) {
|
|
364
364
|
};
|
365
365
|
return b.set(u, e + 1), [s, n];
|
366
366
|
}
|
367
|
-
function
|
367
|
+
function qe(r, t) {
|
368
368
|
if (!u) throw new Error("useEffect must be called within a render");
|
369
369
|
const e = b.get(u);
|
370
370
|
L.has(u) || L.set(u, []);
|
@@ -374,22 +374,22 @@ function Ue(r, t) {
|
|
374
374
|
s[e] = { cleanup: i, deps: t };
|
375
375
|
})), b.set(u, e + 1);
|
376
376
|
}
|
377
|
-
function
|
377
|
+
function Ge(r, t) {
|
378
378
|
if (!u) throw new Error("useMemo must be called within a render");
|
379
379
|
const e = b.get(u);
|
380
|
-
|
381
|
-
const s =
|
380
|
+
ee.has(u) || ee.set(u, []);
|
381
|
+
const s = ee.get(u), n = s[e];
|
382
382
|
if (!n || t && t.some((i, o) => !Object.is(i, n.deps[o]))) {
|
383
383
|
const i = r();
|
384
384
|
return s[e] = { value: i, deps: t }, b.set(u, e + 1), i;
|
385
385
|
}
|
386
386
|
return b.set(u, e + 1), n.value;
|
387
387
|
}
|
388
|
-
function
|
388
|
+
function Je(r) {
|
389
389
|
if (!u) throw new Error("useRef must be called within a render");
|
390
390
|
const t = b.get(u);
|
391
|
-
|
392
|
-
const e =
|
391
|
+
te.has(u) || te.set(u, []);
|
392
|
+
const e = te.get(u);
|
393
393
|
if (t >= e.length) {
|
394
394
|
const n = { current: r };
|
395
395
|
return e.push(n), b.set(u, t + 1), n;
|
@@ -402,17 +402,17 @@ async function pe(r) {
|
|
402
402
|
const t = L.get(r);
|
403
403
|
t && (t.forEach((e) => {
|
404
404
|
e.cleanup && e.cleanup();
|
405
|
-
}), L.set(r, [])),
|
405
|
+
}), L.set(r, [])), oe && ie && ae && await oe(ae, ie);
|
406
406
|
} catch (t) {
|
407
407
|
console.error("Error during rerender:", t);
|
408
408
|
}
|
409
409
|
}
|
410
|
-
function
|
410
|
+
function Qe() {
|
411
411
|
const [r, t] = Ae(null);
|
412
412
|
return [r, () => t(null)];
|
413
413
|
}
|
414
414
|
let G = !1;
|
415
|
-
async function
|
415
|
+
async function Ye(r, t) {
|
416
416
|
G = !0;
|
417
417
|
try {
|
418
418
|
await ue(r, t);
|
@@ -424,7 +424,7 @@ async function ue(r, t) {
|
|
424
424
|
console.log("Rendering to:", t.id || "unnamed-container"), ce(async () => {
|
425
425
|
const e = U();
|
426
426
|
try {
|
427
|
-
|
427
|
+
xe(ue, r, t);
|
428
428
|
const s = await C(r);
|
429
429
|
G || (t.innerHTML = ""), G && t.firstChild ? console.log("Hydrating existing DOM") : t.appendChild(s);
|
430
430
|
} finally {
|
@@ -432,21 +432,21 @@ async function ue(r, t) {
|
|
432
432
|
}
|
433
433
|
});
|
434
434
|
}
|
435
|
-
async function
|
436
|
-
U(),
|
435
|
+
async function D(r) {
|
436
|
+
U(), xe(() => {
|
437
437
|
}, r, null);
|
438
438
|
try {
|
439
439
|
if (r == null || typeof r == "boolean") return "";
|
440
440
|
if (typeof r == "number" || typeof r == "string")
|
441
441
|
return V(String(r));
|
442
442
|
if (Array.isArray(r))
|
443
|
-
return (await Promise.all(r.map(
|
443
|
+
return (await Promise.all(r.map(D))).join("");
|
444
444
|
if ("type" in r && r.props !== void 0) {
|
445
445
|
const { type: t, props: e } = r;
|
446
446
|
if (typeof t == "function")
|
447
447
|
try {
|
448
448
|
U();
|
449
|
-
const i = await t(e || {}), o = await
|
449
|
+
const i = await t(e || {}), o = await D(i);
|
450
450
|
return q(), o;
|
451
451
|
} catch (i) {
|
452
452
|
return console.error("Error rendering component:", i), "";
|
@@ -454,13 +454,13 @@ async function P(r) {
|
|
454
454
|
if (t === Symbol.for("react.fragment") || t.name === "Fragment") {
|
455
455
|
if (e.children) {
|
456
456
|
const i = Array.isArray(e.children) ? e.children : [e.children];
|
457
|
-
return (await Promise.all(i.map(
|
457
|
+
return (await Promise.all(i.map(D))).join("");
|
458
458
|
}
|
459
459
|
return "";
|
460
460
|
}
|
461
461
|
let s = `<${t}`;
|
462
462
|
for (const [i, o] of Object.entries(e || {}))
|
463
|
-
i === "children" || i === "key" || (i === "className" ? s += ` class="${V(String(o))}"` : i === "style" && typeof o == "object" ? s += ` style="${
|
463
|
+
i === "children" || i === "key" || (i === "className" ? s += ` class="${V(String(o))}"` : i === "style" && typeof o == "object" ? s += ` style="${ze(o || {})}"` : i.startsWith("on") || (s += ` ${i}="${V(String(o))}"`));
|
464
464
|
if ((/* @__PURE__ */ new Set([
|
465
465
|
"area",
|
466
466
|
"base",
|
@@ -481,7 +481,7 @@ async function P(r) {
|
|
481
481
|
if (s += ">", e != null && e.children) {
|
482
482
|
const i = Array.isArray(e.children) ? e.children : [e.children];
|
483
483
|
for (const o of i)
|
484
|
-
s += await
|
484
|
+
s += await D(o);
|
485
485
|
}
|
486
486
|
return s + `</${t}>`;
|
487
487
|
}
|
@@ -493,13 +493,13 @@ async function P(r) {
|
|
493
493
|
function V(r) {
|
494
494
|
return r.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
495
495
|
}
|
496
|
-
function Ye(r) {
|
497
|
-
return Object.entries(r).map(([t, e]) => `${ze(t)}:${e}`).join(";");
|
498
|
-
}
|
499
496
|
function ze(r) {
|
500
|
-
return r.
|
497
|
+
return Object.entries(r).map(([t, e]) => `${Xe(t)}:${e}`).join(";");
|
501
498
|
}
|
502
499
|
function Xe(r) {
|
500
|
+
return r.replace(/[A-Z]/g, (t) => "-" + t.toLowerCase());
|
501
|
+
}
|
502
|
+
function Ze(r) {
|
503
503
|
const t = {
|
504
504
|
_currentValue: r,
|
505
505
|
Provider: function({ value: s, children: n }) {
|
@@ -511,10 +511,10 @@ function Xe(r) {
|
|
511
511
|
};
|
512
512
|
return t;
|
513
513
|
}
|
514
|
-
function
|
514
|
+
function Ke(r) {
|
515
515
|
return r._currentValue;
|
516
516
|
}
|
517
|
-
class
|
517
|
+
class Ce {
|
518
518
|
// Renamed from isConnected to _connected
|
519
519
|
constructor(t) {
|
520
520
|
this.connection = null, this._connected = !1, this.options = {
|
@@ -532,11 +532,11 @@ class xe {
|
|
532
532
|
try {
|
533
533
|
if (this._connected && this.connection)
|
534
534
|
return this.connection;
|
535
|
-
|
535
|
+
j.set("strictQuery", !0);
|
536
536
|
let t = 0;
|
537
537
|
for (; t < (this.options.retryAttempts || 3); )
|
538
538
|
try {
|
539
|
-
await
|
539
|
+
await j.connect(this.options.uri, {
|
540
540
|
dbName: this.options.name,
|
541
541
|
connectTimeoutMS: this.options.connectionTimeout,
|
542
542
|
autoIndex: this.options.autoIndex,
|
@@ -548,7 +548,7 @@ class xe {
|
|
548
548
|
throw e;
|
549
549
|
console.log(`Connection attempt ${t} failed. Retrying in ${this.options.retryDelay}ms...`), await new Promise((s) => setTimeout(s, this.options.retryDelay));
|
550
550
|
}
|
551
|
-
return this.connection =
|
551
|
+
return this.connection = j.connection, this._connected = !0, console.log(`Connected to MongoDB at ${this.options.uri}/${this.options.name}`), this.connection.on("error", (e) => {
|
552
552
|
console.error("MongoDB connection error:", e), this._connected = !1;
|
553
553
|
}), this.connection.on("disconnected", () => {
|
554
554
|
console.log("MongoDB disconnected"), this._connected = !1;
|
@@ -561,7 +561,7 @@ class xe {
|
|
561
561
|
* Disconnect from the database
|
562
562
|
*/
|
563
563
|
async disconnect() {
|
564
|
-
this.connection && (await
|
564
|
+
this.connection && (await j.disconnect(), this._connected = !1, this.connection = null, console.log("Disconnected from MongoDB"));
|
565
565
|
}
|
566
566
|
/**
|
567
567
|
* Check if connected to the database
|
@@ -576,7 +576,7 @@ class xe {
|
|
576
576
|
return this.connection;
|
577
577
|
}
|
578
578
|
}
|
579
|
-
function
|
579
|
+
function et(r = {}) {
|
580
580
|
const t = O(), {
|
581
581
|
port: e = 3e3,
|
582
582
|
staticDir: s = "public",
|
@@ -590,7 +590,7 @@ function Ke(r = {}) {
|
|
590
590
|
trustProxy: E = !1,
|
591
591
|
showErrorDetails: S = w.env.NODE_ENV !== "production"
|
592
592
|
} = r;
|
593
|
-
if (E && t.set("trust proxy", E), t.use(O.json()), t.use(O.urlencoded({ extended: !0 })), c && t.use(
|
593
|
+
if (E && t.set("trust proxy", E), t.use(O.json()), t.use(O.urlencoded({ extended: !0 })), c && t.use(Oe()), d && t.use(De({
|
594
594
|
contentSecurityPolicy: r.disableCSP ? !1 : void 0
|
595
595
|
})), h && t.use(Pe(h)), n && t.use((l, p, f) => {
|
596
596
|
if (p.header("Access-Control-Allow-Origin", "*"), p.header("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, PATCH, OPTIONS"), p.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept, Authorization"), l.method === "OPTIONS")
|
@@ -598,7 +598,7 @@ function Ke(r = {}) {
|
|
598
598
|
f();
|
599
599
|
}), a.forEach((l) => t.use(l)), s) {
|
600
600
|
const l = de.resolve(w.cwd(), s);
|
601
|
-
|
601
|
+
Me.existsSync(l) ? (t.use(O.static(l, {
|
602
602
|
maxAge: r.staticCacheAge || "1d",
|
603
603
|
etag: !0
|
604
604
|
})), console.log(`📂 Serving static files from: ${l}`)) : console.warn(`⚠️ Static directory not found: ${l}`);
|
@@ -606,14 +606,14 @@ function Ke(r = {}) {
|
|
606
606
|
let y = null;
|
607
607
|
t.connectToDatabase = async (l) => {
|
608
608
|
try {
|
609
|
-
return y && y.isConnected() ? (console.log("✅ Using existing database connection"), y) : (y = new
|
609
|
+
return y && y.isConnected() ? (console.log("✅ Using existing database connection"), y) : (y = new Ce(l), await y.connect(), console.log("✅ Database connected successfully"), w.on("SIGTERM", async () => {
|
610
610
|
y && y.isConnected() && (await y.disconnect(), console.log("Database connection closed"));
|
611
611
|
}), y);
|
612
612
|
} catch (p) {
|
613
613
|
throw console.error("❌ Failed to connect to database:", p), p;
|
614
614
|
}
|
615
615
|
};
|
616
|
-
const I = {},
|
616
|
+
const I = {}, Q = {};
|
617
617
|
return t.registerApi = (l, p, f = {}) => {
|
618
618
|
try {
|
619
619
|
const { prefix: g = i } = f, T = de.posix.join(g, l).replace(/\\/g, "/");
|
@@ -622,18 +622,18 @@ function Ke(r = {}) {
|
|
622
622
|
console.error(`❌ Failed to register API at ${l}:`, g);
|
623
623
|
}
|
624
624
|
return t;
|
625
|
-
}, t.registerSSR = (l, p, f = {}) => o ? (
|
625
|
+
}, t.registerSSR = (l, p, f = {}) => o ? (Q[l] = { component: p, options: f }, t.get(l, async (g, T, Y) => {
|
626
626
|
try {
|
627
627
|
if (g.query.nossr === "true")
|
628
|
-
return
|
629
|
-
const
|
628
|
+
return Y();
|
629
|
+
const z = {
|
630
630
|
req: g,
|
631
631
|
res: T,
|
632
632
|
params: g.params,
|
633
633
|
query: g.query,
|
634
634
|
user: g.user,
|
635
635
|
...f.props
|
636
|
-
},
|
636
|
+
}, Ie = await D(p(z));
|
637
637
|
T.send(`
|
638
638
|
<!DOCTYPE html>
|
639
639
|
<html lang="${f.lang || "en"}">
|
@@ -641,7 +641,7 @@ function Ke(r = {}) {
|
|
641
641
|
<meta charset="UTF-8">
|
642
642
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
643
643
|
<title>${f.title || "Frontend Hamroun App"}</title>
|
644
|
-
${f.meta ? f.meta.map((F) => `<meta ${Object.entries(F).map(([
|
644
|
+
${f.meta ? f.meta.map((F) => `<meta ${Object.entries(F).map(([Re, Ne]) => `${Re}="${Ne}"`).join(" ")}>`).join(`
|
645
645
|
`) : ""}
|
646
646
|
${f.head || ""}
|
647
647
|
${f.styles ? `<style>${f.styles}</style>` : ""}
|
@@ -649,7 +649,7 @@ function Ke(r = {}) {
|
|
649
649
|
`) : ""}
|
650
650
|
</head>
|
651
651
|
<body ${f.bodyAttributes || ""}>
|
652
|
-
<div id="${f.rootId || "root"}">${
|
652
|
+
<div id="${f.rootId || "root"}">${Ie}</div>
|
653
653
|
<script>
|
654
654
|
window.__INITIAL_DATA__ = ${JSON.stringify(f.initialData || {})};
|
655
655
|
<\/script>
|
@@ -658,9 +658,9 @@ function Ke(r = {}) {
|
|
658
658
|
</body>
|
659
659
|
</html>
|
660
660
|
`);
|
661
|
-
} catch (
|
662
|
-
if (console.error("SSR Error:",
|
663
|
-
return
|
661
|
+
} catch (z) {
|
662
|
+
if (console.error("SSR Error:", z), f.fallback)
|
663
|
+
return Y();
|
664
664
|
T.status(500).send("Server rendering error");
|
665
665
|
}
|
666
666
|
}), console.log(`🖥️ SSR registered: ${l}`), t) : (console.log(`⚠️ SSR disabled: skipping registration of ${l}`), t), t.use((l, p, f, g) => {
|
@@ -713,9 +713,9 @@ ${Object.keys(I).length > 0 ? `
|
|
713
713
|
📡 Registered API Routes:
|
714
714
|
${Object.keys(I).map((g) => ` ${g}`).join(`
|
715
715
|
`)}` : ""}
|
716
|
-
${Object.keys(
|
716
|
+
${Object.keys(Q).length > 0 ? `
|
717
717
|
🖥️ Registered SSR Routes:
|
718
|
-
${Object.keys(
|
718
|
+
${Object.keys(Q).map((g) => ` ${g}`).join(`
|
719
719
|
`)}` : ""}
|
720
720
|
`), l && l();
|
721
721
|
}), f = async (g) => {
|
@@ -729,7 +729,7 @@ ${Object.keys(J).map((g) => ` ${g}`).join(`
|
|
729
729
|
}, t;
|
730
730
|
}
|
731
731
|
const me = fe.default || fe;
|
732
|
-
class
|
732
|
+
class tt {
|
733
733
|
constructor(t) {
|
734
734
|
if (this.loginAttempts = /* @__PURE__ */ new Map(), this.login = async (e, s) => {
|
735
735
|
try {
|
@@ -926,17 +926,17 @@ class et {
|
|
926
926
|
* Generate a cryptographically secure random token
|
927
927
|
*/
|
928
928
|
generateSecureToken(t = 32) {
|
929
|
-
return
|
929
|
+
return Fe.randomBytes(t).toString("hex");
|
930
930
|
}
|
931
931
|
/**
|
932
932
|
* Generate token pair (access token + refresh token)
|
933
933
|
*/
|
934
934
|
generateTokenPair(t) {
|
935
|
-
const e = this.getExpirationSeconds(this.options.tokenExpiration || "15m"), s =
|
935
|
+
const e = this.getExpirationSeconds(this.options.tokenExpiration || "15m"), s = X.sign(
|
936
936
|
{ ...t, type: "access" },
|
937
937
|
this.options.jwtSecret,
|
938
938
|
{ expiresIn: this.options.tokenExpiration }
|
939
|
-
), n =
|
939
|
+
), n = X.sign(
|
940
940
|
{ id: t.id, type: "refresh" },
|
941
941
|
this.options.refreshSecret,
|
942
942
|
{ expiresIn: this.options.refreshExpiration }
|
@@ -970,7 +970,7 @@ class et {
|
|
970
970
|
*/
|
971
971
|
verifyToken(t, e = "access") {
|
972
972
|
try {
|
973
|
-
const s = e === "access" ? this.options.jwtSecret : this.options.refreshSecret, n =
|
973
|
+
const s = e === "access" ? this.options.jwtSecret : this.options.refreshSecret, n = X.verify(t, s);
|
974
974
|
if (typeof n == "object" && n.type !== e)
|
975
975
|
throw new Error("Invalid token type");
|
976
976
|
return n;
|
@@ -1017,11 +1017,11 @@ class et {
|
|
1017
1017
|
return s ? e > s.resetTime ? (this.loginAttempts.set(t, { count: 1, resetTime: e + 36e5 }), !0) : s.count >= 5 ? !1 : (s.count++, this.loginAttempts.set(t, s), !0) : (this.loginAttempts.set(t, { count: 1, resetTime: e + 36e5 }), !0);
|
1018
1018
|
}
|
1019
1019
|
}
|
1020
|
-
function
|
1021
|
-
return new
|
1020
|
+
function rt(r) {
|
1021
|
+
return new tt(r);
|
1022
1022
|
}
|
1023
|
-
function
|
1024
|
-
const e =
|
1023
|
+
function st(r, t) {
|
1024
|
+
const e = j.model(r, t);
|
1025
1025
|
return {
|
1026
1026
|
getAll: async (s) => {
|
1027
1027
|
try {
|
@@ -1046,7 +1046,7 @@ function rt(r, t) {
|
|
1046
1046
|
},
|
1047
1047
|
getById: async (s) => {
|
1048
1048
|
try {
|
1049
|
-
return
|
1049
|
+
return j.isValidObjectId(s) ? await e.findById(s).exec() : null;
|
1050
1050
|
} catch (n) {
|
1051
1051
|
throw console.error(`Error in ${r}.getById:`, n), new Error(`Failed to retrieve ${r} by ID: ${n.message}`);
|
1052
1052
|
}
|
@@ -1067,7 +1067,7 @@ function rt(r, t) {
|
|
1067
1067
|
},
|
1068
1068
|
update: async (s, n) => {
|
1069
1069
|
try {
|
1070
|
-
return
|
1070
|
+
return j.isValidObjectId(s) ? await e.findByIdAndUpdate(
|
1071
1071
|
s,
|
1072
1072
|
{ $set: n },
|
1073
1073
|
{ new: !0, runValidators: !0 }
|
@@ -1078,7 +1078,7 @@ function rt(r, t) {
|
|
1078
1078
|
},
|
1079
1079
|
delete: async (s) => {
|
1080
1080
|
try {
|
1081
|
-
return
|
1081
|
+
return j.isValidObjectId(s) ? await e.findByIdAndDelete(s).exec() !== null : !1;
|
1082
1082
|
} catch (n) {
|
1083
1083
|
throw console.error(`Error in ${r}.delete:`, n), new Error(`Failed to delete ${r}: ${n.message}`);
|
1084
1084
|
}
|
@@ -1120,7 +1120,7 @@ function rt(r, t) {
|
|
1120
1120
|
}
|
1121
1121
|
};
|
1122
1122
|
}
|
1123
|
-
const
|
1123
|
+
const nt = {
|
1124
1124
|
String: { type: String },
|
1125
1125
|
Number: { type: Number },
|
1126
1126
|
Boolean: { type: Boolean },
|
@@ -1139,7 +1139,7 @@ const st = {
|
|
1139
1139
|
Default: (r, t) => ({ ...r, default: t }),
|
1140
1140
|
// Array field type
|
1141
1141
|
Array: (r) => ({ type: [r] })
|
1142
|
-
},
|
1142
|
+
}, je = (r, { res: t }) => {
|
1143
1143
|
console.error("API Error:", r);
|
1144
1144
|
const e = r.status || r.statusCode || 500, s = r.message || "Internal server error";
|
1145
1145
|
t.status(e).json({
|
@@ -1148,8 +1148,8 @@ const st = {
|
|
1148
1148
|
stack: w.env.NODE_ENV !== "production" ? r.stack : void 0
|
1149
1149
|
});
|
1150
1150
|
};
|
1151
|
-
function
|
1152
|
-
const e = O.Router(), { middleware: s = [], errorHandler: n =
|
1151
|
+
function ot(r, t = {}) {
|
1152
|
+
const e = O.Router(), { middleware: s = [], errorHandler: n = je } = t;
|
1153
1153
|
s.forEach((o) => e.use(o));
|
1154
1154
|
const i = (o) => async (a, c, d) => {
|
1155
1155
|
try {
|
@@ -1214,8 +1214,8 @@ function nt(r, t = {}) {
|
|
1214
1214
|
});
|
1215
1215
|
})), e;
|
1216
1216
|
}
|
1217
|
-
function
|
1218
|
-
const e = O.Router(), { middleware: s = [], errorHandler: n =
|
1217
|
+
function it(r, t = {}) {
|
1218
|
+
const e = O.Router(), { middleware: s = [], errorHandler: n = je } = t;
|
1219
1219
|
s.forEach((o) => e.use(o));
|
1220
1220
|
const i = (o) => async (a, c, d) => {
|
1221
1221
|
try {
|
@@ -1250,10 +1250,10 @@ function $e(r) {
|
|
1250
1250
|
const t = parseInt(r.query.page) || 1, e = parseInt(r.query.limit) || 10, s = r.query.sort || "createdAt", n = r.query.order === "asc" ? "asc" : "desc";
|
1251
1251
|
return { page: t, limit: e, sort: s, order: n };
|
1252
1252
|
}
|
1253
|
-
function
|
1253
|
+
function _e(r, t, e) {
|
1254
1254
|
r.pagination = $e(r), e();
|
1255
1255
|
}
|
1256
|
-
function
|
1256
|
+
function at(r) {
|
1257
1257
|
return (t, e, s) => {
|
1258
1258
|
try {
|
1259
1259
|
const { error: n, value: i } = r.validate(t.body);
|
@@ -1267,7 +1267,7 @@ function it(r) {
|
|
1267
1267
|
}
|
1268
1268
|
};
|
1269
1269
|
}
|
1270
|
-
function
|
1270
|
+
function ct(r = {}, t) {
|
1271
1271
|
const e = ye();
|
1272
1272
|
return r.requireAuth && t && (e.use(t.authenticate), r.requiredRole && e.use(t.hasRole(r.requiredRole))), r.rateLimit && console.warn("Rate limiting is disabled: express-rate-limit dependency is not installed"), e;
|
1273
1273
|
}
|
@@ -1276,9 +1276,9 @@ function N(r) {
|
|
1276
1276
|
r(t, e, s).catch(s);
|
1277
1277
|
};
|
1278
1278
|
}
|
1279
|
-
function
|
1279
|
+
function ut(r) {
|
1280
1280
|
const t = ye();
|
1281
|
-
return t.get("/",
|
1281
|
+
return t.get("/", _e, N(async (e, s) => {
|
1282
1282
|
const n = await r.getAll(e.pagination);
|
1283
1283
|
R(s, n);
|
1284
1284
|
})), t.get("/:id", N(async (e, s) => {
|
@@ -1300,78 +1300,81 @@ function ct(r) {
|
|
1300
1300
|
R(s, null, "Item deleted successfully");
|
1301
1301
|
})), t;
|
1302
1302
|
}
|
1303
|
-
const
|
1303
|
+
const Et = {
|
1304
1304
|
// Frontend
|
1305
|
-
jsx:
|
1305
|
+
jsx: J,
|
1306
1306
|
jsxs: Te,
|
1307
|
-
|
1307
|
+
jsxDEV: ve,
|
1308
|
+
// Add to default export
|
1309
|
+
createElement: ne,
|
1308
1310
|
Fragment: ke,
|
1309
|
-
Component:
|
1311
|
+
Component: Ue,
|
1310
1312
|
useState: Ae,
|
1311
|
-
useEffect:
|
1312
|
-
useRef:
|
1313
|
-
useMemo:
|
1314
|
-
useErrorBoundary:
|
1313
|
+
useEffect: qe,
|
1314
|
+
useRef: Je,
|
1315
|
+
useMemo: Ge,
|
1316
|
+
useErrorBoundary: Qe,
|
1315
1317
|
render: ue,
|
1316
|
-
hydrate:
|
1317
|
-
renderToString:
|
1318
|
+
hydrate: Ye,
|
1319
|
+
renderToString: D,
|
1318
1320
|
prepareRender: U,
|
1319
1321
|
finishRender: q,
|
1320
1322
|
batchUpdates: ce,
|
1321
|
-
createContext:
|
1322
|
-
useContext:
|
1323
|
+
createContext: Ze,
|
1324
|
+
useContext: Ke,
|
1323
1325
|
// Backend
|
1324
|
-
createServer:
|
1325
|
-
createAuth:
|
1326
|
-
createModel:
|
1327
|
-
FieldTypes:
|
1328
|
-
createModelRouter:
|
1329
|
-
createCustomRouter:
|
1330
|
-
createApiRouter:
|
1326
|
+
createServer: et,
|
1327
|
+
createAuth: rt,
|
1328
|
+
createModel: st,
|
1329
|
+
FieldTypes: nt,
|
1330
|
+
createModelRouter: ot,
|
1331
|
+
createCustomRouter: it,
|
1332
|
+
createApiRouter: ct,
|
1331
1333
|
sendSuccess: R,
|
1332
1334
|
sendError: M,
|
1333
1335
|
apiResponse: le,
|
1334
1336
|
getPaginationParams: $e,
|
1335
|
-
paginationMiddleware:
|
1336
|
-
validateRequest:
|
1337
|
+
paginationMiddleware: _e,
|
1338
|
+
validateRequest: at,
|
1337
1339
|
asyncHandler: N,
|
1338
|
-
createRestEndpoints:
|
1339
|
-
DatabaseConnector:
|
1340
|
+
createRestEndpoints: ut,
|
1341
|
+
DatabaseConnector: Ce
|
1340
1342
|
};
|
1341
1343
|
export {
|
1342
|
-
|
1343
|
-
|
1344
|
-
|
1344
|
+
Ue as Component,
|
1345
|
+
Ce as DatabaseConnector,
|
1346
|
+
nt as FieldTypes,
|
1345
1347
|
ke as Fragment,
|
1346
1348
|
le as apiResponse,
|
1347
1349
|
N as asyncHandler,
|
1348
1350
|
ce as batchUpdates,
|
1349
|
-
|
1350
|
-
|
1351
|
-
|
1352
|
-
|
1353
|
-
|
1354
|
-
|
1355
|
-
|
1356
|
-
|
1357
|
-
|
1358
|
-
|
1351
|
+
ct as createApiRouter,
|
1352
|
+
rt as createAuth,
|
1353
|
+
Ze as createContext,
|
1354
|
+
it as createCustomRouter,
|
1355
|
+
ne as createElement,
|
1356
|
+
st as createModel,
|
1357
|
+
ot as createModelRouter,
|
1358
|
+
ut as createRestEndpoints,
|
1359
|
+
et as createServer,
|
1360
|
+
Et as default,
|
1359
1361
|
q as finishRender,
|
1360
1362
|
$e as getPaginationParams,
|
1361
|
-
|
1362
|
-
|
1363
|
+
Ye as hydrate,
|
1364
|
+
J as jsx,
|
1365
|
+
ve as jsxDEV,
|
1363
1366
|
Te as jsxs,
|
1364
|
-
|
1367
|
+
_e as paginationMiddleware,
|
1365
1368
|
U as prepareRender,
|
1366
1369
|
ue as render,
|
1367
|
-
|
1370
|
+
D as renderToString,
|
1368
1371
|
M as sendError,
|
1369
1372
|
R as sendSuccess,
|
1370
|
-
|
1371
|
-
|
1372
|
-
|
1373
|
-
|
1374
|
-
|
1373
|
+
Ke as useContext,
|
1374
|
+
qe as useEffect,
|
1375
|
+
Qe as useErrorBoundary,
|
1376
|
+
Ge as useMemo,
|
1377
|
+
Je as useRef,
|
1375
1378
|
Ae as useState,
|
1376
|
-
|
1379
|
+
at as validateRequest
|
1377
1380
|
};
|
@@ -1,27 +1,27 @@
|
|
1
|
-
(function(a,v){typeof exports=="object"&&typeof module<"u"?v(exports,require("express"),require("path"),require("compression"),require("helmet"),require("morgan"),require("mongoose"),require("fs"),require("jsonwebtoken"),require("bcrypt"),require("crypto")):typeof define=="function"&&define.amd?define(["exports","express","path","compression","helmet","morgan","mongoose","fs","jsonwebtoken","bcrypt","crypto"],v):(a=typeof globalThis<"u"?globalThis:a||self,v(a["frontend-hamroun"]={},a.express,a.path,a.compression,a.helmet,a.morgan,a.mongoose,a.fs,a.jwt,a.bcrypt,a.crypto))})(this,function(a,v,we,Je,ze,Qe,$,Ye,K,Xe,Ze){"use strict";function Ke(r){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const e in r)if(e!=="default"){const n=Object.getOwnPropertyDescriptor(r,e);Object.defineProperty(t,e,n.get?n:{enumerable:!0,get:()=>r[e]})}}return t.default=r,Object.freeze(t)}const Ee=Ke(Xe),be=globalThis||void 0||self;function et(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var Te={exports:{}},y=Te.exports={},k,A;function ee(){throw new Error("setTimeout has not been defined")}function te(){throw new Error("clearTimeout has not been defined")}(function(){try{typeof setTimeout=="function"?k=setTimeout:k=ee}catch{k=ee}try{typeof clearTimeout=="function"?A=clearTimeout:A=te}catch{A=te}})();function ve(r){if(k===setTimeout)return setTimeout(r,0);if((k===ee||!k)&&setTimeout)return k=setTimeout,setTimeout(r,0);try{return k(r,0)}catch{try{return k.call(null,r,0)}catch{return k.call(this,r,0)}}}function tt(r){if(A===clearTimeout)return clearTimeout(r);if((A===te||!A)&&clearTimeout)return A=clearTimeout,clearTimeout(r);try{return A(r)}catch{try{return A.call(null,r)}catch{return A.call(this,r)}}}var C=[],M=!1,R,q=-1;function rt(){!M||!R||(M=!1,R.length?C=R.concat(C):q=-1,C.length&&Se())}function Se(){if(!M){var r=ve(rt);M=!0;for(var t=C.length;t;){for(R=C,C=[];++q<t;)R&&R[q].run();q=-1,t=C.length}R=null,M=!1,tt(r)}}y.nextTick=function(r){var t=new Array(arguments.length-1);if(arguments.length>1)for(var e=1;e<arguments.length;e++)t[e-1]=arguments[e];C.push(new ke(r,t)),C.length===1&&!M&&ve(Se)};function ke(r,t){this.fun=r,this.array=t}ke.prototype.run=function(){this.fun.apply(null,this.array)},y.title="browser",y.browser=!0,y.env={},y.argv=[],y.version="",y.versions={};function j(){}y.on=j,y.addListener=j,y.once=j,y.off=j,y.removeListener=j,y.removeAllListeners=j,y.emit=j,y.prependListener=j,y.prependOnceListener=j,y.listeners=function(r){return[]},y.binding=function(r){throw new Error("process.binding is not supported")},y.cwd=function(){return"/"},y.chdir=function(r){throw new Error("process.chdir is not supported")},y.umask=function(){return 0};var nt=Te.exports;const E=et(nt),O=typeof window<"u"?window:typeof be<"u"?be:{};function W(r,t,e){return{type:r,props:t||{},key:e}}function re(r,t,e){return W(r,t,e)}function U(r){if(typeof r=="string"||typeof r=="number")return document.createTextNode(String(r));if(typeof r.type=="function"){const e=r.type(r.props);return U(e)}const t=document.createElement(r.type);return Object.entries(r.props||{}).forEach(([e,n])=>{if(e==="children")(Array.isArray(n)?n:[n]).forEach(i=>{if(i!=null){const o=U(i);E.env.NODE_ENV==="test"&&typeof window<"u"&&(O.__renderStats||(O.__renderStats={elementsCreated:0,textNodesCreated:0,eventsAttached:0,renderTime:0},typeof afterAll=="function"&&afterAll(()=>{try{const c=require("fs"),f=require("path").resolve(E.cwd(),"jsx-runtime-stats.json");c.writeFileSync(f,JSON.stringify(O.__renderStats,null,2)),console.log(`JSX runtime stats written to ${f}`)}catch(c){console.error("Failed to write stats file:",c)}})),o instanceof Text?O.__renderStats.textNodesCreated++:O.__renderStats.elementsCreated++),t.appendChild(o)}});else if(e.startsWith("on")){const s=e.toLowerCase().substring(2);t.addEventListener(s,n),E.env.NODE_ENV==="test"&&typeof window<"u"&&O.__renderStats&&O.__renderStats.eventsAttached++}else e==="className"?t.setAttribute("class",n):e==="style"&&typeof n=="object"?Object.entries(n).forEach(([s,i])=>{t.style[s]=String(i)}):t.setAttribute(e,n)}),t}const ne=Symbol("Fragment");typeof window<"u"&&(window.jsx=W,window.jsxs=re,window.Fragment=ne);const st=typeof window<"u"&&typeof document<"u";async function I(r){var t;if(console.log("Creating element from:",r),!st){if(r==null)return{nodeType:3,textContent:""};if(typeof r=="boolean")return{nodeType:3,textContent:""};if(typeof r=="number"||typeof r=="string")return{nodeType:3,textContent:String(r)};if(Array.isArray(r)){const e={nodeType:11,childNodes:[]};for(const n of r){const s=await I(n);e.childNodes.push(s)}return e}if("type"in r&&r.props!==void 0){const{type:e,props:n}=r;if(typeof e=="function")try{const o=await e(n||{});return await I(o)}catch(o){return console.error("Error rendering component:",o),{nodeType:3,textContent:""}}const s={nodeType:1,tagName:e,attributes:{},style:{},childNodes:[],setAttribute:function(o,c){this.attributes[o]=c},appendChild:function(o){this.childNodes.push(o)}};for(const[o,c]of Object.entries(n||{}))if(o!=="children")if(o.startsWith("on")&&typeof c=="function"){const u=o.toLowerCase().slice(2);s.__events||(s.__events={}),s.__events[u]=c}else o==="style"&&typeof c=="object"?Object.assign(s.style,c):o==="className"?s.setAttribute("class",String(c)):o!=="key"&&o!=="ref"&&s.setAttribute(o,String(c));const i=n==null?void 0:n.children;if(i!=null){const o=Array.isArray(i)?i.flat():[i];for(const c of o){const u=await I(c);s.appendChild(u)}}return s}return{nodeType:3,textContent:String(r)}}if(r==null||typeof r=="boolean")return document.createTextNode("");if(typeof r=="number"||typeof r=="string")return document.createTextNode(String(r));if(Array.isArray(r)){const e=document.createDocumentFragment();for(const n of r){const s=await I(n);e.appendChild(s)}return e}if("type"in r&&r.props!==void 0){const{type:e,props:n}=r;if(typeof e=="function")try{const o=await e(n||{}),c=await I(o);return c instanceof Element&&c.setAttribute("data-component-id",e.name||e.toString()),c}catch(o){return console.error("Error rendering component:",o),document.createTextNode("")}const s=document.createElement(e);for(const[o,c]of Object.entries(n||{}))if(o!=="children")if(o.startsWith("on")&&typeof c=="function"){const u=o.toLowerCase().slice(2),f=(t=s.__events)==null?void 0:t[u];f&&s.removeEventListener(u,f),s.addEventListener(u,c),s.__events||(s.__events={}),s.__events[u]=c}else o==="style"&&typeof c=="object"?Object.assign(s.style,c):o==="className"?s.setAttribute("class",String(c)):o!=="key"&&o!=="ref"&&s.setAttribute(o,String(c));const i=n==null?void 0:n.children;if(i!=null){const o=Array.isArray(i)?i.flat():[i];for(const c of o){const u=await I(c);s.appendChild(u)}}return s}return document.createTextNode(String(r))}class Ae{constructor(t={}){this.state={},this.element=null,this._mounted=!1,this.props=t}componentDidMount(){}async setState(t){const e={...this.state};this.state={...e,...t},console.log(`${this.constructor.name} state updated:`,{prev:e,next:this.state}),await Promise.resolve(),this._mounted?await this.update():await this.update()}_replayEvents(t,e){const n=t.__events||{};Object.entries(n).forEach(([s,i])=>{e.addEventListener(s,i)}),e.__events=n}_deepCloneWithEvents(t){const e=t.cloneNode(!1),n=t.__events||{};return e.__events=n,Object.entries(n).forEach(([s,i])=>{e.addEventListener(s,i)}),Array.from(t.childNodes).forEach(s=>{s instanceof HTMLElement?e.appendChild(this._deepCloneWithEvents(s)):e.appendChild(s.cloneNode(!0))}),e}async update(){const t=this.render();if(!t)return document.createTextNode("");const e=await I(t);if(e instanceof HTMLElement)return this._updateElement(e);const n=document.createElement("div");return n.appendChild(e),this._updateElement(n)}async _updateElement(t){const e=this._deepCloneWithEvents(t);return e.__instance=this,this.element?this.element.parentNode&&(this.element.parentNode.replaceChild(e,this.element),this.element=e):(this.element=e,this._mounted||(this._mounted=!0,queueMicrotask(()=>this.componentDidMount()))),this.element}render(){throw new Error("Component must implement render() method")}}let G=!1;const se=[];function J(r){if(G){se.push(r);return}G=!0;try{for(r();se.length>0;){const t=se.shift();t==null||t()}}finally{G=!1}}let l=0;const oe=new Map,T=new Map,L=new Map,ie=new Map,ce=new Map;let ae=null,ue=null,le=null;const Ce=typeof window>"u",z=new Map;function je(r,t,e){ae=r,ue=e,le=t}function B(){return l++,T.set(l,0),l}function V(){Ce&&z.delete(l),l=0}function de(r){if(!l)throw new Error("useState must be called within a render");if(Ce){z.has(l)||z.set(l,new Map);const i=z.get(l),o=T.get(l)||0;i.has(o)||i.set(o,r);const c=i.get(o),u=f=>{};return T.set(l,o+1),[c,u]}oe.has(l)||oe.set(l,[]);const t=oe.get(l),e=T.get(l);e>=t.length&&t.push(r);const n=t[e],s=i=>{const o=typeof i=="function"?i(t[e]):i;t[e]!==o&&(t[e]=o,G?J(()=>Re(l)):Re(l))};return T.set(l,e+1),[n,s]}function _e(r,t){if(!l)throw new Error("useEffect must be called within a render");const e=T.get(l);L.has(l)||L.set(l,[]);const n=L.get(l),s=n[e];(!s||!t||!s.deps||t.some((i,o)=>i!==s.deps[o]))&&(s!=null&&s.cleanup&&s.cleanup(),queueMicrotask(()=>{const i=r()||void 0;n[e]={cleanup:i,deps:t}})),T.set(l,e+1)}function $e(r,t){if(!l)throw new Error("useMemo must be called within a render");const e=T.get(l);ie.has(l)||ie.set(l,[]);const n=ie.get(l),s=n[e];if(!s||t&&t.some((i,o)=>!Object.is(i,s.deps[o]))){const i=r();return n[e]={value:i,deps:t},T.set(l,e+1),i}return T.set(l,e+1),s.value}function Ie(r){if(!l)throw new Error("useRef must be called within a render");const t=T.get(l);ce.has(l)||ce.set(l,[]);const e=ce.get(l);if(t>=e.length){const s={current:r};return e.push(s),T.set(l,t+1),s}const n=e[t];return T.set(l,t+1),n}async function Re(r){try{const t=L.get(r);t&&(t.forEach(e=>{e.cleanup&&e.cleanup()}),L.set(r,[])),ae&&ue&&le&&await ae(le,ue)}catch(t){console.error("Error during rerender:",t)}}function Oe(){const[r,t]=de(null);return[r,()=>t(null)]}let Q=!1;async function xe(r,t){Q=!0;try{await Y(r,t)}finally{Q=!1}}async function Y(r,t){console.log("Rendering to:",t.id||"unnamed-container"),J(async()=>{const e=B();try{je(Y,r,t);const n=await I(r);Q||(t.innerHTML=""),Q&&t.firstChild?console.log("Hydrating existing DOM"):t.appendChild(n)}finally{V()}})}async function x(r){B(),je(()=>{},r,null);try{if(r==null||typeof r=="boolean")return"";if(typeof r=="number"||typeof r=="string")return X(String(r));if(Array.isArray(r))return(await Promise.all(r.map(x))).join("");if("type"in r&&r.props!==void 0){const{type:t,props:e}=r;if(typeof t=="function")try{B();const i=await t(e||{}),o=await x(i);return V(),o}catch(i){return console.error("Error rendering component:",i),""}if(t===Symbol.for("react.fragment")||t.name==="Fragment"){if(e.children){const i=Array.isArray(e.children)?e.children:[e.children];return(await Promise.all(i.map(x))).join("")}return""}let n=`<${t}`;for(const[i,o]of Object.entries(e||{}))i==="children"||i==="key"||(i==="className"?n+=` class="${X(String(o))}"`:i==="style"&&typeof o=="object"?n+=` style="${ot(o||{})}"`:i.startsWith("on")||(n+=` ${i}="${X(String(o))}"`));if(new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]).has(t))return n+"/>";if(n+=">",e!=null&&e.children){const i=Array.isArray(e.children)?e.children:[e.children];for(const o of i)n+=await x(o)}return n+`</${t}>`}return X(String(r))}finally{V()}}function X(r){return r.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function ot(r){return Object.entries(r).map(([t,e])=>`${it(t)}:${e}`).join(";")}function it(r){return r.replace(/[A-Z]/g,t=>"-"+t.toLowerCase())}function Ne(r){const t={_currentValue:r,Provider:function({value:n,children:s}){return t._currentValue=n,s},Consumer:function({children:n}){return n(t._currentValue)}};return t}function Pe(r){return r._currentValue}class fe{constructor(t){this.connection=null,this._connected=!1,this.options={retryAttempts:3,retryDelay:1e3,connectionTimeout:1e4,autoIndex:!0,...t}}async connect(){try{if(this._connected&&this.connection)return this.connection;$.set("strictQuery",!0);let t=0;for(;t<(this.options.retryAttempts||3);)try{await $.connect(this.options.uri,{dbName:this.options.name,connectTimeoutMS:this.options.connectionTimeout,autoIndex:this.options.autoIndex,...this.options.options});break}catch(e){if(t++,t>=(this.options.retryAttempts||3))throw e;console.log(`Connection attempt ${t} failed. Retrying in ${this.options.retryDelay}ms...`),await new Promise(n=>setTimeout(n,this.options.retryDelay))}return this.connection=$.connection,this._connected=!0,console.log(`Connected to MongoDB at ${this.options.uri}/${this.options.name}`),this.connection.on("error",e=>{console.error("MongoDB connection error:",e),this._connected=!1}),this.connection.on("disconnected",()=>{console.log("MongoDB disconnected"),this._connected=!1}),this.connection}catch(t){throw console.error("Failed to connect to MongoDB:",t),t}}async disconnect(){this.connection&&(await $.disconnect(),this._connected=!1,this.connection=null,console.log("Disconnected from MongoDB"))}isConnected(){return this._connected}getConnection(){return this.connection}}function De(r={}){const t=v(),{port:e=3e3,staticDir:n="public",enableCors:s=!0,apiPrefix:i="/api",ssrEnabled:o=!0,middlewares:c=[],enableCompression:u=!0,enableHelmet:f=!0,logFormat:p="dev",trustProxy:b=!1,showErrorDetails:_=E.env.NODE_ENV!=="production"}=r;if(b&&t.set("trust proxy",b),t.use(v.json()),t.use(v.urlencoded({extended:!0})),u&&t.use(Je()),f&&t.use(ze({contentSecurityPolicy:r.disableCSP?!1:void 0})),p&&t.use(Qe(p)),s&&t.use((d,m,h)=>{if(m.header("Access-Control-Allow-Origin","*"),m.header("Access-Control-Allow-Methods","GET, POST, PUT, DELETE, PATCH, OPTIONS"),m.header("Access-Control-Allow-Headers","Origin, X-Requested-With, Content-Type, Accept, Authorization"),d.method==="OPTIONS")return m.sendStatus(200);h()}),c.forEach(d=>t.use(d)),n){const d=we.resolve(E.cwd(),n);Ye.existsSync(d)?(t.use(v.static(d,{maxAge:r.staticCacheAge||"1d",etag:!0})),console.log(`📂 Serving static files from: ${d}`)):console.warn(`⚠️ Static directory not found: ${d}`)}let g=null;t.connectToDatabase=async d=>{try{return g&&g.isConnected()?(console.log("✅ Using existing database connection"),g):(g=new fe(d),await g.connect(),console.log("✅ Database connected successfully"),E.on("SIGTERM",async()=>{g&&g.isConnected()&&(await g.disconnect(),console.log("Database connection closed"))}),g)}catch(m){throw console.error("❌ Failed to connect to database:",m),m}};const F={},ye={};return t.registerApi=(d,m,h={})=>{try{const{prefix:w=i}=h,S=we.posix.join(w,d).replace(/\\/g,"/");t.use(S,m),F[S]={router:m,options:h},console.log(`🔌 API registered: ${S}`)}catch(w){console.error(`❌ Failed to register API at ${d}:`,w)}return t},t.registerSSR=(d,m,h={})=>o?(ye[d]={component:m,options:h},t.get(d,async(w,S,me)=>{try{if(w.query.nossr==="true")return me();const ge={req:w,res:S,params:w.params,query:w.query,user:w.user,...h.props},ut=await x(m(ge));S.send(`
|
1
|
+
(function(a,v){typeof exports=="object"&&typeof module<"u"?v(exports,require("express"),require("path"),require("compression"),require("helmet"),require("morgan"),require("mongoose"),require("fs"),require("jsonwebtoken"),require("bcrypt"),require("crypto")):typeof define=="function"&&define.amd?define(["exports","express","path","compression","helmet","morgan","mongoose","fs","jsonwebtoken","bcrypt","crypto"],v):(a=typeof globalThis<"u"?globalThis:a||self,v(a["frontend-hamroun"]={},a.express,a.path,a.compression,a.helmet,a.morgan,a.mongoose,a.fs,a.jwt,a.bcrypt,a.crypto))})(this,function(a,v,Ee,ze,Qe,Ye,$,Xe,K,Ze,Ke){"use strict";function et(r){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const e in r)if(e!=="default"){const n=Object.getOwnPropertyDescriptor(r,e);Object.defineProperty(t,e,n.get?n:{enumerable:!0,get:()=>r[e]})}}return t.default=r,Object.freeze(t)}const be=et(Ze),Te=globalThis||void 0||self;function tt(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var ve={exports:{}},y=ve.exports={},k,A;function ee(){throw new Error("setTimeout has not been defined")}function te(){throw new Error("clearTimeout has not been defined")}(function(){try{typeof setTimeout=="function"?k=setTimeout:k=ee}catch{k=ee}try{typeof clearTimeout=="function"?A=clearTimeout:A=te}catch{A=te}})();function Se(r){if(k===setTimeout)return setTimeout(r,0);if((k===ee||!k)&&setTimeout)return k=setTimeout,setTimeout(r,0);try{return k(r,0)}catch{try{return k.call(null,r,0)}catch{return k.call(this,r,0)}}}function rt(r){if(A===clearTimeout)return clearTimeout(r);if((A===te||!A)&&clearTimeout)return A=clearTimeout,clearTimeout(r);try{return A(r)}catch{try{return A.call(null,r)}catch{return A.call(this,r)}}}var j=[],M=!1,R,W=-1;function nt(){!M||!R||(M=!1,R.length?j=R.concat(j):W=-1,j.length&&ke())}function ke(){if(!M){var r=Se(nt);M=!0;for(var t=j.length;t;){for(R=j,j=[];++W<t;)R&&R[W].run();W=-1,t=j.length}R=null,M=!1,rt(r)}}y.nextTick=function(r){var t=new Array(arguments.length-1);if(arguments.length>1)for(var e=1;e<arguments.length;e++)t[e-1]=arguments[e];j.push(new Ae(r,t)),j.length===1&&!M&&Se(ke)};function Ae(r,t){this.fun=r,this.array=t}Ae.prototype.run=function(){this.fun.apply(null,this.array)},y.title="browser",y.browser=!0,y.env={},y.argv=[],y.version="",y.versions={};function C(){}y.on=C,y.addListener=C,y.once=C,y.off=C,y.removeListener=C,y.removeAllListeners=C,y.emit=C,y.prependListener=C,y.prependOnceListener=C,y.listeners=function(r){return[]},y.binding=function(r){throw new Error("process.binding is not supported")},y.cwd=function(){return"/"},y.chdir=function(r){throw new Error("process.chdir is not supported")},y.umask=function(){return 0};var st=ve.exports;const E=tt(st),x=typeof window<"u"?window:typeof Te<"u"?Te:{};function L(r,t,e){return{type:r,props:t||{},key:e}}function re(r,t,e){return L(r,t,e)}function U(r){if(typeof r=="string"||typeof r=="number")return document.createTextNode(String(r));if(typeof r.type=="function"){const e=r.type(r.props);return U(e)}const t=document.createElement(r.type);return Object.entries(r.props||{}).forEach(([e,n])=>{if(e==="children")(Array.isArray(n)?n:[n]).forEach(i=>{if(i!=null){const o=U(i);E.env.NODE_ENV==="test"&&typeof window<"u"&&(x.__renderStats||(x.__renderStats={elementsCreated:0,textNodesCreated:0,eventsAttached:0,renderTime:0},typeof afterAll=="function"&&afterAll(()=>{try{const c=require("fs"),f=require("path").resolve(E.cwd(),"jsx-runtime-stats.json");c.writeFileSync(f,JSON.stringify(x.__renderStats,null,2)),console.log(`JSX runtime stats written to ${f}`)}catch(c){console.error("Failed to write stats file:",c)}})),o instanceof Text?x.__renderStats.textNodesCreated++:x.__renderStats.elementsCreated++),t.appendChild(o)}});else if(e.startsWith("on")){const s=e.toLowerCase().substring(2);t.addEventListener(s,n),E.env.NODE_ENV==="test"&&typeof window<"u"&&x.__renderStats&&x.__renderStats.eventsAttached++}else e==="className"?t.setAttribute("class",n):e==="style"&&typeof n=="object"?Object.entries(n).forEach(([s,i])=>{t.style[s]=String(i)}):t.setAttribute(e,n)}),t}const ne=Symbol("Fragment"),se=L;typeof window<"u"&&(window.jsx=L,window.jsxs=re,window.jsxDEV=se,window.Fragment=ne);const ot=typeof window<"u"&&typeof document<"u";async function I(r){var t;if(console.log("Creating element from:",r),!ot){if(r==null)return{nodeType:3,textContent:""};if(typeof r=="boolean")return{nodeType:3,textContent:""};if(typeof r=="number"||typeof r=="string")return{nodeType:3,textContent:String(r)};if(Array.isArray(r)){const e={nodeType:11,childNodes:[]};for(const n of r){const s=await I(n);e.childNodes.push(s)}return e}if("type"in r&&r.props!==void 0){const{type:e,props:n}=r;if(typeof e=="function")try{const o=await e(n||{});return await I(o)}catch(o){return console.error("Error rendering component:",o),{nodeType:3,textContent:""}}const s={nodeType:1,tagName:e,attributes:{},style:{},childNodes:[],setAttribute:function(o,c){this.attributes[o]=c},appendChild:function(o){this.childNodes.push(o)}};for(const[o,c]of Object.entries(n||{}))if(o!=="children")if(o.startsWith("on")&&typeof c=="function"){const u=o.toLowerCase().slice(2);s.__events||(s.__events={}),s.__events[u]=c}else o==="style"&&typeof c=="object"?Object.assign(s.style,c):o==="className"?s.setAttribute("class",String(c)):o!=="key"&&o!=="ref"&&s.setAttribute(o,String(c));const i=n==null?void 0:n.children;if(i!=null){const o=Array.isArray(i)?i.flat():[i];for(const c of o){const u=await I(c);s.appendChild(u)}}return s}return{nodeType:3,textContent:String(r)}}if(r==null||typeof r=="boolean")return document.createTextNode("");if(typeof r=="number"||typeof r=="string")return document.createTextNode(String(r));if(Array.isArray(r)){const e=document.createDocumentFragment();for(const n of r){const s=await I(n);e.appendChild(s)}return e}if("type"in r&&r.props!==void 0){const{type:e,props:n}=r;if(typeof e=="function")try{const o=await e(n||{}),c=await I(o);return c instanceof Element&&c.setAttribute("data-component-id",e.name||e.toString()),c}catch(o){return console.error("Error rendering component:",o),document.createTextNode("")}const s=document.createElement(e);for(const[o,c]of Object.entries(n||{}))if(o!=="children")if(o.startsWith("on")&&typeof c=="function"){const u=o.toLowerCase().slice(2),f=(t=s.__events)==null?void 0:t[u];f&&s.removeEventListener(u,f),s.addEventListener(u,c),s.__events||(s.__events={}),s.__events[u]=c}else o==="style"&&typeof c=="object"?Object.assign(s.style,c):o==="className"?s.setAttribute("class",String(c)):o!=="key"&&o!=="ref"&&s.setAttribute(o,String(c));const i=n==null?void 0:n.children;if(i!=null){const o=Array.isArray(i)?i.flat():[i];for(const c of o){const u=await I(c);s.appendChild(u)}}return s}return document.createTextNode(String(r))}class je{constructor(t={}){this.state={},this.element=null,this._mounted=!1,this.props=t}componentDidMount(){}async setState(t){const e={...this.state};this.state={...e,...t},console.log(`${this.constructor.name} state updated:`,{prev:e,next:this.state}),await Promise.resolve(),this._mounted?await this.update():await this.update()}_replayEvents(t,e){const n=t.__events||{};Object.entries(n).forEach(([s,i])=>{e.addEventListener(s,i)}),e.__events=n}_deepCloneWithEvents(t){const e=t.cloneNode(!1),n=t.__events||{};return e.__events=n,Object.entries(n).forEach(([s,i])=>{e.addEventListener(s,i)}),Array.from(t.childNodes).forEach(s=>{s instanceof HTMLElement?e.appendChild(this._deepCloneWithEvents(s)):e.appendChild(s.cloneNode(!0))}),e}async update(){const t=this.render();if(!t)return document.createTextNode("");const e=await I(t);if(e instanceof HTMLElement)return this._updateElement(e);const n=document.createElement("div");return n.appendChild(e),this._updateElement(n)}async _updateElement(t){const e=this._deepCloneWithEvents(t);return e.__instance=this,this.element?this.element.parentNode&&(this.element.parentNode.replaceChild(e,this.element),this.element=e):(this.element=e,this._mounted||(this._mounted=!0,queueMicrotask(()=>this.componentDidMount()))),this.element}render(){throw new Error("Component must implement render() method")}}let G=!1;const oe=[];function J(r){if(G){oe.push(r);return}G=!0;try{for(r();oe.length>0;){const t=oe.shift();t==null||t()}}finally{G=!1}}let l=0;const ie=new Map,T=new Map,V=new Map,ce=new Map,ae=new Map;let ue=null,le=null,de=null;const Ce=typeof window>"u",z=new Map;function _e(r,t,e){ue=r,le=e,de=t}function B(){return l++,T.set(l,0),l}function H(){Ce&&z.delete(l),l=0}function fe(r){if(!l)throw new Error("useState must be called within a render");if(Ce){z.has(l)||z.set(l,new Map);const i=z.get(l),o=T.get(l)||0;i.has(o)||i.set(o,r);const c=i.get(o),u=f=>{};return T.set(l,o+1),[c,u]}ie.has(l)||ie.set(l,[]);const t=ie.get(l),e=T.get(l);e>=t.length&&t.push(r);const n=t[e],s=i=>{const o=typeof i=="function"?i(t[e]):i;t[e]!==o&&(t[e]=o,G?J(()=>xe(l)):xe(l))};return T.set(l,e+1),[n,s]}function $e(r,t){if(!l)throw new Error("useEffect must be called within a render");const e=T.get(l);V.has(l)||V.set(l,[]);const n=V.get(l),s=n[e];(!s||!t||!s.deps||t.some((i,o)=>i!==s.deps[o]))&&(s!=null&&s.cleanup&&s.cleanup(),queueMicrotask(()=>{const i=r()||void 0;n[e]={cleanup:i,deps:t}})),T.set(l,e+1)}function Ie(r,t){if(!l)throw new Error("useMemo must be called within a render");const e=T.get(l);ce.has(l)||ce.set(l,[]);const n=ce.get(l),s=n[e];if(!s||t&&t.some((i,o)=>!Object.is(i,s.deps[o]))){const i=r();return n[e]={value:i,deps:t},T.set(l,e+1),i}return T.set(l,e+1),s.value}function Re(r){if(!l)throw new Error("useRef must be called within a render");const t=T.get(l);ae.has(l)||ae.set(l,[]);const e=ae.get(l);if(t>=e.length){const s={current:r};return e.push(s),T.set(l,t+1),s}const n=e[t];return T.set(l,t+1),n}async function xe(r){try{const t=V.get(r);t&&(t.forEach(e=>{e.cleanup&&e.cleanup()}),V.set(r,[])),ue&&le&&de&&await ue(de,le)}catch(t){console.error("Error during rerender:",t)}}function Oe(){const[r,t]=fe(null);return[r,()=>t(null)]}let Q=!1;async function Ne(r,t){Q=!0;try{await Y(r,t)}finally{Q=!1}}async function Y(r,t){console.log("Rendering to:",t.id||"unnamed-container"),J(async()=>{const e=B();try{_e(Y,r,t);const n=await I(r);Q||(t.innerHTML=""),Q&&t.firstChild?console.log("Hydrating existing DOM"):t.appendChild(n)}finally{H()}})}async function O(r){B(),_e(()=>{},r,null);try{if(r==null||typeof r=="boolean")return"";if(typeof r=="number"||typeof r=="string")return X(String(r));if(Array.isArray(r))return(await Promise.all(r.map(O))).join("");if("type"in r&&r.props!==void 0){const{type:t,props:e}=r;if(typeof t=="function")try{B();const i=await t(e||{}),o=await O(i);return H(),o}catch(i){return console.error("Error rendering component:",i),""}if(t===Symbol.for("react.fragment")||t.name==="Fragment"){if(e.children){const i=Array.isArray(e.children)?e.children:[e.children];return(await Promise.all(i.map(O))).join("")}return""}let n=`<${t}`;for(const[i,o]of Object.entries(e||{}))i==="children"||i==="key"||(i==="className"?n+=` class="${X(String(o))}"`:i==="style"&&typeof o=="object"?n+=` style="${it(o||{})}"`:i.startsWith("on")||(n+=` ${i}="${X(String(o))}"`));if(new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]).has(t))return n+"/>";if(n+=">",e!=null&&e.children){const i=Array.isArray(e.children)?e.children:[e.children];for(const o of i)n+=await O(o)}return n+`</${t}>`}return X(String(r))}finally{H()}}function X(r){return r.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function it(r){return Object.entries(r).map(([t,e])=>`${ct(t)}:${e}`).join(";")}function ct(r){return r.replace(/[A-Z]/g,t=>"-"+t.toLowerCase())}function Pe(r){const t={_currentValue:r,Provider:function({value:n,children:s}){return t._currentValue=n,s},Consumer:function({children:n}){return n(t._currentValue)}};return t}function De(r){return r._currentValue}class he{constructor(t){this.connection=null,this._connected=!1,this.options={retryAttempts:3,retryDelay:1e3,connectionTimeout:1e4,autoIndex:!0,...t}}async connect(){try{if(this._connected&&this.connection)return this.connection;$.set("strictQuery",!0);let t=0;for(;t<(this.options.retryAttempts||3);)try{await $.connect(this.options.uri,{dbName:this.options.name,connectTimeoutMS:this.options.connectionTimeout,autoIndex:this.options.autoIndex,...this.options.options});break}catch(e){if(t++,t>=(this.options.retryAttempts||3))throw e;console.log(`Connection attempt ${t} failed. Retrying in ${this.options.retryDelay}ms...`),await new Promise(n=>setTimeout(n,this.options.retryDelay))}return this.connection=$.connection,this._connected=!0,console.log(`Connected to MongoDB at ${this.options.uri}/${this.options.name}`),this.connection.on("error",e=>{console.error("MongoDB connection error:",e),this._connected=!1}),this.connection.on("disconnected",()=>{console.log("MongoDB disconnected"),this._connected=!1}),this.connection}catch(t){throw console.error("Failed to connect to MongoDB:",t),t}}async disconnect(){this.connection&&(await $.disconnect(),this._connected=!1,this.connection=null,console.log("Disconnected from MongoDB"))}isConnected(){return this._connected}getConnection(){return this.connection}}function Me(r={}){const t=v(),{port:e=3e3,staticDir:n="public",enableCors:s=!0,apiPrefix:i="/api",ssrEnabled:o=!0,middlewares:c=[],enableCompression:u=!0,enableHelmet:f=!0,logFormat:p="dev",trustProxy:b=!1,showErrorDetails:_=E.env.NODE_ENV!=="production"}=r;if(b&&t.set("trust proxy",b),t.use(v.json()),t.use(v.urlencoded({extended:!0})),u&&t.use(ze()),f&&t.use(Qe({contentSecurityPolicy:r.disableCSP?!1:void 0})),p&&t.use(Ye(p)),s&&t.use((d,m,h)=>{if(m.header("Access-Control-Allow-Origin","*"),m.header("Access-Control-Allow-Methods","GET, POST, PUT, DELETE, PATCH, OPTIONS"),m.header("Access-Control-Allow-Headers","Origin, X-Requested-With, Content-Type, Accept, Authorization"),d.method==="OPTIONS")return m.sendStatus(200);h()}),c.forEach(d=>t.use(d)),n){const d=Ee.resolve(E.cwd(),n);Xe.existsSync(d)?(t.use(v.static(d,{maxAge:r.staticCacheAge||"1d",etag:!0})),console.log(`📂 Serving static files from: ${d}`)):console.warn(`⚠️ Static directory not found: ${d}`)}let g=null;t.connectToDatabase=async d=>{try{return g&&g.isConnected()?(console.log("✅ Using existing database connection"),g):(g=new he(d),await g.connect(),console.log("✅ Database connected successfully"),E.on("SIGTERM",async()=>{g&&g.isConnected()&&(await g.disconnect(),console.log("Database connection closed"))}),g)}catch(m){throw console.error("❌ Failed to connect to database:",m),m}};const F={},me={};return t.registerApi=(d,m,h={})=>{try{const{prefix:w=i}=h,S=Ee.posix.join(w,d).replace(/\\/g,"/");t.use(S,m),F[S]={router:m,options:h},console.log(`🔌 API registered: ${S}`)}catch(w){console.error(`❌ Failed to register API at ${d}:`,w)}return t},t.registerSSR=(d,m,h={})=>o?(me[d]={component:m,options:h},t.get(d,async(w,S,ge)=>{try{if(w.query.nossr==="true")return ge();const we={req:w,res:S,params:w.params,query:w.query,user:w.user,...h.props},lt=await O(m(we));S.send(`
|
2
2
|
<!DOCTYPE html>
|
3
3
|
<html lang="${h.lang||"en"}">
|
4
4
|
<head>
|
5
5
|
<meta charset="UTF-8">
|
6
6
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
7
7
|
<title>${h.title||"Frontend Hamroun App"}</title>
|
8
|
-
${h.meta?h.meta.map(
|
8
|
+
${h.meta?h.meta.map(q=>`<meta ${Object.entries(q).map(([dt,ft])=>`${dt}="${ft}"`).join(" ")}>`).join(`
|
9
9
|
`):""}
|
10
10
|
${h.head||""}
|
11
11
|
${h.styles?`<style>${h.styles}</style>`:""}
|
12
|
-
${h.styleSheets?h.styleSheets.map(
|
12
|
+
${h.styleSheets?h.styleSheets.map(q=>`<link rel="stylesheet" href="${q}">`).join(`
|
13
13
|
`):""}
|
14
14
|
</head>
|
15
15
|
<body ${h.bodyAttributes||""}>
|
16
|
-
<div id="${h.rootId||"root"}">${
|
16
|
+
<div id="${h.rootId||"root"}">${lt}</div>
|
17
17
|
<script>
|
18
18
|
window.__INITIAL_DATA__ = ${JSON.stringify(h.initialData||{})};
|
19
19
|
<\/script>
|
20
|
-
${h.scripts?h.scripts.map(
|
20
|
+
${h.scripts?h.scripts.map(q=>`<script src="${q}"><\/script>`).join(`
|
21
21
|
`):""}
|
22
22
|
</body>
|
23
23
|
</html>
|
24
|
-
`)}catch(
|
24
|
+
`)}catch(we){if(console.error("SSR Error:",we),h.fallback)return ge();S.status(500).send("Server rendering error")}}),console.log(`🖥️ SSR registered: ${d}`),t):(console.log(`⚠️ SSR disabled: skipping registration of ${d}`),t),t.use((d,m,h,w)=>{console.error("Server error:",d);const S=d.statusCode||d.status||500;m.path.startsWith(i)?h.status(S).json({success:!1,error:_?d.message:"Internal Server Error",stack:_?d.stack:void 0}):h.status(S).send(`
|
25
25
|
<!DOCTYPE html>
|
26
26
|
<html>
|
27
27
|
<head>
|
@@ -59,8 +59,8 @@ ${Object.keys(F).length>0?`
|
|
59
59
|
📡 Registered API Routes:
|
60
60
|
${Object.keys(F).map(w=>` ${w}`).join(`
|
61
61
|
`)}`:""}
|
62
|
-
${Object.keys(
|
62
|
+
${Object.keys(me).length>0?`
|
63
63
|
🖥️ Registered SSR Routes:
|
64
|
-
${Object.keys(
|
64
|
+
${Object.keys(me).map(w=>` ${w}`).join(`
|
65
65
|
`)}`:""}
|
66
|
-
`),d&&d()}),h=async w=>{console.log(`${w} signal received: closing HTTP server and cleaning up`),m.close(async()=>{console.log("HTTP server closed"),g&&g.isConnected()&&(await g.disconnect(),console.log("Database connection closed")),E.exit(0)}),setTimeout(()=>{console.error("Could not close connections in time, forcefully shutting down"),E.exit(1)},1e4)};return E.on("SIGTERM",()=>h("SIGTERM")),E.on("SIGINT",()=>h("SIGINT")),m},t}const Me=Ee.default||Ee;class ct{constructor(t){if(this.loginAttempts=new Map,this.login=async(e,n)=>{try{const{username:s,password:i}=e.body,o=e.ip||e.connection.remoteAddress||"";if(!this.checkRateLimit(o)){n.status(429).json({success:!1,message:"Too many login attempts. Please try again later."});return}if(!s||!i){n.status(400).json({success:!1,message:"Username and password are required"});return}if(!this.options.findUser){n.status(500).json({success:!1,message:"User finder function not configured"});return}const c=await this.options.findUser(s);if(!c){n.status(401).json({success:!1,message:"Invalid credentials"});return}if(!await this.options.verifyPassword(i,c.password)){n.status(401).json({success:!1,message:"Invalid credentials"});return}const f={...c};delete f.password;const p=this.generateTokenPair({id:c.id||c._id,username:c.username,role:c.role||"user"});if(this.options.saveRefreshToken){const b=new Date;b.setSeconds(b.getSeconds()+this.getExpirationSeconds(this.options.refreshExpiration||"7d")),await this.options.saveRefreshToken(c.id||c._id,p.refreshToken,b)}e.body.useCookies&&this.setAuthCookies(n,p),n.json({success:!0,message:"Authentication successful",tokens:p,user:f})}catch(s){console.error("Authentication error:",s),n.status(500).json({success:!1,message:"Authentication failed",error:E.env.NODE_ENV!=="production"?s.message:void 0})}},this.refreshToken=async(e,n)=>{var s,i;try{const o=((s=e.cookies)==null?void 0:s.refreshToken)||e.body.refreshToken;if(!o){n.status(401).json({success:!1,message:"Refresh token required"});return}const c=this.verifyToken(o,"refresh");if(this.options.verifyRefreshToken&&!await this.options.verifyRefreshToken(c.id,o)){this.clearAuthCookies(n),n.status(401).json({success:!1,message:"Invalid refresh token"});return}const u=this.generateTokenPair({id:c.id,...this.options.findUser?await this.options.findUser(c.id):{}});if(this.options.saveRefreshToken){const p=new Date;p.setSeconds(p.getSeconds()+this.getExpirationSeconds(this.options.refreshExpiration||"7d")),await this.options.saveRefreshToken(c.id,u.refreshToken,p)}(((i=e.cookies)==null?void 0:i.accessToken)||e.body.useCookies)&&this.setAuthCookies(n,u),n.json({success:!0,message:"Token refreshed successfully",tokens:u})}catch(o){this.clearAuthCookies(n),n.status(401).json({success:!1,message:"Invalid or expired refresh token",error:E.env.NODE_ENV!=="production"?o.message:void 0})}},this.logout=async(e,n)=>{var s;try{this.clearAuthCookies(n);const i=((s=e.cookies)==null?void 0:s.refreshToken)||e.body.refreshToken;if(i&&this.options.saveRefreshToken)try{const o=this.verifyToken(i,"refresh");typeof this.options.saveRefreshToken=="function"&&await this.options.saveRefreshToken(o.id,"",new Date)}catch{}n.json({success:!0,message:"Logged out successfully"})}catch(i){console.error("Logout error:",i),n.status(500).json({success:!1,message:"Logout failed",error:i.message})}},this.authenticate=(e,n,s)=>{var i;try{let o=(i=e.cookies)==null?void 0:i.accessToken;if(!o){const u=e.headers.authorization;u&&u.startsWith("Bearer ")&&(o=u.split(" ")[1])}if(!o){n.status(401).json({success:!1,message:"Authentication required"});return}const c=this.verifyToken(o,"access");e.user=c,s()}catch(o){n.status(401).json({success:!1,message:"Invalid or expired token",error:E.env.NODE_ENV!=="production"?o.message:void 0})}},this.hasRole=e=>(n,s,i)=>{const o=n.user;if(!o){s.status(401).json({success:!1,message:"Authentication required"});return}(Array.isArray(e)?e:[e]).includes(o.role)?i():s.status(403).json({success:!1,message:"Insufficient permissions"})},this.options={tokenExpiration:"15m",refreshExpiration:"7d",saltRounds:10,secureCookies:E.env.NODE_ENV==="production",httpOnlyCookies:!0,rateLimit:!0,...t,refreshSecret:t.refreshSecret||t.jwtSecret},!t.jwtSecret)throw new Error("JWT secret is required for authentication");this.options.verifyPassword||(this.options.verifyPassword=this.verifyPasswordWithBcrypt)}async hashPassword(t){return await Me.hash(t,this.options.saltRounds||10)}async verifyPasswordWithBcrypt(t,e){return await Me.compare(t,e)}generateSecureToken(t=32){return Ze.randomBytes(t).toString("hex")}generateTokenPair(t){const e=this.getExpirationSeconds(this.options.tokenExpiration||"15m"),n=K.sign({...t,type:"access"},this.options.jwtSecret,{expiresIn:this.options.tokenExpiration}),s=K.sign({id:t.id,type:"refresh"},this.options.refreshSecret,{expiresIn:this.options.refreshExpiration});return{accessToken:n,refreshToken:s,expiresIn:e}}getExpirationSeconds(t){const e=t.charAt(t.length-1),n=parseInt(t.slice(0,-1));switch(e){case"s":return n;case"m":return n*60;case"h":return n*60*60;case"d":return n*60*60*24;default:return 3600}}verifyToken(t,e="access"){try{const n=e==="access"?this.options.jwtSecret:this.options.refreshSecret,s=K.verify(t,n);if(typeof s=="object"&&s.type!==e)throw new Error("Invalid token type");return s}catch{throw new Error("Invalid or expired token")}}setAuthCookies(t,e){t.cookie("accessToken",e.accessToken,{httpOnly:this.options.httpOnlyCookies,secure:this.options.secureCookies,domain:this.options.cookieDomain,sameSite:"strict",maxAge:e.expiresIn*1e3});const n=this.getExpirationSeconds(this.options.refreshExpiration||"7d");t.cookie("refreshToken",e.refreshToken,{httpOnly:!0,secure:this.options.secureCookies,domain:this.options.cookieDomain,sameSite:"strict",maxAge:n*1e3,path:"/api/auth/refresh"})}clearAuthCookies(t){t.clearCookie("accessToken"),t.clearCookie("refreshToken",{path:"/api/auth/refresh"})}checkRateLimit(t){if(!this.options.rateLimit)return!0;const e=Date.now(),n=this.loginAttempts.get(t);return n?e>n.resetTime?(this.loginAttempts.set(t,{count:1,resetTime:e+36e5}),!0):n.count>=5?!1:(n.count++,this.loginAttempts.set(t,n),!0):(this.loginAttempts.set(t,{count:1,resetTime:e+36e5}),!0)}}function Fe(r){return new ct(r)}function Le(r,t){const e=$.model(r,t);return{getAll:async n=>{try{const{page:s=1,limit:i=10,sort:o="_id",order:c="desc"}=n||{},u=(s-1)*i,f=c==="asc"?1:-1,p={[o]:f},[b,_]=await Promise.all([e.find().sort(p).skip(u).limit(i).exec(),e.countDocuments().exec()]),g=Math.ceil(_/i);return{data:b,pagination:{total:_,totalPages:g,currentPage:s,limit:i,hasNextPage:s<g,hasPrevPage:s>1}}}catch(s){throw console.error(`Error in ${r}.getAll:`,s),new Error(`Failed to retrieve ${r} records: ${s.message}`)}},getById:async n=>{try{return $.isValidObjectId(n)?await e.findById(n).exec():null}catch(s){throw console.error(`Error in ${r}.getById:`,s),new Error(`Failed to retrieve ${r} by ID: ${s.message}`)}},create:async n=>{try{return await new e(n).save()}catch(s){throw console.error(`Error in ${r}.create:`,s),new Error(`Failed to create ${r}: ${s.message}`)}},createMany:async n=>{try{return await e.insertMany(n)}catch(s){throw console.error(`Error in ${r}.createMany:`,s),new Error(`Failed to create multiple ${r} records: ${s.message}`)}},update:async(n,s)=>{try{return $.isValidObjectId(n)?await e.findByIdAndUpdate(n,{$set:s},{new:!0,runValidators:!0}).exec():null}catch(i){throw console.error(`Error in ${r}.update:`,i),new Error(`Failed to update ${r}: ${i.message}`)}},delete:async n=>{try{return $.isValidObjectId(n)?await e.findByIdAndDelete(n).exec()!==null:!1}catch(s){throw console.error(`Error in ${r}.delete:`,s),new Error(`Failed to delete ${r}: ${s.message}`)}},find:async(n,s)=>{try{const{page:i=1,limit:o=10,sort:c="_id",order:u="desc"}=s||{},f=(i-1)*o,p=u==="asc"?1:-1,b={[c]:p},[_,g]=await Promise.all([e.find(n).sort(b).skip(f).limit(o).exec(),e.countDocuments(n).exec()]),F=Math.ceil(g/o);return{data:_,pagination:{total:g,totalPages:F,currentPage:i,limit:o,hasNextPage:i<F,hasPrevPage:i>1}}}catch(i){throw console.error(`Error in ${r}.find:`,i),new Error(`Failed to find ${r} records: ${i.message}`)}},count:async n=>{try{return await e.countDocuments(n||{}).exec()}catch(s){throw console.error(`Error in ${r}.count:`,s),new Error(`Failed to count ${r} records: ${s.message}`)}},findOne:async n=>{try{return await e.findOne(n).exec()}catch(s){throw console.error(`Error in ${r}.findOne:`,s),new Error(`Failed to find ${r} record: ${s.message}`)}}}}const Be={String:{type:String},Number:{type:Number},Boolean:{type:Boolean},Date:{type:Date},ObjectId:{type:String},Required:r=>({...r,required:!0}),Unique:r=>({...r,unique:!0}),Ref:r=>({type:String,ref:r}),Enum:r=>({type:String,enum:r}),Default:(r,t)=>({...r,default:t}),Array:r=>({type:[r]})},Ve=(r,{res:t})=>{console.error("API Error:",r);const e=r.status||r.statusCode||500,n=r.message||"Internal server error";t.status(e).json({success:!1,error:n,stack:E.env.NODE_ENV!=="production"?r.stack:void 0})};function He(r,t={}){const e=v.Router(),{middleware:n=[],errorHandler:s=Ve}=t;n.forEach(o=>e.use(o));const i=o=>async(c,u,f)=>{try{const p={req:c,res:u,next:f,params:c.params,query:c.query,body:c.body};return await o(p)}catch(p){const b={req:c,res:u,next:f,params:c.params,query:c.query,body:c.body};return s(p,b)}};return e.get("/",i(async({req:o,res:c})=>{const u=o.pagination||{page:1,limit:10},f=await r.getAll(u);c.json({success:!0,...f})})),e.get("/:id",i(async({params:o,res:c})=>{const u=await r.getById(o.id);if(!u){c.status(404).json({success:!1,error:"Item not found"});return}c.json({success:!0,data:u})})),e.post("/",i(async({body:o,res:c})=>{const u=await r.create(o);c.status(201).json({success:!0,data:u,message:"Item created successfully"})})),e.put("/:id",i(async({params:o,body:c,res:u})=>{const f=await r.update(o.id,c);if(!f){u.status(404).json({success:!1,error:"Item not found"});return}u.json({success:!0,data:f,message:"Item updated successfully"})})),e.delete("/:id",i(async({params:o,res:c})=>{if(!await r.delete(o.id)){c.status(404).json({success:!1,error:"Item not found"});return}c.json({success:!0,message:"Item deleted successfully"})})),e}function qe(r,t={}){const e=v.Router(),{middleware:n=[],errorHandler:s=Ve}=t;n.forEach(o=>e.use(o));const i=o=>async(c,u,f)=>{try{const p={req:c,res:u,next:f,params:c.params,query:c.query,body:c.body};return u.headersSent?void 0:await o(p)}catch(p){if(u.headersSent){console.error("Error occurred after response was sent:",p);return}const b={req:c,res:u,next:f,params:c.params,query:c.query,body:c.body};return s(p,b)}};return Object.entries(r).forEach(([o,c])=>{const{method:u,handler:f}=c;e[u](o,i(f))}),e}function Z(r,t,e,n,s){const i={success:r};return t!==void 0&&(i.data=t),e&&(i.message=e),n&&(i.error=n),s&&(i.meta=s),i}function N(r,t,e,n=200,s){r.status(n).json(Z(!0,t,e,void 0,s))}function P(r,t,e=400,n){const s=t instanceof Error?t.message:t;r.status(e).json(Z(!1,void 0,void 0,s,n))}function he(r){const t=parseInt(r.query.page)||1,e=parseInt(r.query.limit)||10,n=r.query.sort||"createdAt",s=r.query.order==="asc"?"asc":"desc";return{page:t,limit:e,sort:n,order:s}}function pe(r,t,e){r.pagination=he(r),e()}function We(r){return(t,e,n)=>{try{const{error:s,value:i}=r.validate(t.body);if(s){P(e,`Validation error: ${s.message}`,400);return}t.body=i,n()}catch{P(e,"Validation error",400)}}}function Ue(r={},t){const e=v.Router();return r.requireAuth&&t&&(e.use(t.authenticate),r.requiredRole&&e.use(t.hasRole(r.requiredRole))),r.rateLimit&&console.warn("Rate limiting is disabled: express-rate-limit dependency is not installed"),e}function D(r){return(t,e,n)=>{r(t,e,n).catch(n)}}function Ge(r){const t=v.Router();return t.get("/",pe,D(async(e,n)=>{const s=await r.getAll(e.pagination);N(n,s)})),t.get("/:id",D(async(e,n)=>{const s=await r.getById(e.params.id);if(!s)return P(n,"Item not found",404);N(n,s)})),t.post("/",D(async(e,n)=>{const s=await r.create(e.body);N(n,s,"Item created successfully",201)})),t.put("/:id",D(async(e,n)=>{const s=await r.update(e.params.id,e.body);if(!s)return P(n,"Item not found",404);N(n,s,"Item updated successfully")})),t.delete("/:id",D(async(e,n)=>{if(!await r.delete(e.params.id))return P(n,"Item not found",404);N(n,null,"Item deleted successfully")})),t}const at={jsx:W,jsxs:re,createElement:U,Fragment:ne,Component:Ae,useState:de,useEffect:_e,useRef:Ie,useMemo:$e,useErrorBoundary:Oe,render:Y,hydrate:xe,renderToString:x,prepareRender:B,finishRender:V,batchUpdates:J,createContext:Ne,useContext:Pe,createServer:De,createAuth:Fe,createModel:Le,FieldTypes:Be,createModelRouter:He,createCustomRouter:qe,createApiRouter:Ue,sendSuccess:N,sendError:P,apiResponse:Z,getPaginationParams:he,paginationMiddleware:pe,validateRequest:We,asyncHandler:D,createRestEndpoints:Ge,DatabaseConnector:fe};a.Component=Ae,a.DatabaseConnector=fe,a.FieldTypes=Be,a.Fragment=ne,a.apiResponse=Z,a.asyncHandler=D,a.batchUpdates=J,a.createApiRouter=Ue,a.createAuth=Fe,a.createContext=Ne,a.createCustomRouter=qe,a.createElement=U,a.createModel=Le,a.createModelRouter=He,a.createRestEndpoints=Ge,a.createServer=De,a.default=at,a.finishRender=V,a.getPaginationParams=he,a.hydrate=xe,a.jsx=W,a.jsxs=re,a.paginationMiddleware=pe,a.prepareRender=B,a.render=Y,a.renderToString=x,a.sendError=P,a.sendSuccess=N,a.useContext=Pe,a.useEffect=_e,a.useErrorBoundary=Oe,a.useMemo=$e,a.useRef=Ie,a.useState=de,a.validateRequest=We,Object.defineProperties(a,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
66
|
+
`),d&&d()}),h=async w=>{console.log(`${w} signal received: closing HTTP server and cleaning up`),m.close(async()=>{console.log("HTTP server closed"),g&&g.isConnected()&&(await g.disconnect(),console.log("Database connection closed")),E.exit(0)}),setTimeout(()=>{console.error("Could not close connections in time, forcefully shutting down"),E.exit(1)},1e4)};return E.on("SIGTERM",()=>h("SIGTERM")),E.on("SIGINT",()=>h("SIGINT")),m},t}const Fe=be.default||be;class at{constructor(t){if(this.loginAttempts=new Map,this.login=async(e,n)=>{try{const{username:s,password:i}=e.body,o=e.ip||e.connection.remoteAddress||"";if(!this.checkRateLimit(o)){n.status(429).json({success:!1,message:"Too many login attempts. Please try again later."});return}if(!s||!i){n.status(400).json({success:!1,message:"Username and password are required"});return}if(!this.options.findUser){n.status(500).json({success:!1,message:"User finder function not configured"});return}const c=await this.options.findUser(s);if(!c){n.status(401).json({success:!1,message:"Invalid credentials"});return}if(!await this.options.verifyPassword(i,c.password)){n.status(401).json({success:!1,message:"Invalid credentials"});return}const f={...c};delete f.password;const p=this.generateTokenPair({id:c.id||c._id,username:c.username,role:c.role||"user"});if(this.options.saveRefreshToken){const b=new Date;b.setSeconds(b.getSeconds()+this.getExpirationSeconds(this.options.refreshExpiration||"7d")),await this.options.saveRefreshToken(c.id||c._id,p.refreshToken,b)}e.body.useCookies&&this.setAuthCookies(n,p),n.json({success:!0,message:"Authentication successful",tokens:p,user:f})}catch(s){console.error("Authentication error:",s),n.status(500).json({success:!1,message:"Authentication failed",error:E.env.NODE_ENV!=="production"?s.message:void 0})}},this.refreshToken=async(e,n)=>{var s,i;try{const o=((s=e.cookies)==null?void 0:s.refreshToken)||e.body.refreshToken;if(!o){n.status(401).json({success:!1,message:"Refresh token required"});return}const c=this.verifyToken(o,"refresh");if(this.options.verifyRefreshToken&&!await this.options.verifyRefreshToken(c.id,o)){this.clearAuthCookies(n),n.status(401).json({success:!1,message:"Invalid refresh token"});return}const u=this.generateTokenPair({id:c.id,...this.options.findUser?await this.options.findUser(c.id):{}});if(this.options.saveRefreshToken){const p=new Date;p.setSeconds(p.getSeconds()+this.getExpirationSeconds(this.options.refreshExpiration||"7d")),await this.options.saveRefreshToken(c.id,u.refreshToken,p)}(((i=e.cookies)==null?void 0:i.accessToken)||e.body.useCookies)&&this.setAuthCookies(n,u),n.json({success:!0,message:"Token refreshed successfully",tokens:u})}catch(o){this.clearAuthCookies(n),n.status(401).json({success:!1,message:"Invalid or expired refresh token",error:E.env.NODE_ENV!=="production"?o.message:void 0})}},this.logout=async(e,n)=>{var s;try{this.clearAuthCookies(n);const i=((s=e.cookies)==null?void 0:s.refreshToken)||e.body.refreshToken;if(i&&this.options.saveRefreshToken)try{const o=this.verifyToken(i,"refresh");typeof this.options.saveRefreshToken=="function"&&await this.options.saveRefreshToken(o.id,"",new Date)}catch{}n.json({success:!0,message:"Logged out successfully"})}catch(i){console.error("Logout error:",i),n.status(500).json({success:!1,message:"Logout failed",error:i.message})}},this.authenticate=(e,n,s)=>{var i;try{let o=(i=e.cookies)==null?void 0:i.accessToken;if(!o){const u=e.headers.authorization;u&&u.startsWith("Bearer ")&&(o=u.split(" ")[1])}if(!o){n.status(401).json({success:!1,message:"Authentication required"});return}const c=this.verifyToken(o,"access");e.user=c,s()}catch(o){n.status(401).json({success:!1,message:"Invalid or expired token",error:E.env.NODE_ENV!=="production"?o.message:void 0})}},this.hasRole=e=>(n,s,i)=>{const o=n.user;if(!o){s.status(401).json({success:!1,message:"Authentication required"});return}(Array.isArray(e)?e:[e]).includes(o.role)?i():s.status(403).json({success:!1,message:"Insufficient permissions"})},this.options={tokenExpiration:"15m",refreshExpiration:"7d",saltRounds:10,secureCookies:E.env.NODE_ENV==="production",httpOnlyCookies:!0,rateLimit:!0,...t,refreshSecret:t.refreshSecret||t.jwtSecret},!t.jwtSecret)throw new Error("JWT secret is required for authentication");this.options.verifyPassword||(this.options.verifyPassword=this.verifyPasswordWithBcrypt)}async hashPassword(t){return await Fe.hash(t,this.options.saltRounds||10)}async verifyPasswordWithBcrypt(t,e){return await Fe.compare(t,e)}generateSecureToken(t=32){return Ke.randomBytes(t).toString("hex")}generateTokenPair(t){const e=this.getExpirationSeconds(this.options.tokenExpiration||"15m"),n=K.sign({...t,type:"access"},this.options.jwtSecret,{expiresIn:this.options.tokenExpiration}),s=K.sign({id:t.id,type:"refresh"},this.options.refreshSecret,{expiresIn:this.options.refreshExpiration});return{accessToken:n,refreshToken:s,expiresIn:e}}getExpirationSeconds(t){const e=t.charAt(t.length-1),n=parseInt(t.slice(0,-1));switch(e){case"s":return n;case"m":return n*60;case"h":return n*60*60;case"d":return n*60*60*24;default:return 3600}}verifyToken(t,e="access"){try{const n=e==="access"?this.options.jwtSecret:this.options.refreshSecret,s=K.verify(t,n);if(typeof s=="object"&&s.type!==e)throw new Error("Invalid token type");return s}catch{throw new Error("Invalid or expired token")}}setAuthCookies(t,e){t.cookie("accessToken",e.accessToken,{httpOnly:this.options.httpOnlyCookies,secure:this.options.secureCookies,domain:this.options.cookieDomain,sameSite:"strict",maxAge:e.expiresIn*1e3});const n=this.getExpirationSeconds(this.options.refreshExpiration||"7d");t.cookie("refreshToken",e.refreshToken,{httpOnly:!0,secure:this.options.secureCookies,domain:this.options.cookieDomain,sameSite:"strict",maxAge:n*1e3,path:"/api/auth/refresh"})}clearAuthCookies(t){t.clearCookie("accessToken"),t.clearCookie("refreshToken",{path:"/api/auth/refresh"})}checkRateLimit(t){if(!this.options.rateLimit)return!0;const e=Date.now(),n=this.loginAttempts.get(t);return n?e>n.resetTime?(this.loginAttempts.set(t,{count:1,resetTime:e+36e5}),!0):n.count>=5?!1:(n.count++,this.loginAttempts.set(t,n),!0):(this.loginAttempts.set(t,{count:1,resetTime:e+36e5}),!0)}}function Le(r){return new at(r)}function Ve(r,t){const e=$.model(r,t);return{getAll:async n=>{try{const{page:s=1,limit:i=10,sort:o="_id",order:c="desc"}=n||{},u=(s-1)*i,f=c==="asc"?1:-1,p={[o]:f},[b,_]=await Promise.all([e.find().sort(p).skip(u).limit(i).exec(),e.countDocuments().exec()]),g=Math.ceil(_/i);return{data:b,pagination:{total:_,totalPages:g,currentPage:s,limit:i,hasNextPage:s<g,hasPrevPage:s>1}}}catch(s){throw console.error(`Error in ${r}.getAll:`,s),new Error(`Failed to retrieve ${r} records: ${s.message}`)}},getById:async n=>{try{return $.isValidObjectId(n)?await e.findById(n).exec():null}catch(s){throw console.error(`Error in ${r}.getById:`,s),new Error(`Failed to retrieve ${r} by ID: ${s.message}`)}},create:async n=>{try{return await new e(n).save()}catch(s){throw console.error(`Error in ${r}.create:`,s),new Error(`Failed to create ${r}: ${s.message}`)}},createMany:async n=>{try{return await e.insertMany(n)}catch(s){throw console.error(`Error in ${r}.createMany:`,s),new Error(`Failed to create multiple ${r} records: ${s.message}`)}},update:async(n,s)=>{try{return $.isValidObjectId(n)?await e.findByIdAndUpdate(n,{$set:s},{new:!0,runValidators:!0}).exec():null}catch(i){throw console.error(`Error in ${r}.update:`,i),new Error(`Failed to update ${r}: ${i.message}`)}},delete:async n=>{try{return $.isValidObjectId(n)?await e.findByIdAndDelete(n).exec()!==null:!1}catch(s){throw console.error(`Error in ${r}.delete:`,s),new Error(`Failed to delete ${r}: ${s.message}`)}},find:async(n,s)=>{try{const{page:i=1,limit:o=10,sort:c="_id",order:u="desc"}=s||{},f=(i-1)*o,p=u==="asc"?1:-1,b={[c]:p},[_,g]=await Promise.all([e.find(n).sort(b).skip(f).limit(o).exec(),e.countDocuments(n).exec()]),F=Math.ceil(g/o);return{data:_,pagination:{total:g,totalPages:F,currentPage:i,limit:o,hasNextPage:i<F,hasPrevPage:i>1}}}catch(i){throw console.error(`Error in ${r}.find:`,i),new Error(`Failed to find ${r} records: ${i.message}`)}},count:async n=>{try{return await e.countDocuments(n||{}).exec()}catch(s){throw console.error(`Error in ${r}.count:`,s),new Error(`Failed to count ${r} records: ${s.message}`)}},findOne:async n=>{try{return await e.findOne(n).exec()}catch(s){throw console.error(`Error in ${r}.findOne:`,s),new Error(`Failed to find ${r} record: ${s.message}`)}}}}const Be={String:{type:String},Number:{type:Number},Boolean:{type:Boolean},Date:{type:Date},ObjectId:{type:String},Required:r=>({...r,required:!0}),Unique:r=>({...r,unique:!0}),Ref:r=>({type:String,ref:r}),Enum:r=>({type:String,enum:r}),Default:(r,t)=>({...r,default:t}),Array:r=>({type:[r]})},He=(r,{res:t})=>{console.error("API Error:",r);const e=r.status||r.statusCode||500,n=r.message||"Internal server error";t.status(e).json({success:!1,error:n,stack:E.env.NODE_ENV!=="production"?r.stack:void 0})};function qe(r,t={}){const e=v.Router(),{middleware:n=[],errorHandler:s=He}=t;n.forEach(o=>e.use(o));const i=o=>async(c,u,f)=>{try{const p={req:c,res:u,next:f,params:c.params,query:c.query,body:c.body};return await o(p)}catch(p){const b={req:c,res:u,next:f,params:c.params,query:c.query,body:c.body};return s(p,b)}};return e.get("/",i(async({req:o,res:c})=>{const u=o.pagination||{page:1,limit:10},f=await r.getAll(u);c.json({success:!0,...f})})),e.get("/:id",i(async({params:o,res:c})=>{const u=await r.getById(o.id);if(!u){c.status(404).json({success:!1,error:"Item not found"});return}c.json({success:!0,data:u})})),e.post("/",i(async({body:o,res:c})=>{const u=await r.create(o);c.status(201).json({success:!0,data:u,message:"Item created successfully"})})),e.put("/:id",i(async({params:o,body:c,res:u})=>{const f=await r.update(o.id,c);if(!f){u.status(404).json({success:!1,error:"Item not found"});return}u.json({success:!0,data:f,message:"Item updated successfully"})})),e.delete("/:id",i(async({params:o,res:c})=>{if(!await r.delete(o.id)){c.status(404).json({success:!1,error:"Item not found"});return}c.json({success:!0,message:"Item deleted successfully"})})),e}function We(r,t={}){const e=v.Router(),{middleware:n=[],errorHandler:s=He}=t;n.forEach(o=>e.use(o));const i=o=>async(c,u,f)=>{try{const p={req:c,res:u,next:f,params:c.params,query:c.query,body:c.body};return u.headersSent?void 0:await o(p)}catch(p){if(u.headersSent){console.error("Error occurred after response was sent:",p);return}const b={req:c,res:u,next:f,params:c.params,query:c.query,body:c.body};return s(p,b)}};return Object.entries(r).forEach(([o,c])=>{const{method:u,handler:f}=c;e[u](o,i(f))}),e}function Z(r,t,e,n,s){const i={success:r};return t!==void 0&&(i.data=t),e&&(i.message=e),n&&(i.error=n),s&&(i.meta=s),i}function N(r,t,e,n=200,s){r.status(n).json(Z(!0,t,e,void 0,s))}function P(r,t,e=400,n){const s=t instanceof Error?t.message:t;r.status(e).json(Z(!1,void 0,void 0,s,n))}function pe(r){const t=parseInt(r.query.page)||1,e=parseInt(r.query.limit)||10,n=r.query.sort||"createdAt",s=r.query.order==="asc"?"asc":"desc";return{page:t,limit:e,sort:n,order:s}}function ye(r,t,e){r.pagination=pe(r),e()}function Ue(r){return(t,e,n)=>{try{const{error:s,value:i}=r.validate(t.body);if(s){P(e,`Validation error: ${s.message}`,400);return}t.body=i,n()}catch{P(e,"Validation error",400)}}}function Ge(r={},t){const e=v.Router();return r.requireAuth&&t&&(e.use(t.authenticate),r.requiredRole&&e.use(t.hasRole(r.requiredRole))),r.rateLimit&&console.warn("Rate limiting is disabled: express-rate-limit dependency is not installed"),e}function D(r){return(t,e,n)=>{r(t,e,n).catch(n)}}function Je(r){const t=v.Router();return t.get("/",ye,D(async(e,n)=>{const s=await r.getAll(e.pagination);N(n,s)})),t.get("/:id",D(async(e,n)=>{const s=await r.getById(e.params.id);if(!s)return P(n,"Item not found",404);N(n,s)})),t.post("/",D(async(e,n)=>{const s=await r.create(e.body);N(n,s,"Item created successfully",201)})),t.put("/:id",D(async(e,n)=>{const s=await r.update(e.params.id,e.body);if(!s)return P(n,"Item not found",404);N(n,s,"Item updated successfully")})),t.delete("/:id",D(async(e,n)=>{if(!await r.delete(e.params.id))return P(n,"Item not found",404);N(n,null,"Item deleted successfully")})),t}const ut={jsx:L,jsxs:re,jsxDEV:se,createElement:U,Fragment:ne,Component:je,useState:fe,useEffect:$e,useRef:Re,useMemo:Ie,useErrorBoundary:Oe,render:Y,hydrate:Ne,renderToString:O,prepareRender:B,finishRender:H,batchUpdates:J,createContext:Pe,useContext:De,createServer:Me,createAuth:Le,createModel:Ve,FieldTypes:Be,createModelRouter:qe,createCustomRouter:We,createApiRouter:Ge,sendSuccess:N,sendError:P,apiResponse:Z,getPaginationParams:pe,paginationMiddleware:ye,validateRequest:Ue,asyncHandler:D,createRestEndpoints:Je,DatabaseConnector:he};a.Component=je,a.DatabaseConnector=he,a.FieldTypes=Be,a.Fragment=ne,a.apiResponse=Z,a.asyncHandler=D,a.batchUpdates=J,a.createApiRouter=Ge,a.createAuth=Le,a.createContext=Pe,a.createCustomRouter=We,a.createElement=U,a.createModel=Ve,a.createModelRouter=qe,a.createRestEndpoints=Je,a.createServer=Me,a.default=ut,a.finishRender=H,a.getPaginationParams=pe,a.hydrate=Ne,a.jsx=L,a.jsxDEV=se,a.jsxs=re,a.paginationMiddleware=ye,a.prepareRender=B,a.render=Y,a.renderToString=O,a.sendError=P,a.sendSuccess=N,a.useContext=De,a.useEffect=$e,a.useErrorBoundary=Oe,a.useMemo=Ie,a.useRef=Re,a.useState=fe,a.validateRequest=Ue,Object.defineProperties(a,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
package/dist/index.d.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import { jsx, jsxs, createElement, Fragment } from './jsx-runtime/index';
|
1
|
+
import { jsx, jsxs, jsxDEV, createElement, Fragment } from './jsx-runtime/index';
|
2
2
|
import { Component } from './component';
|
3
3
|
import { useState, useEffect, useRef, useMemo, useErrorBoundary } from './hooks';
|
4
4
|
import { render, hydrate } from './renderer';
|
@@ -12,7 +12,8 @@ import { createModel, FieldTypes } from './backend/model';
|
|
12
12
|
import { createModelRouter, createApiRouter as createCustomRouter } from './backend/router';
|
13
13
|
import { sendSuccess, sendError, apiResponse, getPaginationParams, paginationMiddleware, validateRequest, asyncHandler, createRestEndpoints, createApiRouter } from './backend/api-utils';
|
14
14
|
import { DatabaseConnector } from './backend/database';
|
15
|
-
export { jsx, jsxs,
|
15
|
+
export { jsx, jsxs, jsxDEV, // Add jsxDEV export
|
16
|
+
createElement, Fragment };
|
16
17
|
export { useState, useEffect, useRef, useMemo, useErrorBoundary, prepareRender, finishRender, batchUpdates, createContext, useContext };
|
17
18
|
export { Component };
|
18
19
|
export { render, hydrate, renderToString };
|
@@ -24,6 +25,7 @@ export type { AuthOptions, TokenPair } from './backend/auth';
|
|
24
25
|
declare const _default: {
|
25
26
|
jsx: typeof jsx;
|
26
27
|
jsxs: typeof jsxs;
|
28
|
+
jsxDEV: typeof jsx;
|
27
29
|
createElement: typeof createElement;
|
28
30
|
Fragment: symbol;
|
29
31
|
Component: typeof Component;
|
package/dist/index.js
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
// Frontend exports
|
2
|
-
import { jsx, jsxs, createElement, Fragment } from './jsx-runtime/index';
|
2
|
+
import { jsx, jsxs, jsxDEV, createElement, Fragment } from './jsx-runtime/index';
|
3
3
|
import { Component } from './component';
|
4
4
|
import { useState, useEffect, useRef, useMemo, useErrorBoundary } from './hooks';
|
5
5
|
import { render, hydrate } from './renderer';
|
@@ -15,7 +15,8 @@ import { createModelRouter, createApiRouter as createCustomRouter } from './back
|
|
15
15
|
import { sendSuccess, sendError, apiResponse, getPaginationParams, paginationMiddleware, validateRequest, asyncHandler, createRestEndpoints, createApiRouter } from './backend/api-utils';
|
16
16
|
import { DatabaseConnector } from './backend/database';
|
17
17
|
// Export JSX runtime
|
18
|
-
export { jsx, jsxs,
|
18
|
+
export { jsx, jsxs, jsxDEV, // Add jsxDEV export
|
19
|
+
createElement, Fragment };
|
19
20
|
// Export hooks
|
20
21
|
export { useState, useEffect, useRef, useMemo, useErrorBoundary, prepareRender, finishRender, batchUpdates, createContext, useContext };
|
21
22
|
// Export component base class
|
@@ -29,6 +30,7 @@ export default {
|
|
29
30
|
// Frontend
|
30
31
|
jsx,
|
31
32
|
jsxs,
|
33
|
+
jsxDEV, // Add to default export
|
32
34
|
createElement,
|
33
35
|
Fragment,
|
34
36
|
Component,
|
@@ -1,8 +1,10 @@
|
|
1
|
-
import { jsx, jsxs, createElement, Fragment } from './jsx-runtime';
|
2
|
-
export { jsx, jsxs,
|
1
|
+
import { jsx, jsxs, createElement, Fragment, jsxDEV } from './jsx-runtime';
|
2
|
+
export { jsx, jsxs, jsxDEV, // Add export for jsxDEV
|
3
|
+
createElement, Fragment };
|
3
4
|
declare const _default: {
|
4
5
|
jsx: typeof jsx;
|
5
6
|
jsxs: typeof jsxs;
|
7
|
+
jsxDEV: typeof jsx;
|
6
8
|
createElement: typeof createElement;
|
7
9
|
Fragment: symbol;
|
8
10
|
};
|
@@ -1,16 +1,19 @@
|
|
1
|
-
import { jsx, jsxs, createElement, Fragment } from './jsx-runtime';
|
2
|
-
export { jsx, jsxs,
|
1
|
+
import { jsx, jsxs, createElement, Fragment, jsxDEV } from './jsx-runtime';
|
2
|
+
export { jsx, jsxs, jsxDEV, // Add export for jsxDEV
|
3
|
+
createElement, Fragment };
|
3
4
|
// For global access in browsers
|
4
5
|
if (typeof window !== 'undefined') {
|
5
6
|
// TypeScript safe way to add properties to window
|
6
7
|
window.jsx = jsx;
|
7
8
|
window.jsxs = jsxs;
|
9
|
+
window.jsxDEV = jsxDEV; // Add jsxDEV
|
8
10
|
window.Fragment = Fragment;
|
9
11
|
}
|
10
12
|
// Default export for module usage
|
11
13
|
export default {
|
12
14
|
jsx,
|
13
15
|
jsxs,
|
16
|
+
jsxDEV,
|
14
17
|
createElement,
|
15
18
|
Fragment
|
16
19
|
};
|
@@ -2,3 +2,4 @@ export declare function jsx(type: string | Function, props: any, key?: string):
|
|
2
2
|
export declare function jsxs(type: string | Function, props: any, key?: string): any;
|
3
3
|
export declare function createElement(vnode: any): HTMLElement | Text;
|
4
4
|
export declare const Fragment: unique symbol;
|
5
|
+
export declare const jsxDEV: typeof jsx;
|
@@ -8,6 +8,7 @@ export function jsx(type, props, key) {
|
|
8
8
|
key
|
9
9
|
};
|
10
10
|
}
|
11
|
+
// Use the jsx function for jsxs as well
|
11
12
|
export function jsxs(type, props, key) {
|
12
13
|
return jsx(type, props, key);
|
13
14
|
}
|
@@ -89,3 +90,6 @@ export function createElement(vnode) {
|
|
89
90
|
return element;
|
90
91
|
}
|
91
92
|
export const Fragment = Symbol('Fragment');
|
93
|
+
// Add named exports for React JSX compatibility
|
94
|
+
export const jsxDEV = jsx;
|
95
|
+
// Don't export jsxs again - it's already exported above
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
// Frontend exports
|
2
|
-
import { jsx, jsxs, createElement, Fragment } from './jsx-runtime/index';
|
2
|
+
import { jsx, jsxs, jsxDEV, createElement, Fragment } from './jsx-runtime/index';
|
3
3
|
import { Component } from './component';
|
4
4
|
import { useState, useEffect, useRef, useMemo, useErrorBoundary } from './hooks';
|
5
5
|
import { render, hydrate } from './renderer';
|
@@ -30,6 +30,7 @@ import { DatabaseConnector } from './backend/database';
|
|
30
30
|
export {
|
31
31
|
jsx,
|
32
32
|
jsxs,
|
33
|
+
jsxDEV, // Add jsxDEV export
|
33
34
|
createElement,
|
34
35
|
Fragment
|
35
36
|
};
|
@@ -104,6 +105,7 @@ export default {
|
|
104
105
|
// Frontend
|
105
106
|
jsx,
|
106
107
|
jsxs,
|
108
|
+
jsxDEV, // Add to default export
|
107
109
|
createElement,
|
108
110
|
Fragment,
|
109
111
|
Component,
|
package/src/jsx-runtime/index.ts
CHANGED
@@ -1,8 +1,9 @@
|
|
1
|
-
import { jsx, jsxs, createElement, Fragment } from './jsx-runtime';
|
1
|
+
import { jsx, jsxs, createElement, Fragment, jsxDEV } from './jsx-runtime';
|
2
2
|
|
3
3
|
export {
|
4
4
|
jsx,
|
5
5
|
jsxs,
|
6
|
+
jsxDEV, // Add export for jsxDEV
|
6
7
|
createElement,
|
7
8
|
Fragment
|
8
9
|
};
|
@@ -12,6 +13,7 @@ if (typeof window !== 'undefined') {
|
|
12
13
|
// TypeScript safe way to add properties to window
|
13
14
|
(window as any).jsx = jsx;
|
14
15
|
(window as any).jsxs = jsxs;
|
16
|
+
(window as any).jsxDEV = jsxDEV; // Add jsxDEV
|
15
17
|
(window as any).Fragment = Fragment;
|
16
18
|
}
|
17
19
|
|
@@ -19,6 +21,7 @@ if (typeof window !== 'undefined') {
|
|
19
21
|
export default {
|
20
22
|
jsx,
|
21
23
|
jsxs,
|
24
|
+
jsxDEV,
|
22
25
|
createElement,
|
23
26
|
Fragment
|
24
27
|
};
|
@@ -12,6 +12,7 @@ export function jsx(type: string | Function, props: any, key?: string): any {
|
|
12
12
|
};
|
13
13
|
}
|
14
14
|
|
15
|
+
// Use the jsx function for jsxs as well
|
15
16
|
export function jsxs(type: string | Function, props: any, key?: string): any {
|
16
17
|
return jsx(type, props, key);
|
17
18
|
}
|
@@ -97,3 +98,7 @@ export function createElement(vnode: any): HTMLElement | Text {
|
|
97
98
|
}
|
98
99
|
|
99
100
|
export const Fragment = Symbol('Fragment');
|
101
|
+
|
102
|
+
// Add named exports for React JSX compatibility
|
103
|
+
export const jsxDEV = jsx;
|
104
|
+
// Don't export jsxs again - it's already exported above
|
@@ -12,7 +12,8 @@ const api = createApiClient({
|
|
12
12
|
document.addEventListener('DOMContentLoaded', () => {
|
13
13
|
const rootElement = document.getElementById('app');
|
14
14
|
if (rootElement) {
|
15
|
-
|
15
|
+
// Call App as a function to create the VDOM structure
|
16
|
+
render(App({ api }), rootElement);
|
16
17
|
console.log('App rendered successfully');
|
17
18
|
} else {
|
18
19
|
console.error('Root element #app not found');
|
@@ -13,7 +13,13 @@
|
|
13
13
|
"strict": true,
|
14
14
|
"noUnusedLocals": true,
|
15
15
|
"noUnusedParameters": true,
|
16
|
-
"noFallthroughCasesInSwitch": true
|
16
|
+
"noFallthroughCasesInSwitch": true,
|
17
|
+
"paths": {
|
18
|
+
"react": ["./node_modules/frontend-hamroun"],
|
19
|
+
"react-dom": ["./node_modules/frontend-hamroun"],
|
20
|
+
"react/jsx-runtime": ["./node_modules/frontend-hamroun"],
|
21
|
+
"react/jsx-dev-runtime": ["./node_modules/frontend-hamroun"]
|
22
|
+
}
|
17
23
|
},
|
18
24
|
"include": ["src"],
|
19
25
|
"references": [{ "path": "./tsconfig.node.json" }]
|
@@ -8,6 +8,10 @@ export default defineConfig({
|
|
8
8
|
rollupOptions: {
|
9
9
|
// Mark server-side dependencies as external
|
10
10
|
external: [
|
11
|
+
'react',
|
12
|
+
'react-dom',
|
13
|
+
'react/jsx-runtime',
|
14
|
+
'react/jsx-dev-runtime',
|
11
15
|
'express',
|
12
16
|
'compression',
|
13
17
|
'helmet',
|
@@ -42,7 +46,12 @@ export default defineConfig({
|
|
42
46
|
// Remove any Node.js specific imports that might cause issues
|
43
47
|
'bcrypt': 'frontend-hamroun',
|
44
48
|
'jsonwebtoken': 'frontend-hamroun',
|
45
|
-
'mongoose': 'frontend-hamroun'
|
49
|
+
'mongoose': 'frontend-hamroun',
|
50
|
+
// Alias React imports to empty modules
|
51
|
+
'react': 'frontend-hamroun',
|
52
|
+
'react-dom': 'frontend-hamroun',
|
53
|
+
'react/jsx-runtime': 'frontend-hamroun',
|
54
|
+
'react/jsx-dev-runtime': 'frontend-hamroun'
|
46
55
|
}
|
47
56
|
}
|
48
57
|
});
|