qumra-engine 2.0.34 → 2.0.35
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.
|
@@ -14,14 +14,17 @@ const prepareDataMiddleware = (req, res, next) => {
|
|
|
14
14
|
if (req.session.themeId) {
|
|
15
15
|
themePath = `?themeVersionId=${req.session.themeId}`;
|
|
16
16
|
}
|
|
17
|
-
const api =
|
|
17
|
+
const api = false
|
|
18
18
|
? `https://store-gate.qumra-dev.site/render${themePath}`
|
|
19
19
|
: `http://192.168.1.8:4019/v1/render${themePath}`;
|
|
20
20
|
fetch(api, {
|
|
21
21
|
method: "POST",
|
|
22
|
-
headers: {
|
|
22
|
+
headers: {
|
|
23
|
+
"Content-Type": "application/json",
|
|
24
|
+
'qdid': req.cookies.qdid || '',
|
|
25
|
+
'authorization': req.cookies.authorization || '',
|
|
26
|
+
},
|
|
23
27
|
body: JSON.stringify({ url: parsedUrl.fullUrl }),
|
|
24
|
-
credentials: 'include'
|
|
25
28
|
})
|
|
26
29
|
.then((engineResponse) => {
|
|
27
30
|
if (!engineResponse.ok) {
|
|
@@ -30,7 +33,6 @@ const prepareDataMiddleware = (req, res, next) => {
|
|
|
30
33
|
return engineResponse.json();
|
|
31
34
|
})
|
|
32
35
|
.then((data) => {
|
|
33
|
-
console.log("🚀 ~ .then ~ data:", data);
|
|
34
36
|
// تم تخزين النتيجة داخل res.locals.render
|
|
35
37
|
res.locals.render = data.data;
|
|
36
38
|
next();
|
package/dist/middleware.d.ts
CHANGED
|
@@ -8,5 +8,5 @@ interface IStartEngine {
|
|
|
8
8
|
themeId?: string | null;
|
|
9
9
|
currentApp?: App;
|
|
10
10
|
}
|
|
11
|
-
declare const startEngine: ({ mode, getRender, setRender, port, themesRepo, themeId, currentApp }: IStartEngine) => Promise<void>;
|
|
11
|
+
declare const startEngine: ({ mode, getRender, setRender, port, themesRepo, themeId, currentApp, }: IStartEngine) => Promise<void>;
|
|
12
12
|
export default startEngine;
|
package/dist/middleware.js
CHANGED
|
@@ -19,9 +19,11 @@ const isPathAllowedToRender_1 = require("./utils/isPathAllowedToRender");
|
|
|
19
19
|
const mergeData_middleware_1 = require("./middleware/mergeData.middleware");
|
|
20
20
|
const express_session_1 = __importDefault(require("express-session"));
|
|
21
21
|
const printServerLog_1 = require("./utils/printServerLog");
|
|
22
|
-
const
|
|
22
|
+
const cookie_parser_1 = __importDefault(require("cookie-parser"));
|
|
23
|
+
const startEngine = async ({ mode, getRender, setRender, port = 3000, themesRepo, themeId = null, currentApp, }) => {
|
|
23
24
|
try {
|
|
24
25
|
const app = (0, express_1.default)();
|
|
26
|
+
app.use((0, cookie_parser_1.default)());
|
|
25
27
|
app.use((0, express_session_1.default)({
|
|
26
28
|
secret: "your-secret-key",
|
|
27
29
|
resave: false,
|
|
@@ -34,7 +36,6 @@ const startEngine = async ({ mode, getRender, setRender, port = 3000, themesRepo
|
|
|
34
36
|
app.use((req, res, next) => {
|
|
35
37
|
if (req.query.theme) {
|
|
36
38
|
req.session.themeId = req.query.theme;
|
|
37
|
-
console.log(`✅ Theme ID set in session: ${themeId}`);
|
|
38
39
|
return res.redirect("/");
|
|
39
40
|
}
|
|
40
41
|
else {
|
|
@@ -80,7 +81,11 @@ const startEngine = async ({ mode, getRender, setRender, port = 3000, themesRepo
|
|
|
80
81
|
app.use(extensions_middleware_1.nunjucksExtensionsMiddleWare);
|
|
81
82
|
app.use(render_middleware_1.renderMiddleware);
|
|
82
83
|
app.listen(avilablePort, () => {
|
|
83
|
-
(0, printServerLog_1.printServerLog)({
|
|
84
|
+
(0, printServerLog_1.printServerLog)({
|
|
85
|
+
port: avilablePort,
|
|
86
|
+
themeId: themeId || "default",
|
|
87
|
+
app: currentApp,
|
|
88
|
+
});
|
|
84
89
|
});
|
|
85
90
|
}
|
|
86
91
|
catch (err) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "qumra-engine",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.35",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"scripts": {
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"chalk": "^5.4.1",
|
|
12
12
|
"colord": "^2.9.3",
|
|
13
|
+
"cookie-parser": "^1.4.7",
|
|
13
14
|
"express": "^5.1.0",
|
|
14
15
|
"express-session": "^1.18.1",
|
|
15
16
|
"morgan": "^1.10.0",
|
|
@@ -20,6 +21,7 @@
|
|
|
20
21
|
},
|
|
21
22
|
"devDependencies": {
|
|
22
23
|
"@types/chalk": "^0.4.31",
|
|
24
|
+
"@types/cookie-parser": "^1.4.9",
|
|
23
25
|
"@types/express": "^4.17.21",
|
|
24
26
|
"@types/express-session": "^1.18.2",
|
|
25
27
|
"@types/morgan": "^1.9.10",
|