frontend-hamroun 1.2.13 → 1.2.15
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/backend/auth.js +3 -4
- package/dist/frontend-hamroun.es.js +232 -234
- package/dist/frontend-hamroun.umd.js +9 -9
- package/package.json +1 -1
- package/src/backend/auth.ts +4 -4
- package/templates/basic/tsconfig.json +0 -3
- package/templates/basic-app/index.html +6 -6
- package/templates/basic-app/src/App.js +105 -0
- package/templates/basic-app/src/main.js +10 -0
- package/templates/basic-app/vite.config.js +22 -0
- package/templates/full-stack/tsconfig.json +0 -3
@@ -1,18 +1,16 @@
|
|
1
|
-
import O, { Router as
|
1
|
+
import O, { Router as me } from "express";
|
2
2
|
import de from "path";
|
3
|
-
import
|
4
|
-
import
|
5
|
-
import
|
3
|
+
import Ne from "compression";
|
4
|
+
import Oe from "helmet";
|
5
|
+
import De from "morgan";
|
6
6
|
import j from "mongoose";
|
7
|
-
import
|
8
|
-
import
|
9
|
-
|
10
|
-
|
11
|
-
const he = globalThis || void 0 || self;
|
12
|
-
function Le(r) {
|
7
|
+
import Pe from "fs";
|
8
|
+
import "bcrypt";
|
9
|
+
const fe = globalThis || void 0 || self;
|
10
|
+
function Me(r) {
|
13
11
|
return r && r.__esModule && Object.prototype.hasOwnProperty.call(r, "default") ? r.default : r;
|
14
12
|
}
|
15
|
-
var
|
13
|
+
var ye = { exports: {} }, m = ye.exports = {}, k, v;
|
16
14
|
function re() {
|
17
15
|
throw new Error("setTimeout has not been defined");
|
18
16
|
}
|
@@ -31,7 +29,7 @@ function se() {
|
|
31
29
|
v = se;
|
32
30
|
}
|
33
31
|
})();
|
34
|
-
function
|
32
|
+
function ge(r) {
|
35
33
|
if (k === setTimeout)
|
36
34
|
return setTimeout(r, 0);
|
37
35
|
if ((k === re || !k) && setTimeout)
|
@@ -46,7 +44,7 @@ function we(r) {
|
|
46
44
|
}
|
47
45
|
}
|
48
46
|
}
|
49
|
-
function
|
47
|
+
function Fe(r) {
|
50
48
|
if (v === clearTimeout)
|
51
49
|
return clearTimeout(r);
|
52
50
|
if ((v === se || !v) && clearTimeout)
|
@@ -62,19 +60,19 @@ function Ve(r) {
|
|
62
60
|
}
|
63
61
|
}
|
64
62
|
var x = [], P = !1, _, B = -1;
|
65
|
-
function
|
66
|
-
!P || !_ || (P = !1, _.length ? x = _.concat(x) : B = -1, x.length &&
|
63
|
+
function Le() {
|
64
|
+
!P || !_ || (P = !1, _.length ? x = _.concat(x) : B = -1, x.length && we());
|
67
65
|
}
|
68
|
-
function
|
66
|
+
function we() {
|
69
67
|
if (!P) {
|
70
|
-
var r =
|
68
|
+
var r = ge(Le);
|
71
69
|
P = !0;
|
72
70
|
for (var t = x.length; t; ) {
|
73
71
|
for (_ = x, x = []; ++B < t; )
|
74
72
|
_ && _[B].run();
|
75
73
|
B = -1, t = x.length;
|
76
74
|
}
|
77
|
-
_ = null, P = !1,
|
75
|
+
_ = null, P = !1, Fe(r);
|
78
76
|
}
|
79
77
|
}
|
80
78
|
m.nextTick = function(r) {
|
@@ -82,12 +80,12 @@ m.nextTick = function(r) {
|
|
82
80
|
if (arguments.length > 1)
|
83
81
|
for (var e = 1; e < arguments.length; e++)
|
84
82
|
t[e - 1] = arguments[e];
|
85
|
-
x.push(new
|
83
|
+
x.push(new Ee(r, t)), x.length === 1 && !P && ge(we);
|
86
84
|
};
|
87
|
-
function
|
85
|
+
function Ee(r, t) {
|
88
86
|
this.fun = r, this.array = t;
|
89
87
|
}
|
90
|
-
|
88
|
+
Ee.prototype.run = function() {
|
91
89
|
this.fun.apply(null, this.array);
|
92
90
|
};
|
93
91
|
m.title = "browser";
|
@@ -122,8 +120,8 @@ m.chdir = function(r) {
|
|
122
120
|
m.umask = function() {
|
123
121
|
return 0;
|
124
122
|
};
|
125
|
-
var
|
126
|
-
const w = /* @__PURE__ */
|
123
|
+
var Ve = ye.exports;
|
124
|
+
const w = /* @__PURE__ */ Me(Ve), $ = typeof window < "u" ? window : typeof fe < "u" ? fe : {};
|
127
125
|
function J(r, t, e) {
|
128
126
|
return {
|
129
127
|
type: r,
|
@@ -131,7 +129,7 @@ function J(r, t, e) {
|
|
131
129
|
key: e
|
132
130
|
};
|
133
131
|
}
|
134
|
-
function
|
132
|
+
function be(r, t, e) {
|
135
133
|
return J(r, t, e);
|
136
134
|
}
|
137
135
|
function ne(r) {
|
@@ -154,10 +152,10 @@ function ne(r) {
|
|
154
152
|
renderTime: 0
|
155
153
|
}, typeof afterAll == "function" && afterAll(() => {
|
156
154
|
try {
|
157
|
-
const
|
158
|
-
|
159
|
-
} catch (
|
160
|
-
console.error("Failed to write stats file:",
|
155
|
+
const c = require("fs"), d = require("path").resolve(w.cwd(), "jsx-runtime-stats.json");
|
156
|
+
c.writeFileSync(d, JSON.stringify($.__renderStats, null, 2)), console.log(`JSX runtime stats written to ${d}`);
|
157
|
+
} catch (c) {
|
158
|
+
console.error("Failed to write stats file:", c);
|
161
159
|
}
|
162
160
|
})), o instanceof Text ? $.__renderStats.textNodesCreated++ : $.__renderStats.elementsCreated++), t.appendChild(o);
|
163
161
|
}
|
@@ -170,12 +168,12 @@ function ne(r) {
|
|
170
168
|
}) : t.setAttribute(e, s);
|
171
169
|
}), t;
|
172
170
|
}
|
173
|
-
const
|
174
|
-
typeof window < "u" && (window.jsx = J, window.jsxs =
|
175
|
-
const
|
171
|
+
const Te = Symbol("Fragment"), ke = J;
|
172
|
+
typeof window < "u" && (window.jsx = J, window.jsxs = be, window.jsxDEV = ke, window.Fragment = Te);
|
173
|
+
const Be = typeof window < "u" && typeof document < "u";
|
176
174
|
async function C(r) {
|
177
175
|
var t;
|
178
|
-
if (console.log("Creating element from:", r), !
|
176
|
+
if (console.log("Creating element from:", r), !Be) {
|
179
177
|
if (r == null)
|
180
178
|
return { nodeType: 3, textContent: "" };
|
181
179
|
if (typeof r == "boolean")
|
@@ -205,25 +203,25 @@ async function C(r) {
|
|
205
203
|
attributes: {},
|
206
204
|
style: {},
|
207
205
|
childNodes: [],
|
208
|
-
setAttribute: function(o,
|
209
|
-
this.attributes[o] =
|
206
|
+
setAttribute: function(o, c) {
|
207
|
+
this.attributes[o] = c;
|
210
208
|
},
|
211
209
|
appendChild: function(o) {
|
212
210
|
this.childNodes.push(o);
|
213
211
|
}
|
214
212
|
};
|
215
|
-
for (const [o,
|
213
|
+
for (const [o, c] of Object.entries(s || {}))
|
216
214
|
if (o !== "children")
|
217
|
-
if (o.startsWith("on") && typeof
|
218
|
-
const
|
219
|
-
n.__events || (n.__events = {}), n.__events[
|
220
|
-
} else o === "style" && typeof
|
215
|
+
if (o.startsWith("on") && typeof c == "function") {
|
216
|
+
const a = o.toLowerCase().slice(2);
|
217
|
+
n.__events || (n.__events = {}), n.__events[a] = c;
|
218
|
+
} else o === "style" && typeof c == "object" ? Object.assign(n.style, c) : o === "className" ? n.setAttribute("class", String(c)) : o !== "key" && o !== "ref" && n.setAttribute(o, String(c));
|
221
219
|
const i = s == null ? void 0 : s.children;
|
222
220
|
if (i != null) {
|
223
221
|
const o = Array.isArray(i) ? i.flat() : [i];
|
224
|
-
for (const
|
225
|
-
const
|
226
|
-
n.appendChild(
|
222
|
+
for (const c of o) {
|
223
|
+
const a = await C(c);
|
224
|
+
n.appendChild(a);
|
227
225
|
}
|
228
226
|
}
|
229
227
|
return n;
|
@@ -246,31 +244,31 @@ async function C(r) {
|
|
246
244
|
const { type: e, props: s } = r;
|
247
245
|
if (typeof e == "function")
|
248
246
|
try {
|
249
|
-
const o = await e(s || {}),
|
250
|
-
return
|
247
|
+
const o = await e(s || {}), c = await C(o);
|
248
|
+
return c instanceof Element && c.setAttribute("data-component-id", e.name || e.toString()), c;
|
251
249
|
} catch (o) {
|
252
250
|
return console.error("Error rendering component:", o), document.createTextNode("");
|
253
251
|
}
|
254
252
|
const n = document.createElement(e);
|
255
|
-
for (const [o,
|
253
|
+
for (const [o, c] of Object.entries(s || {}))
|
256
254
|
if (o !== "children")
|
257
|
-
if (o.startsWith("on") && typeof
|
258
|
-
const
|
259
|
-
d && n.removeEventListener(
|
260
|
-
} else o === "style" && typeof
|
255
|
+
if (o.startsWith("on") && typeof c == "function") {
|
256
|
+
const a = o.toLowerCase().slice(2), d = (t = n.__events) == null ? void 0 : t[a];
|
257
|
+
d && n.removeEventListener(a, d), n.addEventListener(a, c), n.__events || (n.__events = {}), n.__events[a] = c;
|
258
|
+
} else o === "style" && typeof c == "object" ? Object.assign(n.style, c) : o === "className" ? n.setAttribute("class", String(c)) : o !== "key" && o !== "ref" && n.setAttribute(o, String(c));
|
261
259
|
const i = s == null ? void 0 : s.children;
|
262
260
|
if (i != null) {
|
263
261
|
const o = Array.isArray(i) ? i.flat() : [i];
|
264
|
-
for (const
|
265
|
-
const
|
266
|
-
n.appendChild(
|
262
|
+
for (const c of o) {
|
263
|
+
const a = await C(c);
|
264
|
+
n.appendChild(a);
|
267
265
|
}
|
268
266
|
}
|
269
267
|
return n;
|
270
268
|
}
|
271
269
|
return document.createTextNode(String(r));
|
272
270
|
}
|
273
|
-
class
|
271
|
+
class He {
|
274
272
|
constructor(t = {}) {
|
275
273
|
this.state = {}, this.element = null, this._mounted = !1, this.props = t;
|
276
274
|
}
|
@@ -315,16 +313,16 @@ class Ue {
|
|
315
313
|
}
|
316
314
|
}
|
317
315
|
let H = !1;
|
318
|
-
const
|
319
|
-
function
|
316
|
+
const X = [];
|
317
|
+
function ae(r) {
|
320
318
|
if (H) {
|
321
|
-
|
319
|
+
X.push(r);
|
322
320
|
return;
|
323
321
|
}
|
324
322
|
H = !0;
|
325
323
|
try {
|
326
|
-
for (r();
|
327
|
-
const t =
|
324
|
+
for (r(); X.length > 0; ) {
|
325
|
+
const t = X.shift();
|
328
326
|
t == null || t();
|
329
327
|
}
|
330
328
|
} finally {
|
@@ -332,39 +330,39 @@ function ce(r) {
|
|
332
330
|
}
|
333
331
|
}
|
334
332
|
let u = 0;
|
335
|
-
const
|
336
|
-
let oe = null, ie = null,
|
337
|
-
const
|
338
|
-
function
|
339
|
-
oe = r, ie = e,
|
333
|
+
const Z = /* @__PURE__ */ new Map(), b = /* @__PURE__ */ new Map(), L = /* @__PURE__ */ new Map(), K = /* @__PURE__ */ new Map(), ee = /* @__PURE__ */ new Map();
|
334
|
+
let oe = null, ie = null, ce = null;
|
335
|
+
const ve = typeof window > "u", W = /* @__PURE__ */ new Map();
|
336
|
+
function Se(r, t, e) {
|
337
|
+
oe = r, ie = e, ce = t;
|
340
338
|
}
|
341
339
|
function U() {
|
342
340
|
return u++, b.set(u, 0), u;
|
343
341
|
}
|
344
342
|
function q() {
|
345
|
-
|
343
|
+
ve && W.delete(u), u = 0;
|
346
344
|
}
|
347
|
-
function
|
345
|
+
function xe(r) {
|
348
346
|
if (!u)
|
349
347
|
throw new Error("useState must be called within a render");
|
350
|
-
if (
|
348
|
+
if (ve) {
|
351
349
|
W.has(u) || W.set(u, /* @__PURE__ */ new Map());
|
352
350
|
const i = W.get(u), o = b.get(u) || 0;
|
353
351
|
i.has(o) || i.set(o, r);
|
354
|
-
const
|
352
|
+
const c = i.get(o), a = (d) => {
|
355
353
|
};
|
356
|
-
return b.set(u, o + 1), [
|
354
|
+
return b.set(u, o + 1), [c, a];
|
357
355
|
}
|
358
|
-
|
359
|
-
const t =
|
356
|
+
Z.has(u) || Z.set(u, []);
|
357
|
+
const t = Z.get(u), e = b.get(u);
|
360
358
|
e >= t.length && t.push(r);
|
361
359
|
const s = t[e], n = (i) => {
|
362
360
|
const o = typeof i == "function" ? i(t[e]) : i;
|
363
|
-
t[e] !== o && (t[e] = o, H ?
|
361
|
+
t[e] !== o && (t[e] = o, H ? ae(() => he(u)) : he(u));
|
364
362
|
};
|
365
363
|
return b.set(u, e + 1), [s, n];
|
366
364
|
}
|
367
|
-
function
|
365
|
+
function We(r, t) {
|
368
366
|
if (!u) throw new Error("useEffect must be called within a render");
|
369
367
|
const e = b.get(u);
|
370
368
|
L.has(u) || L.set(u, []);
|
@@ -374,22 +372,22 @@ function qe(r, t) {
|
|
374
372
|
s[e] = { cleanup: i, deps: t };
|
375
373
|
})), b.set(u, e + 1);
|
376
374
|
}
|
377
|
-
function
|
375
|
+
function Ue(r, t) {
|
378
376
|
if (!u) throw new Error("useMemo must be called within a render");
|
379
377
|
const e = b.get(u);
|
380
|
-
|
381
|
-
const s =
|
378
|
+
K.has(u) || K.set(u, []);
|
379
|
+
const s = K.get(u), n = s[e];
|
382
380
|
if (!n || t && t.some((i, o) => !Object.is(i, n.deps[o]))) {
|
383
381
|
const i = r();
|
384
382
|
return s[e] = { value: i, deps: t }, b.set(u, e + 1), i;
|
385
383
|
}
|
386
384
|
return b.set(u, e + 1), n.value;
|
387
385
|
}
|
388
|
-
function
|
386
|
+
function qe(r) {
|
389
387
|
if (!u) throw new Error("useRef must be called within a render");
|
390
388
|
const t = b.get(u);
|
391
|
-
|
392
|
-
const e =
|
389
|
+
ee.has(u) || ee.set(u, []);
|
390
|
+
const e = ee.get(u);
|
393
391
|
if (t >= e.length) {
|
394
392
|
const n = { current: r };
|
395
393
|
return e.push(n), b.set(u, t + 1), n;
|
@@ -397,22 +395,22 @@ function Je(r) {
|
|
397
395
|
const s = e[t];
|
398
396
|
return b.set(u, t + 1), s;
|
399
397
|
}
|
400
|
-
async function
|
398
|
+
async function he(r) {
|
401
399
|
try {
|
402
400
|
const t = L.get(r);
|
403
401
|
t && (t.forEach((e) => {
|
404
402
|
e.cleanup && e.cleanup();
|
405
|
-
}), L.set(r, [])), oe && ie &&
|
403
|
+
}), L.set(r, [])), oe && ie && ce && await oe(ce, ie);
|
406
404
|
} catch (t) {
|
407
405
|
console.error("Error during rerender:", t);
|
408
406
|
}
|
409
407
|
}
|
410
|
-
function
|
411
|
-
const [r, t] =
|
408
|
+
function Ge() {
|
409
|
+
const [r, t] = xe(null);
|
412
410
|
return [r, () => t(null)];
|
413
411
|
}
|
414
412
|
let G = !1;
|
415
|
-
async function
|
413
|
+
async function Je(r, t) {
|
416
414
|
G = !0;
|
417
415
|
try {
|
418
416
|
await ue(r, t);
|
@@ -421,10 +419,10 @@ async function Ye(r, t) {
|
|
421
419
|
}
|
422
420
|
}
|
423
421
|
async function ue(r, t) {
|
424
|
-
console.log("Rendering to:", t.id || "unnamed-container"),
|
422
|
+
console.log("Rendering to:", t.id || "unnamed-container"), ae(async () => {
|
425
423
|
const e = U();
|
426
424
|
try {
|
427
|
-
|
425
|
+
Se(ue, r, t);
|
428
426
|
const s = await C(r);
|
429
427
|
G || (t.innerHTML = ""), G && t.firstChild ? console.log("Hydrating existing DOM") : t.appendChild(s);
|
430
428
|
} finally {
|
@@ -433,7 +431,7 @@ async function ue(r, t) {
|
|
433
431
|
});
|
434
432
|
}
|
435
433
|
async function D(r) {
|
436
|
-
U(),
|
434
|
+
U(), Se(() => {
|
437
435
|
}, r, null);
|
438
436
|
try {
|
439
437
|
if (r == null || typeof r == "boolean") return "";
|
@@ -460,7 +458,7 @@ async function D(r) {
|
|
460
458
|
}
|
461
459
|
let s = `<${t}`;
|
462
460
|
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="${
|
461
|
+
i === "children" || i === "key" || (i === "className" ? s += ` class="${V(String(o))}"` : i === "style" && typeof o == "object" ? s += ` style="${Qe(o || {})}"` : i.startsWith("on") || (s += ` ${i}="${V(String(o))}"`));
|
464
462
|
if ((/* @__PURE__ */ new Set([
|
465
463
|
"area",
|
466
464
|
"base",
|
@@ -493,13 +491,13 @@ async function D(r) {
|
|
493
491
|
function V(r) {
|
494
492
|
return r.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
495
493
|
}
|
496
|
-
function
|
497
|
-
return Object.entries(r).map(([t, e]) => `${
|
494
|
+
function Qe(r) {
|
495
|
+
return Object.entries(r).map(([t, e]) => `${Ye(t)}:${e}`).join(";");
|
498
496
|
}
|
499
|
-
function
|
497
|
+
function Ye(r) {
|
500
498
|
return r.replace(/[A-Z]/g, (t) => "-" + t.toLowerCase());
|
501
499
|
}
|
502
|
-
function
|
500
|
+
function ze(r) {
|
503
501
|
const t = {
|
504
502
|
_currentValue: r,
|
505
503
|
Provider: function({ value: s, children: n }) {
|
@@ -511,10 +509,10 @@ function Ze(r) {
|
|
511
509
|
};
|
512
510
|
return t;
|
513
511
|
}
|
514
|
-
function
|
512
|
+
function Xe(r) {
|
515
513
|
return r._currentValue;
|
516
514
|
}
|
517
|
-
class
|
515
|
+
class Ae {
|
518
516
|
// Renamed from isConnected to _connected
|
519
517
|
constructor(t) {
|
520
518
|
this.connection = null, this._connected = !1, this.options = {
|
@@ -576,29 +574,29 @@ class Ce {
|
|
576
574
|
return this.connection;
|
577
575
|
}
|
578
576
|
}
|
579
|
-
function
|
577
|
+
function Ze(r = {}) {
|
580
578
|
const t = O(), {
|
581
579
|
port: e = 3e3,
|
582
580
|
staticDir: s = "public",
|
583
581
|
enableCors: n = !0,
|
584
582
|
apiPrefix: i = "/api",
|
585
583
|
ssrEnabled: o = !0,
|
586
|
-
middlewares:
|
587
|
-
enableCompression:
|
584
|
+
middlewares: c = [],
|
585
|
+
enableCompression: a = !0,
|
588
586
|
enableHelmet: d = !0,
|
589
587
|
logFormat: h = "dev",
|
590
588
|
trustProxy: E = !1,
|
591
589
|
showErrorDetails: S = w.env.NODE_ENV !== "production"
|
592
590
|
} = r;
|
593
|
-
if (E && t.set("trust proxy", E), t.use(O.json()), t.use(O.urlencoded({ extended: !0 })),
|
591
|
+
if (E && t.set("trust proxy", E), t.use(O.json()), t.use(O.urlencoded({ extended: !0 })), a && t.use(Ne()), d && t.use(Oe({
|
594
592
|
contentSecurityPolicy: r.disableCSP ? !1 : void 0
|
595
|
-
})), h && t.use(
|
593
|
+
})), h && t.use(De(h)), n && t.use((l, p, f) => {
|
596
594
|
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")
|
597
595
|
return p.sendStatus(200);
|
598
596
|
f();
|
599
|
-
}),
|
597
|
+
}), c.forEach((l) => t.use(l)), s) {
|
600
598
|
const l = de.resolve(w.cwd(), s);
|
601
|
-
|
599
|
+
Pe.existsSync(l) ? (t.use(O.static(l, {
|
602
600
|
maxAge: r.staticCacheAge || "1d",
|
603
601
|
etag: !0
|
604
602
|
})), console.log(`📂 Serving static files from: ${l}`)) : console.warn(`⚠️ Static directory not found: ${l}`);
|
@@ -606,7 +604,7 @@ function et(r = {}) {
|
|
606
604
|
let y = null;
|
607
605
|
t.connectToDatabase = async (l) => {
|
608
606
|
try {
|
609
|
-
return y && y.isConnected() ? (console.log("✅ Using existing database connection"), y) : (y = new
|
607
|
+
return y && y.isConnected() ? (console.log("✅ Using existing database connection"), y) : (y = new Ae(l), await y.connect(), console.log("✅ Database connected successfully"), w.on("SIGTERM", async () => {
|
610
608
|
y && y.isConnected() && (await y.disconnect(), console.log("Database connection closed"));
|
611
609
|
}), y);
|
612
610
|
} catch (p) {
|
@@ -633,7 +631,7 @@ function et(r = {}) {
|
|
633
631
|
query: g.query,
|
634
632
|
user: g.user,
|
635
633
|
...f.props
|
636
|
-
},
|
634
|
+
}, _e = await D(p(z));
|
637
635
|
T.send(`
|
638
636
|
<!DOCTYPE html>
|
639
637
|
<html lang="${f.lang || "en"}">
|
@@ -641,7 +639,7 @@ function et(r = {}) {
|
|
641
639
|
<meta charset="UTF-8">
|
642
640
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
643
641
|
<title>${f.title || "Frontend Hamroun App"}</title>
|
644
|
-
${f.meta ? f.meta.map((F) => `<meta ${Object.entries(F).map(([
|
642
|
+
${f.meta ? f.meta.map((F) => `<meta ${Object.entries(F).map(([Ie, Re]) => `${Ie}="${Re}"`).join(" ")}>`).join(`
|
645
643
|
`) : ""}
|
646
644
|
${f.head || ""}
|
647
645
|
${f.styles ? `<style>${f.styles}</style>` : ""}
|
@@ -649,7 +647,7 @@ function et(r = {}) {
|
|
649
647
|
`) : ""}
|
650
648
|
</head>
|
651
649
|
<body ${f.bodyAttributes || ""}>
|
652
|
-
<div id="${f.rootId || "root"}">${
|
650
|
+
<div id="${f.rootId || "root"}">${_e}</div>
|
653
651
|
<script>
|
654
652
|
window.__INITIAL_DATA__ = ${JSON.stringify(f.initialData || {})};
|
655
653
|
<\/script>
|
@@ -728,8 +726,8 @@ ${Object.keys(Q).map((g) => ` ${g}`).join(`
|
|
728
726
|
return w.on("SIGTERM", () => f("SIGTERM")), w.on("SIGINT", () => f("SIGINT")), p;
|
729
727
|
}, t;
|
730
728
|
}
|
731
|
-
const
|
732
|
-
class
|
729
|
+
const te = require("jsonwebtoken"), pe = require("bcrypt"), Ke = require("crypto");
|
730
|
+
class et {
|
733
731
|
constructor(t) {
|
734
732
|
if (this.loginAttempts = /* @__PURE__ */ new Map(), this.login = async (e, s) => {
|
735
733
|
try {
|
@@ -755,8 +753,8 @@ class tt {
|
|
755
753
|
});
|
756
754
|
return;
|
757
755
|
}
|
758
|
-
const
|
759
|
-
if (!
|
756
|
+
const c = await this.options.findUser(n);
|
757
|
+
if (!c) {
|
760
758
|
s.status(401).json({
|
761
759
|
success: !1,
|
762
760
|
message: "Invalid credentials"
|
@@ -765,7 +763,7 @@ class tt {
|
|
765
763
|
}
|
766
764
|
if (!await this.options.verifyPassword(
|
767
765
|
i,
|
768
|
-
|
766
|
+
c.password
|
769
767
|
)) {
|
770
768
|
s.status(401).json({
|
771
769
|
success: !1,
|
@@ -773,17 +771,17 @@ class tt {
|
|
773
771
|
});
|
774
772
|
return;
|
775
773
|
}
|
776
|
-
const d = { ...
|
774
|
+
const d = { ...c };
|
777
775
|
delete d.password;
|
778
776
|
const h = this.generateTokenPair({
|
779
|
-
id:
|
780
|
-
username:
|
781
|
-
role:
|
777
|
+
id: c.id || c._id,
|
778
|
+
username: c.username,
|
779
|
+
role: c.role || "user"
|
782
780
|
});
|
783
781
|
if (this.options.saveRefreshToken) {
|
784
782
|
const E = /* @__PURE__ */ new Date();
|
785
783
|
E.setSeconds(E.getSeconds() + this.getExpirationSeconds(this.options.refreshExpiration || "7d")), await this.options.saveRefreshToken(
|
786
|
-
|
784
|
+
c.id || c._id,
|
787
785
|
h.refreshToken,
|
788
786
|
E
|
789
787
|
);
|
@@ -812,31 +810,31 @@ class tt {
|
|
812
810
|
});
|
813
811
|
return;
|
814
812
|
}
|
815
|
-
const
|
816
|
-
if (this.options.verifyRefreshToken && !await this.options.verifyRefreshToken(
|
813
|
+
const c = this.verifyToken(o, "refresh");
|
814
|
+
if (this.options.verifyRefreshToken && !await this.options.verifyRefreshToken(c.id, o)) {
|
817
815
|
this.clearAuthCookies(s), s.status(401).json({
|
818
816
|
success: !1,
|
819
817
|
message: "Invalid refresh token"
|
820
818
|
});
|
821
819
|
return;
|
822
820
|
}
|
823
|
-
const
|
824
|
-
id:
|
821
|
+
const a = this.generateTokenPair({
|
822
|
+
id: c.id,
|
825
823
|
// We need to fetch the user data again for complete payload
|
826
|
-
...this.options.findUser ? await this.options.findUser(
|
824
|
+
...this.options.findUser ? await this.options.findUser(c.id) : {}
|
827
825
|
});
|
828
826
|
if (this.options.saveRefreshToken) {
|
829
827
|
const h = /* @__PURE__ */ new Date();
|
830
828
|
h.setSeconds(h.getSeconds() + this.getExpirationSeconds(this.options.refreshExpiration || "7d")), await this.options.saveRefreshToken(
|
831
|
-
|
832
|
-
|
829
|
+
c.id,
|
830
|
+
a.refreshToken,
|
833
831
|
h
|
834
832
|
);
|
835
833
|
}
|
836
|
-
(((i = e.cookies) == null ? void 0 : i.accessToken) || e.body.useCookies) && this.setAuthCookies(s,
|
834
|
+
(((i = e.cookies) == null ? void 0 : i.accessToken) || e.body.useCookies) && this.setAuthCookies(s, a), s.json({
|
837
835
|
success: !0,
|
838
836
|
message: "Token refreshed successfully",
|
839
|
-
tokens:
|
837
|
+
tokens: a
|
840
838
|
});
|
841
839
|
} catch (o) {
|
842
840
|
this.clearAuthCookies(s), s.status(401).json({
|
@@ -865,8 +863,8 @@ class tt {
|
|
865
863
|
try {
|
866
864
|
let o = (i = e.cookies) == null ? void 0 : i.accessToken;
|
867
865
|
if (!o) {
|
868
|
-
const
|
869
|
-
|
866
|
+
const a = e.headers.authorization;
|
867
|
+
a && a.startsWith("Bearer ") && (o = a.split(" ")[1]);
|
870
868
|
}
|
871
869
|
if (!o) {
|
872
870
|
s.status(401).json({
|
@@ -875,8 +873,8 @@ class tt {
|
|
875
873
|
});
|
876
874
|
return;
|
877
875
|
}
|
878
|
-
const
|
879
|
-
e.user =
|
876
|
+
const c = this.verifyToken(o, "access");
|
877
|
+
e.user = c, n();
|
880
878
|
} catch (o) {
|
881
879
|
s.status(401).json({
|
882
880
|
success: !1,
|
@@ -914,29 +912,29 @@ class tt {
|
|
914
912
|
* Hash a password using bcrypt
|
915
913
|
*/
|
916
914
|
async hashPassword(t) {
|
917
|
-
return await
|
915
|
+
return await pe.hash(t, this.options.saltRounds || 10);
|
918
916
|
}
|
919
917
|
/**
|
920
918
|
* Verify a password against a hash using bcrypt
|
921
919
|
*/
|
922
920
|
async verifyPasswordWithBcrypt(t, e) {
|
923
|
-
return await
|
921
|
+
return await pe.compare(t, e);
|
924
922
|
}
|
925
923
|
/**
|
926
924
|
* Generate a cryptographically secure random token
|
927
925
|
*/
|
928
926
|
generateSecureToken(t = 32) {
|
929
|
-
return
|
927
|
+
return Ke.randomBytes(t).toString("hex");
|
930
928
|
}
|
931
929
|
/**
|
932
930
|
* Generate token pair (access token + refresh token)
|
933
931
|
*/
|
934
932
|
generateTokenPair(t) {
|
935
|
-
const e = this.getExpirationSeconds(this.options.tokenExpiration || "15m"), s =
|
933
|
+
const e = this.getExpirationSeconds(this.options.tokenExpiration || "15m"), s = te.sign(
|
936
934
|
{ ...t, type: "access" },
|
937
935
|
this.options.jwtSecret,
|
938
936
|
{ expiresIn: this.options.tokenExpiration }
|
939
|
-
), n =
|
937
|
+
), n = te.sign(
|
940
938
|
{ id: t.id, type: "refresh" },
|
941
939
|
this.options.refreshSecret,
|
942
940
|
{ expiresIn: this.options.refreshExpiration }
|
@@ -970,7 +968,7 @@ class tt {
|
|
970
968
|
*/
|
971
969
|
verifyToken(t, e = "access") {
|
972
970
|
try {
|
973
|
-
const s = e === "access" ? this.options.jwtSecret : this.options.refreshSecret, n =
|
971
|
+
const s = e === "access" ? this.options.jwtSecret : this.options.refreshSecret, n = te.verify(t, s);
|
974
972
|
if (typeof n == "object" && n.type !== e)
|
975
973
|
throw new Error("Invalid token type");
|
976
974
|
return n;
|
@@ -1017,16 +1015,16 @@ class tt {
|
|
1017
1015
|
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
1016
|
}
|
1019
1017
|
}
|
1020
|
-
function
|
1021
|
-
return new
|
1018
|
+
function tt(r) {
|
1019
|
+
return new et(r);
|
1022
1020
|
}
|
1023
|
-
function
|
1021
|
+
function rt(r, t) {
|
1024
1022
|
const e = j.model(r, t);
|
1025
1023
|
return {
|
1026
1024
|
getAll: async (s) => {
|
1027
1025
|
try {
|
1028
|
-
const { page: n = 1, limit: i = 10, sort: o = "_id", order:
|
1029
|
-
e.find().sort(h).skip(
|
1026
|
+
const { page: n = 1, limit: i = 10, sort: o = "_id", order: c = "desc" } = s || {}, a = (n - 1) * i, d = c === "asc" ? 1 : -1, h = { [o]: d }, [E, S] = await Promise.all([
|
1027
|
+
e.find().sort(h).skip(a).limit(i).exec(),
|
1030
1028
|
e.countDocuments().exec()
|
1031
1029
|
]), y = Math.ceil(S / i);
|
1032
1030
|
return {
|
@@ -1085,7 +1083,7 @@ function st(r, t) {
|
|
1085
1083
|
},
|
1086
1084
|
find: async (s, n) => {
|
1087
1085
|
try {
|
1088
|
-
const { page: i = 1, limit: o = 10, sort:
|
1086
|
+
const { page: i = 1, limit: o = 10, sort: c = "_id", order: a = "desc" } = n || {}, d = (i - 1) * o, h = a === "asc" ? 1 : -1, E = { [c]: h }, [S, y] = await Promise.all([
|
1089
1087
|
e.find(s).sort(E).skip(d).limit(o).exec(),
|
1090
1088
|
e.countDocuments(s).exec()
|
1091
1089
|
]), I = Math.ceil(y / o);
|
@@ -1120,7 +1118,7 @@ function st(r, t) {
|
|
1120
1118
|
}
|
1121
1119
|
};
|
1122
1120
|
}
|
1123
|
-
const
|
1121
|
+
const st = {
|
1124
1122
|
String: { type: String },
|
1125
1123
|
Number: { type: Number },
|
1126
1124
|
Boolean: { type: Boolean },
|
@@ -1139,7 +1137,7 @@ const nt = {
|
|
1139
1137
|
Default: (r, t) => ({ ...r, default: t }),
|
1140
1138
|
// Array field type
|
1141
1139
|
Array: (r) => ({ type: [r] })
|
1142
|
-
},
|
1140
|
+
}, Ce = (r, { res: t }) => {
|
1143
1141
|
console.error("API Error:", r);
|
1144
1142
|
const e = r.status || r.statusCode || 500, s = r.message || "Internal server error";
|
1145
1143
|
t.status(e).json({
|
@@ -1148,91 +1146,91 @@ const nt = {
|
|
1148
1146
|
stack: w.env.NODE_ENV !== "production" ? r.stack : void 0
|
1149
1147
|
});
|
1150
1148
|
};
|
1151
|
-
function
|
1152
|
-
const e = O.Router(), { middleware: s = [], errorHandler: n =
|
1149
|
+
function nt(r, t = {}) {
|
1150
|
+
const e = O.Router(), { middleware: s = [], errorHandler: n = Ce } = t;
|
1153
1151
|
s.forEach((o) => e.use(o));
|
1154
|
-
const i = (o) => async (
|
1152
|
+
const i = (o) => async (c, a, d) => {
|
1155
1153
|
try {
|
1156
|
-
const h = { req:
|
1154
|
+
const h = { req: c, res: a, next: d, params: c.params, query: c.query, body: c.body };
|
1157
1155
|
return await o(h);
|
1158
1156
|
} catch (h) {
|
1159
|
-
const E = { req:
|
1157
|
+
const E = { req: c, res: a, next: d, params: c.params, query: c.query, body: c.body };
|
1160
1158
|
return n(h, E);
|
1161
1159
|
}
|
1162
1160
|
};
|
1163
|
-
return e.get("/", i(async ({ req: o, res:
|
1164
|
-
const
|
1165
|
-
|
1161
|
+
return e.get("/", i(async ({ req: o, res: c }) => {
|
1162
|
+
const a = o.pagination || { page: 1, limit: 10 }, d = await r.getAll(a);
|
1163
|
+
c.json({
|
1166
1164
|
success: !0,
|
1167
1165
|
...d
|
1168
1166
|
});
|
1169
|
-
})), e.get("/:id", i(async ({ params: o, res:
|
1170
|
-
const
|
1171
|
-
if (!
|
1172
|
-
|
1167
|
+
})), e.get("/:id", i(async ({ params: o, res: c }) => {
|
1168
|
+
const a = await r.getById(o.id);
|
1169
|
+
if (!a) {
|
1170
|
+
c.status(404).json({
|
1173
1171
|
success: !1,
|
1174
1172
|
error: "Item not found"
|
1175
1173
|
});
|
1176
1174
|
return;
|
1177
1175
|
}
|
1178
|
-
|
1176
|
+
c.json({
|
1179
1177
|
success: !0,
|
1180
|
-
data:
|
1178
|
+
data: a
|
1181
1179
|
});
|
1182
|
-
})), e.post("/", i(async ({ body: o, res:
|
1183
|
-
const
|
1184
|
-
|
1180
|
+
})), e.post("/", i(async ({ body: o, res: c }) => {
|
1181
|
+
const a = await r.create(o);
|
1182
|
+
c.status(201).json({
|
1185
1183
|
success: !0,
|
1186
|
-
data:
|
1184
|
+
data: a,
|
1187
1185
|
message: "Item created successfully"
|
1188
1186
|
});
|
1189
|
-
})), e.put("/:id", i(async ({ params: o, body:
|
1190
|
-
const d = await r.update(o.id,
|
1187
|
+
})), e.put("/:id", i(async ({ params: o, body: c, res: a }) => {
|
1188
|
+
const d = await r.update(o.id, c);
|
1191
1189
|
if (!d) {
|
1192
|
-
|
1190
|
+
a.status(404).json({
|
1193
1191
|
success: !1,
|
1194
1192
|
error: "Item not found"
|
1195
1193
|
});
|
1196
1194
|
return;
|
1197
1195
|
}
|
1198
|
-
|
1196
|
+
a.json({
|
1199
1197
|
success: !0,
|
1200
1198
|
data: d,
|
1201
1199
|
message: "Item updated successfully"
|
1202
1200
|
});
|
1203
|
-
})), e.delete("/:id", i(async ({ params: o, res:
|
1201
|
+
})), e.delete("/:id", i(async ({ params: o, res: c }) => {
|
1204
1202
|
if (!await r.delete(o.id)) {
|
1205
|
-
|
1203
|
+
c.status(404).json({
|
1206
1204
|
success: !1,
|
1207
1205
|
error: "Item not found"
|
1208
1206
|
});
|
1209
1207
|
return;
|
1210
1208
|
}
|
1211
|
-
|
1209
|
+
c.json({
|
1212
1210
|
success: !0,
|
1213
1211
|
message: "Item deleted successfully"
|
1214
1212
|
});
|
1215
1213
|
})), e;
|
1216
1214
|
}
|
1217
|
-
function
|
1218
|
-
const e = O.Router(), { middleware: s = [], errorHandler: n =
|
1215
|
+
function ot(r, t = {}) {
|
1216
|
+
const e = O.Router(), { middleware: s = [], errorHandler: n = Ce } = t;
|
1219
1217
|
s.forEach((o) => e.use(o));
|
1220
|
-
const i = (o) => async (
|
1218
|
+
const i = (o) => async (c, a, d) => {
|
1221
1219
|
try {
|
1222
|
-
const h = { req:
|
1223
|
-
return
|
1220
|
+
const h = { req: c, res: a, next: d, params: c.params, query: c.query, body: c.body };
|
1221
|
+
return a.headersSent ? void 0 : await o(h);
|
1224
1222
|
} catch (h) {
|
1225
|
-
if (
|
1223
|
+
if (a.headersSent) {
|
1226
1224
|
console.error("Error occurred after response was sent:", h);
|
1227
1225
|
return;
|
1228
1226
|
}
|
1229
|
-
const E = { req:
|
1227
|
+
const E = { req: c, res: a, next: d, params: c.params, query: c.query, body: c.body };
|
1230
1228
|
return n(h, E);
|
1231
1229
|
}
|
1232
1230
|
};
|
1233
|
-
return Object.entries(r).forEach(([o,
|
1234
|
-
const { method:
|
1235
|
-
e[
|
1231
|
+
return Object.entries(r).forEach(([o, c]) => {
|
1232
|
+
const { method: a, handler: d } = c;
|
1233
|
+
e[a](o, i(d));
|
1236
1234
|
}), e;
|
1237
1235
|
}
|
1238
1236
|
function le(r, t, e, s, n) {
|
@@ -1246,14 +1244,14 @@ function M(r, t, e = 400, s) {
|
|
1246
1244
|
const n = t instanceof Error ? t.message : t;
|
1247
1245
|
r.status(e).json(le(!1, void 0, void 0, n, s));
|
1248
1246
|
}
|
1249
|
-
function
|
1247
|
+
function je(r) {
|
1250
1248
|
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
1249
|
return { page: t, limit: e, sort: s, order: n };
|
1252
1250
|
}
|
1253
|
-
function
|
1254
|
-
r.pagination =
|
1251
|
+
function $e(r, t, e) {
|
1252
|
+
r.pagination = je(r), e();
|
1255
1253
|
}
|
1256
|
-
function
|
1254
|
+
function it(r) {
|
1257
1255
|
return (t, e, s) => {
|
1258
1256
|
try {
|
1259
1257
|
const { error: n, value: i } = r.validate(t.body);
|
@@ -1268,7 +1266,7 @@ function at(r) {
|
|
1268
1266
|
};
|
1269
1267
|
}
|
1270
1268
|
function ct(r = {}, t) {
|
1271
|
-
const e =
|
1269
|
+
const e = me();
|
1272
1270
|
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
1271
|
}
|
1274
1272
|
function N(r) {
|
@@ -1276,9 +1274,9 @@ function N(r) {
|
|
1276
1274
|
r(t, e, s).catch(s);
|
1277
1275
|
};
|
1278
1276
|
}
|
1279
|
-
function
|
1280
|
-
const t =
|
1281
|
-
return t.get("/",
|
1277
|
+
function at(r) {
|
1278
|
+
const t = me();
|
1279
|
+
return t.get("/", $e, N(async (e, s) => {
|
1282
1280
|
const n = await r.getAll(e.pagination);
|
1283
1281
|
R(s, n);
|
1284
1282
|
})), t.get("/:id", N(async (e, s) => {
|
@@ -1300,81 +1298,81 @@ function ut(r) {
|
|
1300
1298
|
R(s, null, "Item deleted successfully");
|
1301
1299
|
})), t;
|
1302
1300
|
}
|
1303
|
-
const
|
1301
|
+
const gt = {
|
1304
1302
|
// Frontend
|
1305
1303
|
jsx: J,
|
1306
|
-
jsxs:
|
1307
|
-
jsxDEV:
|
1304
|
+
jsxs: be,
|
1305
|
+
jsxDEV: ke,
|
1308
1306
|
// Add to default export
|
1309
1307
|
createElement: ne,
|
1310
|
-
Fragment:
|
1311
|
-
Component:
|
1312
|
-
useState:
|
1313
|
-
useEffect:
|
1314
|
-
useRef:
|
1315
|
-
useMemo:
|
1316
|
-
useErrorBoundary:
|
1308
|
+
Fragment: Te,
|
1309
|
+
Component: He,
|
1310
|
+
useState: xe,
|
1311
|
+
useEffect: We,
|
1312
|
+
useRef: qe,
|
1313
|
+
useMemo: Ue,
|
1314
|
+
useErrorBoundary: Ge,
|
1317
1315
|
render: ue,
|
1318
|
-
hydrate:
|
1316
|
+
hydrate: Je,
|
1319
1317
|
renderToString: D,
|
1320
1318
|
prepareRender: U,
|
1321
1319
|
finishRender: q,
|
1322
|
-
batchUpdates:
|
1323
|
-
createContext:
|
1324
|
-
useContext:
|
1320
|
+
batchUpdates: ae,
|
1321
|
+
createContext: ze,
|
1322
|
+
useContext: Xe,
|
1325
1323
|
// Backend
|
1326
|
-
createServer:
|
1327
|
-
createAuth:
|
1328
|
-
createModel:
|
1329
|
-
FieldTypes:
|
1330
|
-
createModelRouter:
|
1331
|
-
createCustomRouter:
|
1324
|
+
createServer: Ze,
|
1325
|
+
createAuth: tt,
|
1326
|
+
createModel: rt,
|
1327
|
+
FieldTypes: st,
|
1328
|
+
createModelRouter: nt,
|
1329
|
+
createCustomRouter: ot,
|
1332
1330
|
createApiRouter: ct,
|
1333
1331
|
sendSuccess: R,
|
1334
1332
|
sendError: M,
|
1335
1333
|
apiResponse: le,
|
1336
|
-
getPaginationParams:
|
1337
|
-
paginationMiddleware:
|
1338
|
-
validateRequest:
|
1334
|
+
getPaginationParams: je,
|
1335
|
+
paginationMiddleware: $e,
|
1336
|
+
validateRequest: it,
|
1339
1337
|
asyncHandler: N,
|
1340
|
-
createRestEndpoints:
|
1341
|
-
DatabaseConnector:
|
1338
|
+
createRestEndpoints: at,
|
1339
|
+
DatabaseConnector: Ae
|
1342
1340
|
};
|
1343
1341
|
export {
|
1344
|
-
|
1345
|
-
|
1346
|
-
|
1347
|
-
|
1342
|
+
He as Component,
|
1343
|
+
Ae as DatabaseConnector,
|
1344
|
+
st as FieldTypes,
|
1345
|
+
Te as Fragment,
|
1348
1346
|
le as apiResponse,
|
1349
1347
|
N as asyncHandler,
|
1350
|
-
|
1348
|
+
ae as batchUpdates,
|
1351
1349
|
ct as createApiRouter,
|
1352
|
-
|
1353
|
-
|
1354
|
-
|
1350
|
+
tt as createAuth,
|
1351
|
+
ze as createContext,
|
1352
|
+
ot as createCustomRouter,
|
1355
1353
|
ne as createElement,
|
1356
|
-
|
1357
|
-
|
1358
|
-
|
1359
|
-
|
1360
|
-
|
1354
|
+
rt as createModel,
|
1355
|
+
nt as createModelRouter,
|
1356
|
+
at as createRestEndpoints,
|
1357
|
+
Ze as createServer,
|
1358
|
+
gt as default,
|
1361
1359
|
q as finishRender,
|
1362
|
-
|
1363
|
-
|
1360
|
+
je as getPaginationParams,
|
1361
|
+
Je as hydrate,
|
1364
1362
|
J as jsx,
|
1365
|
-
|
1366
|
-
|
1367
|
-
|
1363
|
+
ke as jsxDEV,
|
1364
|
+
be as jsxs,
|
1365
|
+
$e as paginationMiddleware,
|
1368
1366
|
U as prepareRender,
|
1369
1367
|
ue as render,
|
1370
1368
|
D as renderToString,
|
1371
1369
|
M as sendError,
|
1372
1370
|
R as sendSuccess,
|
1373
|
-
|
1374
|
-
|
1375
|
-
|
1376
|
-
|
1377
|
-
|
1378
|
-
|
1379
|
-
|
1371
|
+
Xe as useContext,
|
1372
|
+
We as useEffect,
|
1373
|
+
Ge as useErrorBoundary,
|
1374
|
+
Ue as useMemo,
|
1375
|
+
qe as useRef,
|
1376
|
+
xe as useState,
|
1377
|
+
it as validateRequest
|
1380
1378
|
};
|