frontend-hamroun 1.2.8 → 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/scripts/build-cli.js +242 -0
- 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/tsconfig.node.json +10 -0
- package/templates/basic-app/src/main.ts +2 -1
- package/templates/basic-app/tsconfig.json +7 -1
- package/templates/basic-app/tsconfig.node.json +10 -0
- package/templates/basic-app/vite.config.ts +10 -1
- package/templates/full-stack/tsconfig.node.json +10 -0
@@ -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
|
};
|