qumra-engine 2.0.22 → 2.0.24
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.
|
@@ -8,16 +8,10 @@ const path_1 = __importDefault(require("path"));
|
|
|
8
8
|
const nunjucksEnv_1 = require("../nunjucksEnv");
|
|
9
9
|
const globals_1 = require("../store/globals");
|
|
10
10
|
const nunjucksMiddleWare = (req, res, next) => {
|
|
11
|
-
console.log(2222222222);
|
|
12
11
|
const isDev = res.locals.mode === "devlopment";
|
|
13
|
-
console.log("🚀 ~ res:", res.locals.render);
|
|
14
|
-
console.log("🚀 ~ res.locals:", res.locals);
|
|
15
|
-
console.log("🚀 ~ isDev:", isDev);
|
|
16
|
-
console.log("🚀 ~ res.locals.themePath:", res.locals.render.themePath);
|
|
17
12
|
const mainPath = isDev
|
|
18
13
|
? path_1.default.join(process.cwd())
|
|
19
14
|
: path_1.default.join(res.locals.themesRepo, res.locals.render.themePath);
|
|
20
|
-
console.log("🚀 ~ mainPath:", mainPath);
|
|
21
15
|
const paths = {
|
|
22
16
|
pagesPath: path_1.default.join(mainPath, "pages"),
|
|
23
17
|
layoutsPath: path_1.default.join(mainPath, "layouts"),
|
|
@@ -10,9 +10,13 @@ const prepareDataMiddleware = (req, res, next) => {
|
|
|
10
10
|
// return next();
|
|
11
11
|
// }
|
|
12
12
|
// }
|
|
13
|
+
let themePath = '';
|
|
14
|
+
if (req.session.themeId) {
|
|
15
|
+
themePath = `?themeVersionId=${req.session.themeId}`;
|
|
16
|
+
}
|
|
13
17
|
const api = true
|
|
14
|
-
?
|
|
15
|
-
: "http://192.168.1.5:4019/v1/render";
|
|
18
|
+
? `https://store-gate.qumra-dev.site/render${themePath}`
|
|
19
|
+
: "http://192.168.1.5:4019/v1/render${themePath}";
|
|
16
20
|
fetch(api, {
|
|
17
21
|
method: "POST",
|
|
18
22
|
headers: { "Content-Type": "application/json" },
|
package/dist/middleware.js
CHANGED
|
@@ -17,9 +17,27 @@ const globals_middleware_1 = require("./middleware/globals.middleware");
|
|
|
17
17
|
const extensions_middleware_1 = require("./middleware/extensions.middleware");
|
|
18
18
|
const isPathAllowedToRender_1 = require("./utils/isPathAllowedToRender");
|
|
19
19
|
const mergeData_middleware_1 = require("./middleware/mergeData.middleware");
|
|
20
|
+
const express_session_1 = __importDefault(require("express-session"));
|
|
20
21
|
const startEngine = async ({ mode, getRender, setRender, port = 3000, themesRepo, }) => {
|
|
21
22
|
try {
|
|
22
23
|
const app = (0, express_1.default)();
|
|
24
|
+
app.use((0, express_session_1.default)({
|
|
25
|
+
secret: 'your-secret-key',
|
|
26
|
+
resave: false,
|
|
27
|
+
saveUninitialized: false,
|
|
28
|
+
cookie: {
|
|
29
|
+
secure: false,
|
|
30
|
+
maxAge: 1000 * 60 * 5,
|
|
31
|
+
},
|
|
32
|
+
}));
|
|
33
|
+
app.use((req, res, next) => {
|
|
34
|
+
const themeId = req.query.theme;
|
|
35
|
+
if (themeId) {
|
|
36
|
+
req.session.themeId = themeId;
|
|
37
|
+
console.log(`✅ Theme ID set in session: ${themeId}`);
|
|
38
|
+
}
|
|
39
|
+
next();
|
|
40
|
+
});
|
|
23
41
|
app.set("view engine", "nunjucks");
|
|
24
42
|
app.use((0, morgan_1.default)("dev"));
|
|
25
43
|
app.use((0, init_middleware_1.initMiddleware)({ mode, getRender, setRender }));
|
|
@@ -36,7 +54,7 @@ const startEngine = async ({ mode, getRender, setRender, port = 3000, themesRepo
|
|
|
36
54
|
next();
|
|
37
55
|
}
|
|
38
56
|
});
|
|
39
|
-
app.use((
|
|
57
|
+
app.use((_, res, next) => {
|
|
40
58
|
var themesRepoPath;
|
|
41
59
|
if (themesRepo) {
|
|
42
60
|
themesRepoPath = path_1.default.join(process.cwd(), themesRepo);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "qumra-engine",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.24",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"scripts": {
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
"chalk": "^5.4.1",
|
|
14
14
|
"color": "^5.0.0",
|
|
15
15
|
"express": "^5.1.0",
|
|
16
|
+
"express-session": "^1.18.1",
|
|
16
17
|
"morgan": "^1.10.0",
|
|
17
18
|
"nunjucks": "^3.2.4",
|
|
18
19
|
"pino": "^9.7.0",
|
|
@@ -22,6 +23,7 @@
|
|
|
22
23
|
"devDependencies": {
|
|
23
24
|
"@types/chalk": "^0.4.31",
|
|
24
25
|
"@types/express": "^4.17.21",
|
|
26
|
+
"@types/express-session": "^1.18.2",
|
|
25
27
|
"@types/morgan": "^1.9.10",
|
|
26
28
|
"@types/node": "^20.4.2",
|
|
27
29
|
"@types/nunjucks": "^3.2.6",
|