baraqex 1.0.76 → 2.0.1
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/CHANGELOG.md +73 -0
- package/README.md +268 -315
- package/bin/baraqex.js +150 -12
- package/dist/browser.d.ts +1 -1
- package/dist/browser.d.ts.map +1 -1
- package/dist/browser.js +2319 -205
- package/dist/browser.js.map +4 -4
- package/dist/core/batch.d.ts +10 -0
- package/dist/core/batch.d.ts.map +1 -0
- package/dist/core/component.d.ts +69 -0
- package/dist/core/component.d.ts.map +1 -0
- package/dist/core/context.d.ts +22 -0
- package/dist/core/context.d.ts.map +1 -0
- package/dist/core/errors.d.ts +125 -0
- package/dist/core/errors.d.ts.map +1 -0
- package/dist/core/event-bus.d.ts +29 -0
- package/dist/core/event-bus.d.ts.map +1 -0
- package/dist/core/forms.d.ts +128 -0
- package/dist/core/forms.d.ts.map +1 -0
- package/dist/core/hooks.d.ts +84 -0
- package/dist/core/hooks.d.ts.map +1 -0
- package/dist/core/index.d.ts +23 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/jsx-runtime.d.ts +45 -0
- package/dist/core/jsx-runtime.d.ts.map +1 -0
- package/dist/core/lifecycle-events.d.ts +71 -0
- package/dist/core/lifecycle-events.d.ts.map +1 -0
- package/dist/core/renderer.d.ts +39 -0
- package/dist/core/renderer.d.ts.map +1 -0
- package/dist/core/router.d.ts +108 -0
- package/dist/core/router.d.ts.map +1 -0
- package/dist/core/server-renderer.d.ts +26 -0
- package/dist/core/server-renderer.d.ts.map +1 -0
- package/dist/core/store.d.ts +102 -0
- package/dist/core/store.d.ts.map +1 -0
- package/dist/core/types.d.ts +66 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/core/utils.d.ts +153 -0
- package/dist/core/utils.d.ts.map +1 -0
- package/dist/core/vdom.d.ts +29 -0
- package/dist/core/vdom.d.ts.map +1 -0
- package/dist/index.d.ts +39 -35
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2596 -508
- package/dist/index.js.map +4 -4
- package/dist/server/auth.d.ts +8 -3
- package/dist/server/auth.d.ts.map +1 -1
- package/dist/server/index.d.ts +2 -2
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +173 -112
- package/dist/server/index.js.map +4 -4
- package/dist/server/middleware.d.ts +10 -1
- package/dist/server/middleware.d.ts.map +1 -1
- package/package.json +224 -124
- package/templates/basic-app/src/main.jsx +336 -0
- package/templates/complete-app/api/hello.js +0 -0
- package/templates/complete-app/client.js +58 -0
- package/templates/complete-app/lib/frontend-hamroun.js +182 -0
- package/templates/complete-app/package.json +18 -0
- package/templates/complete-app/pages/about.js +119 -0
- package/templates/complete-app/pages/about.jsx +0 -0
- package/templates/complete-app/pages/index.js +157 -0
- package/templates/complete-app/pages/index.jsx +0 -0
- package/templates/complete-app/pages/wasm-demo.js +290 -0
- package/templates/complete-app/pages/wasm-demo.jsx +0 -0
- package/templates/complete-app/public/client.js +89 -0
- package/templates/complete-app/public/index.html +118 -0
- package/templates/complete-app/public/styles.css +76 -0
- package/templates/complete-app/readme.md +188 -0
- package/templates/complete-app/server.js +226 -0
- package/templates/complete-app/server.ts +275 -0
- package/templates/complete-app/src/App.tsx +59 -0
- package/templates/complete-app/src/client.ts +61 -0
- package/templates/complete-app/src/client.tsx +18 -0
- package/templates/complete-app/src/pages/index.tsx +51 -0
- package/templates/complete-app/src/server.ts +218 -0
- package/templates/complete-app/tsconfig.json +22 -0
- package/templates/complete-app/tsconfig.server.json +19 -0
- package/templates/complete-app/vite.config.js +57 -0
- package/templates/complete-app/vite.config.ts +30 -0
- package/templates/complete-app/wasm/build.bat +0 -0
- package/templates/complete-app/wasm/build.sh +0 -0
- package/templates/complete-app/wasm/example.go +0 -0
- package/templates/fullstack-app/README.md +37 -0
- package/templates/fullstack-app/api/hello.js +11 -0
- package/templates/fullstack-app/api/hello.ts +18 -0
- package/templates/fullstack-app/api/users/[id].ts +73 -0
- package/templates/fullstack-app/api/users/index.ts +32 -0
- package/templates/fullstack-app/build/main.css +874 -0
- package/templates/fullstack-app/build/main.css.map +7 -0
- package/templates/fullstack-app/build/main.js +967 -0
- package/templates/fullstack-app/build/main.js.map +7 -0
- package/templates/fullstack-app/build.ts +210 -0
- package/templates/fullstack-app/index.html +36 -0
- package/templates/fullstack-app/package.json +35 -0
- package/templates/fullstack-app/postcss.config.js +6 -0
- package/templates/fullstack-app/process-tailwind.js +45 -0
- package/templates/fullstack-app/public/_redirects +1 -0
- package/templates/fullstack-app/public/route-handler.js +47 -0
- package/templates/fullstack-app/public/spa-fix.html +17 -0
- package/templates/fullstack-app/public/styles.css +975 -0
- package/templates/fullstack-app/public/tailwind.css +15 -0
- package/templates/fullstack-app/server.js +267 -0
- package/templates/fullstack-app/server.ts +474 -0
- package/templates/fullstack-app/src/README.md +55 -0
- package/templates/fullstack-app/src/client.js +87 -0
- package/templates/fullstack-app/src/components/ClientHome.tsx +0 -0
- package/templates/fullstack-app/src/components/ErrorBoundary.tsx +36 -0
- package/templates/fullstack-app/src/components/Layout.tsx +42 -0
- package/templates/fullstack-app/src/components/StateDemo.tsx +207 -0
- package/templates/fullstack-app/src/components/UserList.tsx +44 -0
- package/templates/fullstack-app/src/config.ts +42 -0
- package/templates/fullstack-app/src/data/api.ts +206 -0
- package/templates/fullstack-app/src/main.tsx +155 -0
- package/templates/fullstack-app/src/middleware.ts +28 -0
- package/templates/fullstack-app/src/pages/404.tsx +28 -0
- package/templates/fullstack-app/src/pages/[id].tsx +0 -0
- package/templates/fullstack-app/src/pages/_app.tsx +11 -0
- package/templates/fullstack-app/src/pages/_document.tsx +25 -0
- package/templates/fullstack-app/src/pages/_error.tsx +45 -0
- package/templates/fullstack-app/src/pages/about/index.tsx +67 -0
- package/templates/fullstack-app/src/pages/about.tsx +71 -0
- package/templates/fullstack-app/src/pages/api/users/[id].ts +73 -0
- package/templates/fullstack-app/src/pages/api/users/index.ts +43 -0
- package/templates/fullstack-app/src/pages/index.tsx +110 -0
- package/templates/fullstack-app/src/pages/users/[id].tsx +153 -0
- package/templates/fullstack-app/src/pages/users.tsx +60 -0
- package/templates/fullstack-app/src/pages/wasm-demo.tsx +1 -0
- package/templates/fullstack-app/src/router.ts +255 -0
- package/templates/fullstack-app/src/styles.css +5 -0
- package/templates/fullstack-app/tailwind.config.js +11 -0
- package/templates/fullstack-app/tsconfig.json +18 -0
- package/templates/fullstack-app/vite.config.js +87 -0
- package/templates/go/build.bat +36 -0
- package/templates/go/build.sh +43 -0
- package/templates/go/example.go +205 -0
- package/templates/go-wasm-app/README.md +38 -0
- package/templates/go-wasm-app/babel.config.js +21 -0
- package/templates/go-wasm-app/build-client.js +49 -0
- package/templates/go-wasm-app/build-wasm.js +237 -0
- package/templates/go-wasm-app/build.config.js +62 -0
- package/templates/go-wasm-app/build.js +218 -0
- package/templates/go-wasm-app/package.json +32 -0
- package/templates/go-wasm-app/public/index.html +128 -0
- package/templates/go-wasm-app/public/styles.css +197 -0
- package/templates/go-wasm-app/public/wasm/example.wasm +0 -0
- package/templates/go-wasm-app/public/wasm/wasm_exec.js +561 -0
- package/templates/go-wasm-app/public/wasm/wasm_exec_node.js +39 -0
- package/templates/go-wasm-app/server.js +70 -0
- package/templates/go-wasm-app/src/App.jsx +38 -0
- package/templates/go-wasm-app/src/app.js +173 -0
- package/templates/go-wasm-app/src/client.js +57 -0
- package/templates/go-wasm-app/src/components/Footer.jsx +13 -0
- package/templates/go-wasm-app/src/components/Header.jsx +19 -0
- package/templates/go-wasm-app/src/components/WasmDemo.jsx +120 -0
- package/templates/go-wasm-app/src/main.jsx +12 -0
- package/templates/go-wasm-app/src/wasm/example.go +75 -0
- package/templates/go-wasm-app/tsconfig.server.json +18 -0
- package/templates/go-wasm-app/vite.config.js +45 -0
- package/dist/forms/index.d.ts +0 -2
- package/dist/forms/index.d.ts.map +0 -1
- package/dist/forms/types.d.ts +0 -2
- package/dist/forms/types.d.ts.map +0 -1
- package/dist/frontend/components/WasmLoader.d.ts +0 -2
- package/dist/frontend/components/WasmLoader.d.ts.map +0 -1
- package/dist/frontend/hooks/useWasm.d.ts +0 -2
- package/dist/frontend/hooks/useWasm.d.ts.map +0 -1
- package/dist/frontend/index.d.ts +0 -2
- package/dist/frontend/index.d.ts.map +0 -1
- package/dist/router/index.d.ts +0 -2
- package/dist/router/index.d.ts.map +0 -1
- package/dist/router/types.d.ts +0 -2
- package/dist/router/types.d.ts.map +0 -1
- package/dist/store/index.d.ts +0 -2
- package/dist/store/index.d.ts.map +0 -1
- package/dist/store/types.d.ts +0 -2
- package/dist/store/types.d.ts.map +0 -1
- package/templates/basic-app/package-lock.json +0 -7173
- package/templates/fullstack-template/package-lock.json +0 -3558
- package/templates/ssr-template/package-lock.json +0 -5380
- package/templates/wasm/package-lock.json +0 -5347
- package/templates/wasm/public/example.wasm +0 -0
package/dist/server/auth.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Authentication service — JWT tokens, password hashing, Express middleware
|
|
3
|
+
*/
|
|
1
4
|
export interface AuthConfig {
|
|
2
5
|
secret: string;
|
|
3
6
|
expiresIn?: string | number;
|
|
@@ -12,12 +15,14 @@ export interface User {
|
|
|
12
15
|
}
|
|
13
16
|
export declare class AuthService {
|
|
14
17
|
private config;
|
|
18
|
+
private jwtPromise;
|
|
15
19
|
constructor(config: AuthConfig);
|
|
20
|
+
private getJwt;
|
|
16
21
|
hashPassword(password: string): Promise<string>;
|
|
17
22
|
comparePasswords(password: string, hashedPassword: string): Promise<boolean>;
|
|
18
|
-
generateToken(user: Omit<User, 'password'>): string
|
|
19
|
-
verifyToken(token: string): any
|
|
20
|
-
initialize(): (req: any, res: any, next: any) => void
|
|
23
|
+
generateToken(user: Omit<User, 'password'>): Promise<string>;
|
|
24
|
+
verifyToken(token: string): Promise<any>;
|
|
25
|
+
initialize(): (req: any, res: any, next: any) => Promise<void>;
|
|
21
26
|
requireAuth(): (req: any, res: any, next: any) => any;
|
|
22
27
|
requireRoles(roles: string[]): (req: any, res: any, next: any) => any;
|
|
23
28
|
private extractToken;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/server/auth.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/server/auth.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CAC7B;AAED,MAAM,WAAW,IAAI;IACnB,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED,qBAAa,WAAW;IACtB,OAAO,CAAC,MAAM,CAAa;IAC3B,OAAO,CAAC,UAAU,CAAuD;gBAE7D,MAAM,EAAE,UAAU;YAOhB,MAAM;IAed,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAY/C,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAY5E,aAAa,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,UAAU,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC;IAe5D,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC;IAS9C,UAAU,KACM,KAAK,GAAG,EAAE,KAAK,GAAG,EAAE,MAAM,GAAG;IAY7C,WAAW,KACD,KAAK,GAAG,EAAE,KAAK,GAAG,EAAE,MAAM,GAAG;IAQvC,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,IAClB,KAAK,GAAG,EAAE,KAAK,GAAG,EAAE,MAAM,GAAG;IAgBvC,OAAO,CAAC,YAAY;CAMrB"}
|
package/dist/server/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { renderToString } from '
|
|
1
|
+
import { renderToString } from '../core/server-renderer.js';
|
|
2
2
|
import { Database } from './database.js';
|
|
3
3
|
import { AuthService } from './auth.js';
|
|
4
4
|
import { ApiRouter } from './api-router.js';
|
|
@@ -91,7 +91,7 @@ declare const _default: {
|
|
|
91
91
|
createProductionServer: typeof createProductionServer;
|
|
92
92
|
rateLimit: typeof rateLimit;
|
|
93
93
|
requestLogger: import("./middleware.js").MiddlewareFunction;
|
|
94
|
-
errorHandler: (err: Error, req: any, res: any,
|
|
94
|
+
errorHandler: (err: Error, req: any, res: any, _next: any) => void;
|
|
95
95
|
notFoundHandler: (req: any, res: any) => void;
|
|
96
96
|
loadGoWasmFromFile: typeof loadGoWasmFromFile;
|
|
97
97
|
templates: typeof templates;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAgD,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAG1F,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAgB,kBAAkB,EAAE,MAAM,WAAW,CAAC;AA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|
-
}) : x)(function(x) {
|
|
5
|
-
if (typeof require !== "undefined")
|
|
6
|
-
return require.apply(this, arguments);
|
|
7
|
-
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
8
|
-
});
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
9
3
|
var __export = (target, all) => {
|
|
10
4
|
for (var name in all)
|
|
11
5
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
12
6
|
};
|
|
7
|
+
var __publicField = (obj, key, value) => {
|
|
8
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
9
|
+
return value;
|
|
10
|
+
};
|
|
13
11
|
|
|
14
12
|
// src/server/index.ts
|
|
15
13
|
import path4 from "path";
|
|
16
14
|
import fs4 from "fs";
|
|
17
15
|
|
|
18
|
-
//
|
|
19
|
-
var
|
|
20
|
-
var
|
|
21
|
-
var
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
16
|
+
// src/core/hooks.ts
|
|
17
|
+
var currentRoot = null;
|
|
18
|
+
var currentComponentId = null;
|
|
19
|
+
var hookIndex = 0;
|
|
20
|
+
function prepareRender(root, componentId) {
|
|
21
|
+
if (root) {
|
|
22
|
+
currentRoot = root;
|
|
23
|
+
}
|
|
24
|
+
if (componentId !== void 0) {
|
|
25
|
+
currentComponentId = componentId;
|
|
26
|
+
} else if (currentRoot) {
|
|
27
|
+
currentComponentId = ++currentRoot.nextComponentId;
|
|
28
|
+
}
|
|
29
|
+
hookIndex = 0;
|
|
30
|
+
return currentComponentId || 0;
|
|
27
31
|
}
|
|
28
32
|
function finishRender() {
|
|
29
|
-
|
|
30
|
-
serverStates.delete(currentRender);
|
|
31
|
-
}
|
|
32
|
-
currentRender = 0;
|
|
33
|
+
currentComponentId = null;
|
|
33
34
|
}
|
|
35
|
+
|
|
36
|
+
// src/core/server-renderer.ts
|
|
37
|
+
var VOID_ELEMENTS = /* @__PURE__ */ new Set([
|
|
38
|
+
"area",
|
|
39
|
+
"base",
|
|
40
|
+
"br",
|
|
41
|
+
"col",
|
|
42
|
+
"embed",
|
|
43
|
+
"hr",
|
|
44
|
+
"img",
|
|
45
|
+
"input",
|
|
46
|
+
"link",
|
|
47
|
+
"meta",
|
|
48
|
+
"param",
|
|
49
|
+
"source",
|
|
50
|
+
"track",
|
|
51
|
+
"wbr"
|
|
52
|
+
]);
|
|
34
53
|
function renderToString(vnode) {
|
|
35
54
|
prepareRender();
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
55
|
+
try {
|
|
56
|
+
return renderNodeToString(vnode);
|
|
57
|
+
} finally {
|
|
58
|
+
finishRender();
|
|
59
|
+
}
|
|
39
60
|
}
|
|
40
61
|
function renderNodeToString(vnode) {
|
|
41
|
-
var _a, _b, _c;
|
|
42
62
|
if (vnode === null || vnode === void 0)
|
|
43
63
|
return "";
|
|
44
64
|
if (typeof vnode === "boolean")
|
|
45
65
|
return "";
|
|
46
66
|
if (typeof vnode === "number" || typeof vnode === "string")
|
|
47
67
|
return escapeHtml(String(vnode));
|
|
48
|
-
if (
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
68
|
+
if (Array.isArray(vnode)) {
|
|
69
|
+
return vnode.map((child) => renderNodeToString(child)).join("");
|
|
70
|
+
}
|
|
71
|
+
if (typeof vnode !== "object" || vnode.type === void 0) {
|
|
72
|
+
return escapeHtml(String(vnode));
|
|
73
|
+
}
|
|
74
|
+
const { type, props } = vnode;
|
|
75
|
+
if (typeof type === "function") {
|
|
76
|
+
if (type.name === "Fragment" || type === Symbol.for("react.fragment")) {
|
|
77
|
+
const children = props?.children;
|
|
78
|
+
if (children == null)
|
|
79
|
+
return "";
|
|
80
|
+
return Array.isArray(children) ? children.map((child) => renderNodeToString(child)).join("") : renderNodeToString(children);
|
|
81
|
+
}
|
|
82
|
+
const Component = type;
|
|
83
|
+
try {
|
|
84
|
+
const renderedNode = Component(props || {});
|
|
85
|
+
return renderNodeToString(renderedNode);
|
|
86
|
+
} catch (error) {
|
|
87
|
+
console.error("Error rendering component:", error);
|
|
88
|
+
return `<!-- Error rendering component: ${escapeHtml(String(error))} -->`;
|
|
89
|
+
}
|
|
52
90
|
}
|
|
53
|
-
if (typeof
|
|
54
|
-
const tag =
|
|
91
|
+
if (typeof type === "string") {
|
|
92
|
+
const tag = type;
|
|
55
93
|
let attrs = "";
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
for (const [key, value] of Object.entries(vnode.props)) {
|
|
94
|
+
if (props) {
|
|
95
|
+
for (const [key, value] of Object.entries(props)) {
|
|
59
96
|
if (key === "children")
|
|
60
97
|
continue;
|
|
61
|
-
if (key
|
|
98
|
+
if (key === "dangerouslySetInnerHTML")
|
|
62
99
|
continue;
|
|
63
|
-
if (key === "
|
|
64
|
-
attrs += ` class="${escapeHtml(value)}"`;
|
|
100
|
+
if (key === "ref")
|
|
65
101
|
continue;
|
|
102
|
+
if (value === void 0 || value === null || value === false)
|
|
103
|
+
continue;
|
|
104
|
+
let attrName = key;
|
|
105
|
+
let attrValue = value;
|
|
106
|
+
if (key === "className")
|
|
107
|
+
attrName = "class";
|
|
108
|
+
else if (key === "htmlFor")
|
|
109
|
+
attrName = "for";
|
|
110
|
+
else if (key === "tabIndex")
|
|
111
|
+
attrName = "tabindex";
|
|
112
|
+
if (attrName.startsWith("on") && typeof value === "function")
|
|
113
|
+
continue;
|
|
114
|
+
if (attrName === "style" && typeof value === "object") {
|
|
115
|
+
attrValue = Object.entries(value).map(([prop, val]) => {
|
|
116
|
+
const cssProperty = prop.replace(/([A-Z])/g, "-$1").toLowerCase();
|
|
117
|
+
return `${cssProperty}: ${val}`;
|
|
118
|
+
}).join("; ");
|
|
66
119
|
}
|
|
67
|
-
if (
|
|
68
|
-
attrs += ` ${
|
|
69
|
-
} else
|
|
70
|
-
attrs += ` ${
|
|
120
|
+
if (value === true) {
|
|
121
|
+
attrs += ` ${attrName}`;
|
|
122
|
+
} else {
|
|
123
|
+
attrs += ` ${attrName}="${escapeHtml(String(attrValue))}"`;
|
|
71
124
|
}
|
|
72
125
|
}
|
|
73
126
|
}
|
|
74
|
-
|
|
127
|
+
if (VOID_ELEMENTS.has(tag)) {
|
|
128
|
+
return `<${tag}${attrs} />`;
|
|
129
|
+
}
|
|
130
|
+
if (props?.dangerouslySetInnerHTML?.__html) {
|
|
131
|
+
return `<${tag}${attrs}>${props.dangerouslySetInnerHTML.__html}</${tag}>`;
|
|
132
|
+
}
|
|
133
|
+
let children = "";
|
|
134
|
+
const childrenArray = props?.children ? Array.isArray(props.children) ? props.children : [props.children] : [];
|
|
75
135
|
for (const child of childrenArray) {
|
|
76
136
|
children += renderNodeToString(child);
|
|
77
137
|
}
|
|
78
|
-
const selfClosing = [
|
|
79
|
-
"area",
|
|
80
|
-
"base",
|
|
81
|
-
"br",
|
|
82
|
-
"col",
|
|
83
|
-
"embed",
|
|
84
|
-
"hr",
|
|
85
|
-
"img",
|
|
86
|
-
"input",
|
|
87
|
-
"link",
|
|
88
|
-
"meta",
|
|
89
|
-
"param",
|
|
90
|
-
"source",
|
|
91
|
-
"track",
|
|
92
|
-
"wbr"
|
|
93
|
-
];
|
|
94
|
-
if (selfClosing.includes(tag)) {
|
|
95
|
-
return `<${tag}${attrs}/>`;
|
|
96
|
-
}
|
|
97
138
|
return `<${tag}${attrs}>${children}</${tag}>`;
|
|
98
139
|
}
|
|
99
|
-
if (
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
}
|
|
105
|
-
return fragmentOutput;
|
|
140
|
+
if (type === Symbol.for("react.fragment")) {
|
|
141
|
+
const children = props?.children;
|
|
142
|
+
if (children == null)
|
|
143
|
+
return "";
|
|
144
|
+
return Array.isArray(children) ? children.map((child) => renderNodeToString(child)).join("") : renderNodeToString(children);
|
|
106
145
|
}
|
|
107
|
-
console.warn("Unknown vnode type:",
|
|
146
|
+
console.warn("Unknown vnode type:", type);
|
|
108
147
|
return "";
|
|
109
148
|
}
|
|
110
149
|
function escapeHtml(text) {
|
|
@@ -114,10 +153,11 @@ function escapeHtml(text) {
|
|
|
114
153
|
// src/server/database.ts
|
|
115
154
|
var Database = class {
|
|
116
155
|
constructor(config) {
|
|
117
|
-
this
|
|
118
|
-
this
|
|
119
|
-
this
|
|
120
|
-
this
|
|
156
|
+
__publicField(this, "config");
|
|
157
|
+
__publicField(this, "mongoClient", null);
|
|
158
|
+
__publicField(this, "mongoDb", null);
|
|
159
|
+
__publicField(this, "mysqlPool", null);
|
|
160
|
+
__publicField(this, "pgPool", null);
|
|
121
161
|
this.config = config;
|
|
122
162
|
}
|
|
123
163
|
async connect() {
|
|
@@ -228,11 +268,27 @@ var Database = class {
|
|
|
228
268
|
// src/server/auth.ts
|
|
229
269
|
var AuthService = class {
|
|
230
270
|
constructor(config) {
|
|
271
|
+
__publicField(this, "config");
|
|
272
|
+
__publicField(this, "jwtPromise", null);
|
|
231
273
|
this.config = {
|
|
232
274
|
expiresIn: "24h",
|
|
233
275
|
...config
|
|
234
276
|
};
|
|
235
277
|
}
|
|
278
|
+
async getJwt() {
|
|
279
|
+
if (!this.jwtPromise) {
|
|
280
|
+
this.jwtPromise = import("jsonwebtoken").catch((error) => {
|
|
281
|
+
this.jwtPromise = null;
|
|
282
|
+
if (error.code === "MODULE_NOT_FOUND") {
|
|
283
|
+
throw new Error(
|
|
284
|
+
"jsonwebtoken not installed. Run: npm install jsonwebtoken @types/jsonwebtoken"
|
|
285
|
+
);
|
|
286
|
+
}
|
|
287
|
+
throw error;
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
return this.jwtPromise;
|
|
291
|
+
}
|
|
236
292
|
async hashPassword(password) {
|
|
237
293
|
try {
|
|
238
294
|
const bcrypt = await import("bcryptjs");
|
|
@@ -255,42 +311,31 @@ var AuthService = class {
|
|
|
255
311
|
throw error;
|
|
256
312
|
}
|
|
257
313
|
}
|
|
258
|
-
generateToken(user) {
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
options.expiresIn = this.config.expiresIn;
|
|
264
|
-
}
|
|
265
|
-
return jwt.sign(
|
|
266
|
-
{ id: user.id, username: user.username, roles: user.roles || [] },
|
|
267
|
-
this.config.secret,
|
|
268
|
-
options
|
|
269
|
-
);
|
|
270
|
-
} catch (error) {
|
|
271
|
-
if (error.code === "MODULE_NOT_FOUND") {
|
|
272
|
-
throw new Error("jsonwebtoken not installed. Run: npm install jsonwebtoken @types/jsonwebtoken");
|
|
273
|
-
}
|
|
274
|
-
throw error;
|
|
314
|
+
async generateToken(user) {
|
|
315
|
+
const jwt = await this.getJwt();
|
|
316
|
+
const options = {};
|
|
317
|
+
if (this.config.expiresIn) {
|
|
318
|
+
options.expiresIn = this.config.expiresIn;
|
|
275
319
|
}
|
|
320
|
+
return jwt.sign(
|
|
321
|
+
{ id: user.id, username: user.username, roles: user.roles || [] },
|
|
322
|
+
this.config.secret,
|
|
323
|
+
options
|
|
324
|
+
);
|
|
276
325
|
}
|
|
277
|
-
verifyToken(token) {
|
|
326
|
+
async verifyToken(token) {
|
|
278
327
|
try {
|
|
279
|
-
const jwt =
|
|
328
|
+
const jwt = await this.getJwt();
|
|
280
329
|
return jwt.verify(token, this.config.secret);
|
|
281
|
-
} catch
|
|
282
|
-
if (error.code === "MODULE_NOT_FOUND") {
|
|
283
|
-
throw new Error("jsonwebtoken not installed. Run: npm install jsonwebtoken @types/jsonwebtoken");
|
|
284
|
-
}
|
|
330
|
+
} catch {
|
|
285
331
|
return null;
|
|
286
332
|
}
|
|
287
333
|
}
|
|
288
|
-
// Express middleware for authentication
|
|
289
334
|
initialize() {
|
|
290
|
-
return (req, res, next) => {
|
|
335
|
+
return async (req, res, next) => {
|
|
291
336
|
const token = this.extractToken(req);
|
|
292
337
|
if (token) {
|
|
293
|
-
const decoded = this.verifyToken(token);
|
|
338
|
+
const decoded = await this.verifyToken(token);
|
|
294
339
|
if (decoded) {
|
|
295
340
|
req.user = decoded;
|
|
296
341
|
}
|
|
@@ -298,7 +343,6 @@ var AuthService = class {
|
|
|
298
343
|
next();
|
|
299
344
|
};
|
|
300
345
|
}
|
|
301
|
-
// Express middleware for requiring authentication
|
|
302
346
|
requireAuth() {
|
|
303
347
|
return (req, res, next) => {
|
|
304
348
|
if (!req.user) {
|
|
@@ -307,7 +351,6 @@ var AuthService = class {
|
|
|
307
351
|
return next();
|
|
308
352
|
};
|
|
309
353
|
}
|
|
310
|
-
// Express middleware for requiring specific roles
|
|
311
354
|
requireRoles(roles) {
|
|
312
355
|
return (req, res, next) => {
|
|
313
356
|
if (!req.user) {
|
|
@@ -335,8 +378,10 @@ import fs from "fs";
|
|
|
335
378
|
import { pathToFileURL } from "url";
|
|
336
379
|
var ApiRouter = class {
|
|
337
380
|
constructor(apiDir, auth = null) {
|
|
338
|
-
this
|
|
339
|
-
this
|
|
381
|
+
__publicField(this, "router", null);
|
|
382
|
+
__publicField(this, "apiDir");
|
|
383
|
+
__publicField(this, "auth");
|
|
384
|
+
__publicField(this, "initialized", false);
|
|
340
385
|
this.apiDir = path.resolve(process.cwd(), apiDir);
|
|
341
386
|
this.auth = auth;
|
|
342
387
|
}
|
|
@@ -442,7 +487,7 @@ var requestLogger = (req, res, next) => {
|
|
|
442
487
|
console.log(`${(/* @__PURE__ */ new Date()).toISOString()} - ${req.method} ${req.url}`);
|
|
443
488
|
next();
|
|
444
489
|
};
|
|
445
|
-
var errorHandler = (err, req, res,
|
|
490
|
+
var errorHandler = (err, req, res, _next) => {
|
|
446
491
|
console.error(err.stack);
|
|
447
492
|
res.status(500).json({
|
|
448
493
|
error: {
|
|
@@ -460,8 +505,22 @@ var notFoundHandler = (req, res) => {
|
|
|
460
505
|
};
|
|
461
506
|
function rateLimit(options) {
|
|
462
507
|
const requests = /* @__PURE__ */ new Map();
|
|
508
|
+
const cleanupInterval = setInterval(() => {
|
|
509
|
+
const now = Date.now();
|
|
510
|
+
for (const [ip, times] of requests) {
|
|
511
|
+
const valid = times.filter((t) => now - t < options.windowMs);
|
|
512
|
+
if (valid.length === 0) {
|
|
513
|
+
requests.delete(ip);
|
|
514
|
+
} else {
|
|
515
|
+
requests.set(ip, valid);
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
}, options.windowMs);
|
|
519
|
+
if (cleanupInterval.unref) {
|
|
520
|
+
cleanupInterval.unref();
|
|
521
|
+
}
|
|
463
522
|
return (req, res, next) => {
|
|
464
|
-
const ip = req.ip || req.socket
|
|
523
|
+
const ip = req.ip || req.socket?.remoteAddress || "unknown";
|
|
465
524
|
const now = Date.now();
|
|
466
525
|
const reqTimes = (requests.get(ip) || []).filter((time) => now - time < options.windowMs);
|
|
467
526
|
reqTimes.push(now);
|
|
@@ -615,7 +674,7 @@ __export(templates_exports, {
|
|
|
615
674
|
});
|
|
616
675
|
function generateDocument(content, options = {}) {
|
|
617
676
|
const {
|
|
618
|
-
title = "
|
|
677
|
+
title = "Baraqex App",
|
|
619
678
|
description = "",
|
|
620
679
|
lang = "en",
|
|
621
680
|
charset = "UTF-8",
|
|
@@ -877,7 +936,7 @@ async function loadGoWasmFromFile(wasmFilePath, options = {}) {
|
|
|
877
936
|
const GoRuntime = await loadGoRuntime(options.goWasmPath);
|
|
878
937
|
const go = new GoRuntime();
|
|
879
938
|
const wasmBuffer = await fs3.readFile(wasmFilePath);
|
|
880
|
-
const wasmModule = await WebAssembly.compile(wasmBuffer);
|
|
939
|
+
const wasmModule = await WebAssembly.compile(new Uint8Array(wasmBuffer));
|
|
881
940
|
const baseImports = go.importObject;
|
|
882
941
|
const finalImportObject = {
|
|
883
942
|
...baseImports,
|
|
@@ -958,10 +1017,12 @@ function getComponentName(filePath, pagesDir) {
|
|
|
958
1017
|
}
|
|
959
1018
|
var Server = class {
|
|
960
1019
|
constructor(config = {}) {
|
|
961
|
-
this
|
|
962
|
-
this
|
|
963
|
-
this
|
|
964
|
-
this
|
|
1020
|
+
__publicField(this, "app");
|
|
1021
|
+
__publicField(this, "server", null);
|
|
1022
|
+
__publicField(this, "config");
|
|
1023
|
+
__publicField(this, "db", null);
|
|
1024
|
+
__publicField(this, "auth", null);
|
|
1025
|
+
__publicField(this, "initialized", false);
|
|
965
1026
|
this.config = {
|
|
966
1027
|
port: 3e3,
|
|
967
1028
|
apiDir: "./api",
|
|
@@ -1240,8 +1301,8 @@ var Server = class {
|
|
|
1240
1301
|
if (!fs4.existsSync(clientJsPath)) {
|
|
1241
1302
|
const clientJsContent = `
|
|
1242
1303
|
// Auto-generated hydration script
|
|
1243
|
-
import { hydrate } from '
|
|
1244
|
-
|
|
1304
|
+
import { hydrate } from 'baraqex';
|
|
1305
|
+
|
|
1245
1306
|
// Find SSR content and hydrate it
|
|
1246
1307
|
document.addEventListener('DOMContentLoaded', () => {
|
|
1247
1308
|
const ssrRoots = document.querySelectorAll('[data-ssr-root]');
|