@ozdao/prometheus-framework 0.2.183 → 0.2.185
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/builder.js +60 -33
- package/dist/builder.mjs +60 -33
- package/dist/pages.server.js +150 -0
- package/dist/pages.server.mjs +151 -0
- package/dist/prometheus-framework/src/components/Block/Block.vue.cjs +1 -1
- package/dist/prometheus-framework/src/components/Block/Block.vue.js +1 -1
- package/dist/prometheus-framework/src/components/Feed/Feed.vue.cjs +1 -1
- package/dist/prometheus-framework/src/components/Feed/Feed.vue.js +1 -1
- package/dist/prometheus-framework/src/components/FieldBig/FieldBig.vue.cjs +1 -1
- package/dist/prometheus-framework/src/components/FieldBig/FieldBig.vue.js +1 -1
- package/dist/prometheus-framework/src/modules/auth/components/layouts/Auth.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/auth/components/layouts/Auth.vue.js +2 -2
- package/dist/prometheus-framework/src/modules/auth/components/pages/EnterCode.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/auth/components/pages/EnterCode.vue.js +1 -1
- package/dist/prometheus-framework/src/modules/auth/components/pages/EnterPassword.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/auth/components/pages/EnterPassword.vue.js +2 -2
- package/dist/prometheus-framework/src/modules/auth/components/pages/Invite.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/auth/components/pages/Invite.vue.js +2 -2
- package/dist/prometheus-framework/src/modules/auth/components/pages/ResetPassword.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/auth/components/pages/ResetPassword.vue.js +2 -2
- package/dist/prometheus-framework/src/modules/auth/components/pages/SignIn.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/auth/components/pages/SignIn.vue.js +2 -2
- package/dist/prometheus-framework/src/modules/auth/components/pages/SignUp.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/auth/components/pages/SignUp.vue.js +2 -2
- package/dist/prometheus-framework/src/modules/backoffice/components/pages/Dashboard.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/backoffice/components/pages/Dashboard.vue.js +1 -1
- package/dist/prometheus-framework/src/modules/backoffice/components/partials/Sidebar.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/backoffice/components/partials/Sidebar.vue.js +1 -1
- package/dist/prometheus-framework/src/modules/community/components/blocks/CardBlogpost.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/community/components/blocks/CardBlogpost.vue.js +1 -1
- package/dist/prometheus-framework/src/modules/community/components/layouts/Community.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/community/components/layouts/Community.vue.js +1 -1
- package/dist/prometheus-framework/src/modules/community/components/pages/Community.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/community/components/pages/Community.vue.js +3 -3
- package/dist/prometheus-framework/src/modules/community/components/pages/CreateBlogPost.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/community/components/pages/CreateBlogPost.vue.js +3 -3
- package/dist/prometheus-framework/src/modules/community/components/sections/HotPosts.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/community/components/sections/HotPosts.vue.js +2 -2
- package/dist/prometheus-framework/src/modules/constructor/components/elements/Embed.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/constructor/components/elements/Embed.vue.js +1 -1
- package/dist/prometheus-framework/src/modules/events/components/blocks/CardEvent.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/events/components/blocks/CardEvent.vue.js +1 -1
- package/dist/prometheus-framework/src/modules/events/components/elements/ButtonCheck.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/events/components/elements/ButtonCheck.vue.js +2 -2
- package/dist/prometheus-framework/src/modules/events/components/elements/ButtonJoin.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/events/components/elements/ButtonJoin.vue.js +1 -1
- package/dist/prometheus-framework/src/modules/events/components/pages/EditEvent.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/events/components/pages/EditEvent.vue.js +3 -3
- package/dist/prometheus-framework/src/modules/events/components/pages/EditEventTickets.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/events/components/pages/EditEventTickets.vue.js +3 -3
- package/dist/prometheus-framework/src/modules/gallery/components/pages/Gallery.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/gallery/components/pages/Gallery.vue.js +1 -1
- package/dist/prometheus-framework/src/modules/gallery/components/sections/BackofficeGallery.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/gallery/components/sections/BackofficeGallery.vue.js +5 -5
- package/dist/prometheus-framework/src/modules/globals/components/blocks/BlockSearch.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/globals/components/blocks/BlockSearch.vue.js +1 -1
- package/dist/prometheus-framework/src/modules/globals/components/blocks/CardHeader.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/globals/components/blocks/CardHeader.vue.js +3 -3
- package/dist/prometheus-framework/src/modules/globals/mixins/mixins.cjs +1 -0
- package/dist/prometheus-framework/src/modules/globals/mixins/mixins.js +43 -0
- package/dist/prometheus-framework/src/modules/legal/components/pages/Legal.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/legal/components/pages/Legal.vue.js +3 -3
- package/dist/prometheus-framework/src/modules/orders/components/pages/OrderBackoffice.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/orders/components/pages/OrderBackoffice.vue.js +1 -1
- package/dist/prometheus-framework/src/modules/orders/components/pages/OrderCreateBackoffice.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/orders/components/pages/OrderCreateBackoffice.vue.js +4 -4
- package/dist/prometheus-framework/src/modules/orders/components/sections/FormAddCustomer.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/orders/components/sections/FormAddCustomer.vue.js +3 -3
- package/dist/prometheus-framework/src/modules/orders/components/sections/FormCustomerDetails.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/orders/components/sections/FormCustomerDetails.vue.js +2 -2
- package/dist/prometheus-framework/src/modules/orders/components/sections/FormDelivery.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/orders/components/sections/FormDelivery.vue.js +1 -1
- package/dist/prometheus-framework/src/modules/orders/components/sections/FormPayment.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/orders/components/sections/FormPayment.vue.js +1 -1
- package/dist/prometheus-framework/src/modules/organizations/components/blocks/CardOrganization.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/organizations/components/blocks/CardOrganization.vue.js +1 -1
- package/dist/prometheus-framework/src/modules/organizations/components/elements/ButtonToggleMembership.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/organizations/components/elements/ButtonToggleMembership.vue.js +1 -1
- package/dist/prometheus-framework/src/modules/organizations/components/pages/DepartmentEdit.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/organizations/components/pages/DepartmentEdit.vue.js +4 -4
- package/dist/prometheus-framework/src/modules/organizations/components/pages/Members.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/organizations/components/pages/Members.vue.js +3 -3
- package/dist/prometheus-framework/src/modules/organizations/components/pages/Organization.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/organizations/components/pages/Organization.vue.js +1 -1
- package/dist/prometheus-framework/src/modules/organizations/components/pages/OrganizationBackoffice.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/organizations/components/pages/OrganizationBackoffice.vue.js +1 -1
- package/dist/prometheus-framework/src/modules/organizations/components/pages/OrganizationEdit.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/organizations/components/pages/OrganizationEdit.vue.js +4 -4
- package/dist/prometheus-framework/src/modules/organizations/components/sections/DetailsTab.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/organizations/components/sections/DetailsTab.vue.js +2 -2
- package/dist/prometheus-framework/src/modules/organizations/components/sections/Documents.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/organizations/components/sections/Documents.vue.js +3 -3
- package/dist/prometheus-framework/src/modules/organizations/components/sections/MembersAdd.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/organizations/components/sections/MembersAdd.vue.js +3 -3
- package/dist/prometheus-framework/src/modules/organizations/components/sections/Organizations.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/organizations/components/sections/Organizations.vue.js +6 -6
- package/dist/prometheus-framework/src/modules/pages/pages.client.cjs +1 -0
- package/dist/prometheus-framework/src/modules/pages/pages.client.js +31 -0
- package/dist/prometheus-framework/src/modules/pages/views/components/blocks/CardPage.vue.cjs +1 -0
- package/dist/prometheus-framework/src/modules/pages/views/components/blocks/CardPage.vue.js +98 -0
- package/dist/prometheus-framework/src/modules/pages/views/components/pages/Page.vue.cjs +1 -0
- package/dist/prometheus-framework/src/modules/pages/views/components/pages/Page.vue.js +127 -0
- package/dist/prometheus-framework/src/modules/pages/views/components/pages/PageEdit.vue.cjs +1 -0
- package/dist/prometheus-framework/src/modules/pages/views/components/pages/PageEdit.vue.js +89 -0
- package/dist/prometheus-framework/src/modules/pages/views/components/pages/Pages.vue.cjs +1 -0
- package/dist/prometheus-framework/src/modules/pages/views/components/pages/Pages.vue.js +47 -0
- package/dist/prometheus-framework/src/modules/pages/views/components/partials/SidebarPages.vue.cjs +1 -0
- package/dist/prometheus-framework/src/modules/pages/views/components/partials/SidebarPages.vue.js +86 -0
- package/dist/prometheus-framework/src/modules/pages/views/router/pages.backoffice.router.cjs +1 -0
- package/dist/prometheus-framework/src/modules/pages/views/router/pages.backoffice.router.js +53 -0
- package/dist/prometheus-framework/src/modules/pages/views/router/pages.router.cjs +1 -0
- package/dist/prometheus-framework/src/modules/pages/views/router/pages.router.js +28 -0
- package/dist/prometheus-framework/src/modules/pages/views/store/pages.cjs +1 -0
- package/dist/prometheus-framework/src/modules/pages/views/store/pages.js +52 -0
- package/dist/prometheus-framework/src/modules/products/components/blocks/CardPosition.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/products/components/blocks/CardPosition.vue.js +2 -2
- package/dist/prometheus-framework/src/modules/products/components/blocks/ImagesThumbnails.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/products/components/blocks/ImagesThumbnails.vue.js +1 -1
- package/dist/prometheus-framework/src/modules/products/components/blocks/LeftoverPositions.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/products/components/blocks/LeftoverPositions.vue.js +1 -1
- package/dist/prometheus-framework/src/modules/products/components/blocks/ListPositions.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/products/components/blocks/ListPositions.vue.js +1 -1
- package/dist/prometheus-framework/src/modules/products/components/pages/Categories.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/products/components/pages/Categories.vue.js +1 -1
- package/dist/prometheus-framework/src/modules/products/components/pages/CategoryEdit.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/products/components/pages/CategoryEdit.vue.js +3 -3
- package/dist/prometheus-framework/src/modules/products/components/pages/EditLeftover.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/products/components/pages/EditLeftover.vue.js +3 -3
- package/dist/prometheus-framework/src/modules/products/components/pages/ProductEdit.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/products/components/pages/ProductEdit.vue.js +3 -3
- package/dist/prometheus-framework/src/modules/products/components/sections/EditModifications.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/products/components/sections/EditModifications.vue.js +1 -1
- package/dist/prometheus-framework/src/modules/products/components/sections/EditProductInfo.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/products/components/sections/EditProductInfo.vue.js +3 -3
- package/dist/prometheus-framework/src/modules/products/components/sections/SectionProduct.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/products/components/sections/SectionProduct.vue.js +1 -1
- package/dist/prometheus-framework/src/modules/reports/components/sections/FormReport.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/reports/components/sections/FormReport.vue.js +3 -3
- package/dist/prometheus-framework/src/modules/spots/components/blocks/CardSpot.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/spots/components/blocks/CardSpot.vue.js +1 -1
- package/dist/prometheus-framework/src/modules/spots/components/blocks/SpotMemberModify.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/spots/components/blocks/SpotMemberModify.vue.js +2 -2
- package/dist/prometheus-framework/src/modules/spots/components/layouts/Spots.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/spots/components/layouts/Spots.vue.js +2 -2
- package/dist/prometheus-framework/src/modules/spots/components/pages/Map.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/spots/components/pages/Map.vue.js +1 -1
- package/dist/prometheus-framework/src/modules/spots/components/pages/SpotEdit.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/spots/components/pages/SpotEdit.vue.js +4 -4
- package/dist/prometheus-framework/src/modules/users/components/pages/Profile.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/users/components/pages/Profile.vue.js +4 -4
- package/dist/prometheus-framework/src/modules/users/components/pages/ProfileEdit.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/users/components/pages/ProfileEdit.vue.js +2 -2
- package/dist/prometheus-framework/src/modules/wallet/views/components/blocks/CardDeposit.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/wallet/views/components/blocks/CardDeposit.vue.js +1 -1
- package/dist/prometheus-framework/src/modules/wallet/views/components/blocks/CryptoDeposit.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/wallet/views/components/blocks/CryptoDeposit.vue.js +2 -2
- package/dist/prometheus-framework/src/modules/wallet/views/components/pages/Wallet.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/wallet/views/components/pages/Wallet.vue.js +6 -6
- package/dist/style.css +1 -1
- package/package.json +9 -1
- package/src/builder/ssr/ssr-render-html.js +6 -24
- package/src/builder/templates/page.js +39 -0
- package/src/builder/webpack/webpack.config.spa.js +3 -4
- package/src/modules/pages/views/components/pages/Page.vue +0 -2
- package/src/builder/templates/page.html +0 -37
- package/src/builder/templates/screen.html +0 -33
package/dist/builder.js
CHANGED
@@ -24,21 +24,21 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
24
24
|
const require$$0 = require("path");
|
25
25
|
const require$$1$1 = require("webpack");
|
26
26
|
const require$$2$1 = require("compression");
|
27
|
-
const require$$3
|
27
|
+
const require$$3 = require("readline");
|
28
28
|
const require$$4 = require("chalk");
|
29
29
|
const require$$5 = require("webpack-dev-middleware");
|
30
30
|
const require$$1 = require("mustache");
|
31
31
|
const require$$2 = require("chokidar");
|
32
|
-
const require$$3 = require("fs");
|
33
32
|
const require$$1$2 = require("express");
|
34
33
|
const require$$6 = require("connect-history-api-fallback");
|
34
|
+
const require$$0$1 = require("fs");
|
35
35
|
const require$$2$2 = require("vue-loader");
|
36
|
-
const require$$3$
|
36
|
+
const require$$3$1 = require("mini-css-extract-plugin");
|
37
37
|
const require$$4$1 = require("clean-webpack-plugin");
|
38
38
|
const require$$5$1 = require("webpack-bundle-analyzer");
|
39
39
|
const require$$6$1 = require("dotenv-webpack");
|
40
40
|
const require$$1$3 = require("glob-all");
|
41
|
-
const require$$3$
|
41
|
+
const require$$3$2 = require("webpack-merge");
|
42
42
|
const require$$4$2 = require("webpack-stats-plugin");
|
43
43
|
const require$$6$2 = require("css-minimizer-webpack-plugin");
|
44
44
|
const require$$7 = require("terser-webpack-plugin");
|
@@ -51,17 +51,51 @@ const require$$4$3 = require("webpack-manifest-plugin");
|
|
51
51
|
function getDefaultExportFromCjs(x) {
|
52
52
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
|
53
53
|
}
|
54
|
+
var page = `
|
55
|
+
<!-- <!DOCTYPE html> -->
|
56
|
+
<html {{{ meta.htmlAttrs }}}>
|
57
|
+
<head {{{ meta.headAttrs }}}>
|
58
|
+
{{{ meta.head }}}
|
59
|
+
<link rel="apple-touch-icon" sizes="180x180" href="/favicon/apple-touch-icon.png">
|
60
|
+
<link rel="icon" type="image/png" sizes="32x32" href="/favicon/favicon-32x32.png">
|
61
|
+
<link rel="icon" type="image/png" sizes="16x16" href="/favicon/favicon-16x16.png">
|
62
|
+
<link rel="manifest" href="/favicon/site.webmanifest">
|
63
|
+
<link rel="mask-icon" href="/favicon/safari-pinned-tab.svg" color="#5bbad5">
|
64
|
+
<meta name="msapplication-TileColor" content="#000000">
|
65
|
+
<meta name="theme-color" content="#ffffff">
|
66
|
+
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
|
67
|
+
{{{ head }}}
|
68
|
+
<!-- Sign in with Apple -->
|
69
|
+
<!-- <script type="text/javascript" src="https://appleid.cdn-apple.com/appleauth/static/jsapi/appleid/1/en_US/appleid.auth.js"></script> -->
|
70
|
+
</head>
|
71
|
+
<!-- Google tag (gtag.js) -->
|
72
|
+
<script async src="https://www.googletagmanager.com/gtag/js?id={{googleTagId}}"></script>
|
73
|
+
|
74
|
+
<body {{{ meta.bodyAttrs }}}>
|
75
|
+
<div id="app">{{{ appHtml }}}</div>
|
76
|
+
|
77
|
+
<script type="application/json" data-user-state>
|
78
|
+
{{{ userState }}}
|
79
|
+
</script>
|
80
|
+
|
81
|
+
<script>
|
82
|
+
window.dataLayer = window.dataLayer || [];
|
83
|
+
function gtag(){dataLayer.push(arguments);}
|
84
|
+
gtag('js', new Date());
|
85
|
+
|
86
|
+
gtag('config', '{{googleTagId}}');
|
87
|
+
</script>
|
88
|
+
|
89
|
+
{{{ meta.body }}} {{{ body }}}
|
90
|
+
</body>
|
91
|
+
</html>
|
92
|
+
`;
|
54
93
|
const path$9 = require$$0;
|
55
94
|
const Mustache$1 = require$$1;
|
56
95
|
const chokidar = require$$2;
|
57
|
-
const
|
58
|
-
const templatePath
|
59
|
-
let template;
|
96
|
+
const template = page;
|
97
|
+
const templatePath = path$9.resolve(__dirname, "../templates/page.js");
|
60
98
|
const renderHtml$1 = async (stuff) => {
|
61
|
-
if (!template) {
|
62
|
-
const buffer = await readFile(templatePath$1);
|
63
|
-
template = buffer.toString();
|
64
|
-
}
|
65
99
|
const data = {
|
66
100
|
...stuff,
|
67
101
|
googleTagId: process.env.GOOGLE_TAG_ID,
|
@@ -70,20 +104,13 @@ const renderHtml$1 = async (stuff) => {
|
|
70
104
|
return Mustache$1.render(template, data);
|
71
105
|
};
|
72
106
|
const createHtmlRenderer$1 = (onTemplateUpdate) => {
|
73
|
-
let
|
74
|
-
|
75
|
-
|
76
|
-
|
107
|
+
let currentTemplate = template;
|
108
|
+
chokidar.watch(templatePath).on("change", () => {
|
109
|
+
delete require.cache[require.resolve(templatePath)];
|
110
|
+
currentTemplate = require(templatePath);
|
77
111
|
onTemplateUpdate();
|
78
112
|
});
|
79
|
-
const loadTemplate = async () => {
|
80
|
-
if (!shouldReload) return;
|
81
|
-
const buffer = await readFile(templatePath$1);
|
82
|
-
currentTemplate = buffer.toString();
|
83
|
-
shouldReload = false;
|
84
|
-
};
|
85
113
|
return async (stuff) => {
|
86
|
-
await loadTemplate();
|
87
114
|
const data = {
|
88
115
|
...stuff,
|
89
116
|
googleTagId: process.env.GOOGLE_TAG_ID,
|
@@ -132,7 +159,7 @@ var ssrTransformWebpackStats = {
|
|
132
159
|
const path$8 = require$$0;
|
133
160
|
const webpack$6 = require$$1$1;
|
134
161
|
const compression$2 = require$$2$1;
|
135
|
-
const readline$1 = require$$3
|
162
|
+
const readline$1 = require$$3;
|
136
163
|
const chalk$1 = require$$4;
|
137
164
|
const devMiddleware$1 = require$$5;
|
138
165
|
const { createHtmlRenderer } = ssrRenderHtml;
|
@@ -319,7 +346,7 @@ var ssr_prod = function createSsrProdServer(projectRoot, { clientConfig: clientC
|
|
319
346
|
const path$6 = require$$0;
|
320
347
|
const webpack$5 = require$$1$1;
|
321
348
|
const compression$1 = require$$2$1;
|
322
|
-
const readline = require$$3
|
349
|
+
const readline = require$$3;
|
323
350
|
const chalk = require$$4;
|
324
351
|
const devMiddleware = require$$5;
|
325
352
|
const history$1 = require$$6;
|
@@ -387,7 +414,7 @@ var spa_dev = function createSpaDevServer(projectRoot, { spaConfig: spaConfig2,
|
|
387
414
|
createDevRenderer();
|
388
415
|
return startServer;
|
389
416
|
};
|
390
|
-
const fs
|
417
|
+
const fs = require$$0$1;
|
391
418
|
const path$5 = require$$0;
|
392
419
|
const compression = require$$2$1;
|
393
420
|
const express = require$$1$2;
|
@@ -403,7 +430,7 @@ var spa_prod = function createSpaProdServer(projectRoot, { createServerPath }) {
|
|
403
430
|
index: "/index.html"
|
404
431
|
}));
|
405
432
|
app.get("*", (req, res) => {
|
406
|
-
fs
|
433
|
+
fs.readFile(path$5.resolve(projectRoot, "builds/web/spa", "index.html"), "utf-8", (err, content) => {
|
407
434
|
if (err) {
|
408
435
|
console.log('We cannot open "index.html" file.');
|
409
436
|
res.writeHead(500, {
|
@@ -432,7 +459,7 @@ var spa_prod = function createSpaProdServer(projectRoot, { createServerPath }) {
|
|
432
459
|
const path$4 = require$$0;
|
433
460
|
const webpack$4 = require$$1$1;
|
434
461
|
const { VueLoaderPlugin } = require$$2$2;
|
435
|
-
const MiniCssExtractPlugin = require$$3$
|
462
|
+
const MiniCssExtractPlugin = require$$3$1;
|
436
463
|
const { CleanWebpackPlugin } = require$$4$1;
|
437
464
|
const BundleAnalyzerPlugin = require$$5$1.BundleAnalyzerPlugin;
|
438
465
|
const Dotenv = require$$6$1;
|
@@ -554,7 +581,7 @@ var webpack_config_base = (projectRoot) => {
|
|
554
581
|
};
|
555
582
|
const path$3 = require$$0;
|
556
583
|
const glob = require$$1$3;
|
557
|
-
const { merge: merge$2 } = require$$3$
|
584
|
+
const { merge: merge$2 } = require$$3$2;
|
558
585
|
const { StatsWriterPlugin: StatsWriterPlugin$1 } = require$$4$2;
|
559
586
|
const CssMinimizerPlugin$1 = require$$6$2;
|
560
587
|
const TerserPlugin$1 = require$$7;
|
@@ -654,16 +681,16 @@ var webpack_config_server = (projectRoot) => {
|
|
654
681
|
};
|
655
682
|
const path$1 = require$$0;
|
656
683
|
const webpack$2 = require$$1$1;
|
657
|
-
const { merge: merge$1 } = require$$3$
|
684
|
+
const { merge: merge$1 } = require$$3$2;
|
658
685
|
const CssMinimizerPlugin = require$$6$2;
|
659
686
|
const CopyWebpackPlugin = require$$6$3;
|
660
687
|
const TerserPlugin = require$$7;
|
661
688
|
const HtmlWebpackPlugin = require$$8$1;
|
662
689
|
const { StatsWriterPlugin } = require$$4$2;
|
663
690
|
const Mustache = require$$1;
|
664
|
-
|
691
|
+
require$$0$1.promises;
|
665
692
|
const getClientConfig = webpack_config_client;
|
666
|
-
|
693
|
+
path$1.resolve(__dirname, "../templates/page.html");
|
667
694
|
const isProd = process.env.NODE_ENV === "production";
|
668
695
|
var webpack_config_spa = (projectRoot) => {
|
669
696
|
const spaConfig2 = {
|
@@ -686,7 +713,7 @@ var webpack_config_spa = (projectRoot) => {
|
|
686
713
|
}),
|
687
714
|
new HtmlWebpackPlugin({
|
688
715
|
templateContent: async () => {
|
689
|
-
const template2 =
|
716
|
+
const template2 = page;
|
690
717
|
const meta = {
|
691
718
|
htmlAttrs: 'lang="en"',
|
692
719
|
headAttrs: "",
|
@@ -721,7 +748,7 @@ var webpack_config_spa = (projectRoot) => {
|
|
721
748
|
const path = require$$0;
|
722
749
|
const webpack$1 = require$$1$1;
|
723
750
|
const nodeExternals = require$$2$3;
|
724
|
-
const { merge } = require$$3$
|
751
|
+
const { merge } = require$$3$2;
|
725
752
|
const { WebpackManifestPlugin } = require$$4$3;
|
726
753
|
const getBaseConfig = webpack_config_base;
|
727
754
|
var webpack_config_ssr = (projectRoot) => {
|
package/dist/builder.mjs
CHANGED
@@ -1,21 +1,21 @@
|
|
1
1
|
import require$$0 from "path";
|
2
2
|
import require$$1$1 from "webpack";
|
3
3
|
import require$$2$1 from "compression";
|
4
|
-
import require$$3
|
4
|
+
import require$$3 from "readline";
|
5
5
|
import require$$4 from "chalk";
|
6
6
|
import require$$5 from "webpack-dev-middleware";
|
7
7
|
import require$$1 from "mustache";
|
8
8
|
import require$$2 from "chokidar";
|
9
|
-
import require$$3 from "fs";
|
10
9
|
import require$$1$2 from "express";
|
11
10
|
import require$$6 from "connect-history-api-fallback";
|
11
|
+
import require$$0$1 from "fs";
|
12
12
|
import require$$2$2 from "vue-loader";
|
13
|
-
import require$$3$
|
13
|
+
import require$$3$1 from "mini-css-extract-plugin";
|
14
14
|
import require$$4$1 from "clean-webpack-plugin";
|
15
15
|
import require$$5$1 from "webpack-bundle-analyzer";
|
16
16
|
import require$$6$1 from "dotenv-webpack";
|
17
17
|
import require$$1$3 from "glob-all";
|
18
|
-
import require$$3$
|
18
|
+
import require$$3$2 from "webpack-merge";
|
19
19
|
import require$$4$2 from "webpack-stats-plugin";
|
20
20
|
import require$$6$2 from "css-minimizer-webpack-plugin";
|
21
21
|
import require$$7 from "terser-webpack-plugin";
|
@@ -28,17 +28,51 @@ import require$$4$3 from "webpack-manifest-plugin";
|
|
28
28
|
function getDefaultExportFromCjs(x) {
|
29
29
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
|
30
30
|
}
|
31
|
+
var page = `
|
32
|
+
<!-- <!DOCTYPE html> -->
|
33
|
+
<html {{{ meta.htmlAttrs }}}>
|
34
|
+
<head {{{ meta.headAttrs }}}>
|
35
|
+
{{{ meta.head }}}
|
36
|
+
<link rel="apple-touch-icon" sizes="180x180" href="/favicon/apple-touch-icon.png">
|
37
|
+
<link rel="icon" type="image/png" sizes="32x32" href="/favicon/favicon-32x32.png">
|
38
|
+
<link rel="icon" type="image/png" sizes="16x16" href="/favicon/favicon-16x16.png">
|
39
|
+
<link rel="manifest" href="/favicon/site.webmanifest">
|
40
|
+
<link rel="mask-icon" href="/favicon/safari-pinned-tab.svg" color="#5bbad5">
|
41
|
+
<meta name="msapplication-TileColor" content="#000000">
|
42
|
+
<meta name="theme-color" content="#ffffff">
|
43
|
+
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
|
44
|
+
{{{ head }}}
|
45
|
+
<!-- Sign in with Apple -->
|
46
|
+
<!-- <script type="text/javascript" src="https://appleid.cdn-apple.com/appleauth/static/jsapi/appleid/1/en_US/appleid.auth.js"></script> -->
|
47
|
+
</head>
|
48
|
+
<!-- Google tag (gtag.js) -->
|
49
|
+
<script async src="https://www.googletagmanager.com/gtag/js?id={{googleTagId}}"></script>
|
50
|
+
|
51
|
+
<body {{{ meta.bodyAttrs }}}>
|
52
|
+
<div id="app">{{{ appHtml }}}</div>
|
53
|
+
|
54
|
+
<script type="application/json" data-user-state>
|
55
|
+
{{{ userState }}}
|
56
|
+
</script>
|
57
|
+
|
58
|
+
<script>
|
59
|
+
window.dataLayer = window.dataLayer || [];
|
60
|
+
function gtag(){dataLayer.push(arguments);}
|
61
|
+
gtag('js', new Date());
|
62
|
+
|
63
|
+
gtag('config', '{{googleTagId}}');
|
64
|
+
</script>
|
65
|
+
|
66
|
+
{{{ meta.body }}} {{{ body }}}
|
67
|
+
</body>
|
68
|
+
</html>
|
69
|
+
`;
|
31
70
|
const path$9 = require$$0;
|
32
71
|
const Mustache$1 = require$$1;
|
33
72
|
const chokidar = require$$2;
|
34
|
-
const
|
35
|
-
const templatePath
|
36
|
-
let template;
|
73
|
+
const template = page;
|
74
|
+
const templatePath = path$9.resolve(__dirname, "../templates/page.js");
|
37
75
|
const renderHtml$1 = async (stuff) => {
|
38
|
-
if (!template) {
|
39
|
-
const buffer = await readFile(templatePath$1);
|
40
|
-
template = buffer.toString();
|
41
|
-
}
|
42
76
|
const data = {
|
43
77
|
...stuff,
|
44
78
|
googleTagId: process.env.GOOGLE_TAG_ID,
|
@@ -47,20 +81,13 @@ const renderHtml$1 = async (stuff) => {
|
|
47
81
|
return Mustache$1.render(template, data);
|
48
82
|
};
|
49
83
|
const createHtmlRenderer$1 = (onTemplateUpdate) => {
|
50
|
-
let
|
51
|
-
|
52
|
-
|
53
|
-
|
84
|
+
let currentTemplate = template;
|
85
|
+
chokidar.watch(templatePath).on("change", () => {
|
86
|
+
delete require.cache[require.resolve(templatePath)];
|
87
|
+
currentTemplate = require(templatePath);
|
54
88
|
onTemplateUpdate();
|
55
89
|
});
|
56
|
-
const loadTemplate = async () => {
|
57
|
-
if (!shouldReload) return;
|
58
|
-
const buffer = await readFile(templatePath$1);
|
59
|
-
currentTemplate = buffer.toString();
|
60
|
-
shouldReload = false;
|
61
|
-
};
|
62
90
|
return async (stuff) => {
|
63
|
-
await loadTemplate();
|
64
91
|
const data = {
|
65
92
|
...stuff,
|
66
93
|
googleTagId: process.env.GOOGLE_TAG_ID,
|
@@ -109,7 +136,7 @@ var ssrTransformWebpackStats = {
|
|
109
136
|
const path$8 = require$$0;
|
110
137
|
const webpack$6 = require$$1$1;
|
111
138
|
const compression$2 = require$$2$1;
|
112
|
-
const readline$1 = require$$3
|
139
|
+
const readline$1 = require$$3;
|
113
140
|
const chalk$1 = require$$4;
|
114
141
|
const devMiddleware$1 = require$$5;
|
115
142
|
const { createHtmlRenderer } = ssrRenderHtml;
|
@@ -296,7 +323,7 @@ var ssr_prod = function createSsrProdServer(projectRoot, { clientConfig: clientC
|
|
296
323
|
const path$6 = require$$0;
|
297
324
|
const webpack$5 = require$$1$1;
|
298
325
|
const compression$1 = require$$2$1;
|
299
|
-
const readline = require$$3
|
326
|
+
const readline = require$$3;
|
300
327
|
const chalk = require$$4;
|
301
328
|
const devMiddleware = require$$5;
|
302
329
|
const history$1 = require$$6;
|
@@ -364,7 +391,7 @@ var spa_dev = function createSpaDevServer(projectRoot, { spaConfig: spaConfig2,
|
|
364
391
|
createDevRenderer();
|
365
392
|
return startServer;
|
366
393
|
};
|
367
|
-
const fs
|
394
|
+
const fs = require$$0$1;
|
368
395
|
const path$5 = require$$0;
|
369
396
|
const compression = require$$2$1;
|
370
397
|
const express = require$$1$2;
|
@@ -380,7 +407,7 @@ var spa_prod = function createSpaProdServer(projectRoot, { createServerPath }) {
|
|
380
407
|
index: "/index.html"
|
381
408
|
}));
|
382
409
|
app.get("*", (req, res) => {
|
383
|
-
fs
|
410
|
+
fs.readFile(path$5.resolve(projectRoot, "builds/web/spa", "index.html"), "utf-8", (err, content) => {
|
384
411
|
if (err) {
|
385
412
|
console.log('We cannot open "index.html" file.');
|
386
413
|
res.writeHead(500, {
|
@@ -409,7 +436,7 @@ var spa_prod = function createSpaProdServer(projectRoot, { createServerPath }) {
|
|
409
436
|
const path$4 = require$$0;
|
410
437
|
const webpack$4 = require$$1$1;
|
411
438
|
const { VueLoaderPlugin } = require$$2$2;
|
412
|
-
const MiniCssExtractPlugin = require$$3$
|
439
|
+
const MiniCssExtractPlugin = require$$3$1;
|
413
440
|
const { CleanWebpackPlugin } = require$$4$1;
|
414
441
|
const BundleAnalyzerPlugin = require$$5$1.BundleAnalyzerPlugin;
|
415
442
|
const Dotenv = require$$6$1;
|
@@ -531,7 +558,7 @@ var webpack_config_base = (projectRoot) => {
|
|
531
558
|
};
|
532
559
|
const path$3 = require$$0;
|
533
560
|
const glob = require$$1$3;
|
534
|
-
const { merge: merge$2 } = require$$3$
|
561
|
+
const { merge: merge$2 } = require$$3$2;
|
535
562
|
const { StatsWriterPlugin: StatsWriterPlugin$1 } = require$$4$2;
|
536
563
|
const CssMinimizerPlugin$1 = require$$6$2;
|
537
564
|
const TerserPlugin$1 = require$$7;
|
@@ -631,16 +658,16 @@ var webpack_config_server = (projectRoot) => {
|
|
631
658
|
};
|
632
659
|
const path$1 = require$$0;
|
633
660
|
const webpack$2 = require$$1$1;
|
634
|
-
const { merge: merge$1 } = require$$3$
|
661
|
+
const { merge: merge$1 } = require$$3$2;
|
635
662
|
const CssMinimizerPlugin = require$$6$2;
|
636
663
|
const CopyWebpackPlugin = require$$6$3;
|
637
664
|
const TerserPlugin = require$$7;
|
638
665
|
const HtmlWebpackPlugin = require$$8$1;
|
639
666
|
const { StatsWriterPlugin } = require$$4$2;
|
640
667
|
const Mustache = require$$1;
|
641
|
-
|
668
|
+
require$$0$1.promises;
|
642
669
|
const getClientConfig = webpack_config_client;
|
643
|
-
|
670
|
+
path$1.resolve(__dirname, "../templates/page.html");
|
644
671
|
const isProd = process.env.NODE_ENV === "production";
|
645
672
|
var webpack_config_spa = (projectRoot) => {
|
646
673
|
const spaConfig2 = {
|
@@ -663,7 +690,7 @@ var webpack_config_spa = (projectRoot) => {
|
|
663
690
|
}),
|
664
691
|
new HtmlWebpackPlugin({
|
665
692
|
templateContent: async () => {
|
666
|
-
const template2 =
|
693
|
+
const template2 = page;
|
667
694
|
const meta = {
|
668
695
|
htmlAttrs: 'lang="en"',
|
669
696
|
headAttrs: "",
|
@@ -698,7 +725,7 @@ var webpack_config_spa = (projectRoot) => {
|
|
698
725
|
const path = require$$0;
|
699
726
|
const webpack$1 = require$$1$1;
|
700
727
|
const nodeExternals = require$$2$3;
|
701
|
-
const { merge } = require$$3$
|
728
|
+
const { merge } = require$$3$2;
|
702
729
|
const { WebpackManifestPlugin } = require$$4$3;
|
703
730
|
const getBaseConfig = webpack_config_base;
|
704
731
|
var webpack_config_ssr = (projectRoot) => {
|
@@ -0,0 +1,150 @@
|
|
1
|
+
"use strict";
|
2
|
+
const _commonjsHelpers = require("./_commonjsHelpers-DHfMLFPC.js");
|
3
|
+
require("./queryProcessor-iewDZq_f.js");
|
4
|
+
require("node-cache");
|
5
|
+
var page_model = (db) => {
|
6
|
+
const PageSchema = new db.mongoose.Schema({
|
7
|
+
name: { type: Object },
|
8
|
+
url: { type: String },
|
9
|
+
groups: { type: Array },
|
10
|
+
content: { type: [Object, Array] },
|
11
|
+
parent: {
|
12
|
+
type: db.mongoose.Schema.Types.ObjectId,
|
13
|
+
ref: "Page"
|
14
|
+
},
|
15
|
+
children: [{
|
16
|
+
type: db.mongoose.Schema.Types.ObjectId,
|
17
|
+
ref: "Page"
|
18
|
+
}]
|
19
|
+
}, {
|
20
|
+
timestamps: { currentTime: () => Date.now() }
|
21
|
+
});
|
22
|
+
const Page = db.mongoose.model("Page", PageSchema);
|
23
|
+
return Page;
|
24
|
+
};
|
25
|
+
const createPageController = (db) => {
|
26
|
+
const Page = db.page;
|
27
|
+
async function populateChildrenRecursively(page) {
|
28
|
+
await page.populate("children");
|
29
|
+
for (let child of page.children) {
|
30
|
+
await populateChildrenRecursively(child);
|
31
|
+
}
|
32
|
+
}
|
33
|
+
const create = async (req, res) => {
|
34
|
+
try {
|
35
|
+
const page = await Page.create(req.body);
|
36
|
+
if (!page) {
|
37
|
+
return res.status(404).send({ message: "Something wrong when creating page." });
|
38
|
+
}
|
39
|
+
if (req.body.parent) {
|
40
|
+
const parentPage = await Page.findById(req.body.parent);
|
41
|
+
if (parentPage) {
|
42
|
+
if (!parentPage.children) {
|
43
|
+
parentPage.children = [];
|
44
|
+
}
|
45
|
+
parentPage.children.push(page._id);
|
46
|
+
await parentPage.save();
|
47
|
+
} else {
|
48
|
+
console.warn(`Parent page with id ${req.body.parent} not found.`);
|
49
|
+
}
|
50
|
+
}
|
51
|
+
res.status(200).send(page);
|
52
|
+
} catch (err) {
|
53
|
+
res.status(500).send({ message: err.message });
|
54
|
+
}
|
55
|
+
};
|
56
|
+
const read = async (req, res) => {
|
57
|
+
try {
|
58
|
+
const { url } = req.query;
|
59
|
+
if (url) {
|
60
|
+
const page = await Page.findOne({ url }).populate("parent");
|
61
|
+
if (!page) {
|
62
|
+
return res.status(404).json({ message: "Page not found" });
|
63
|
+
}
|
64
|
+
await populateChildrenRecursively(page);
|
65
|
+
res.status(200).send(page);
|
66
|
+
} else {
|
67
|
+
const topLevelPages = await Page.find({ parent: null });
|
68
|
+
for (let page of topLevelPages) {
|
69
|
+
await populateChildrenRecursively(page);
|
70
|
+
}
|
71
|
+
res.json(topLevelPages);
|
72
|
+
}
|
73
|
+
} catch (error) {
|
74
|
+
console.error("Error:", error);
|
75
|
+
res.status(500).json({ message: "Server error" });
|
76
|
+
}
|
77
|
+
};
|
78
|
+
const update = async (req, res) => {
|
79
|
+
try {
|
80
|
+
const page = await Page.findOneAndUpdate({ _id: req.body._id }, req.body);
|
81
|
+
if (!page) {
|
82
|
+
return res.status(404).send({ message: "Page not found." });
|
83
|
+
}
|
84
|
+
res.status(200).send(page);
|
85
|
+
} catch (err) {
|
86
|
+
res.status(500).send({ message: err.message });
|
87
|
+
}
|
88
|
+
};
|
89
|
+
const deletePage = async (req, res) => {
|
90
|
+
try {
|
91
|
+
const page = await Page.findOneAndDelete({ _id: req.body._id });
|
92
|
+
if (!page) {
|
93
|
+
return res.status(404).send({ message: "Something wrong when deleting page." });
|
94
|
+
}
|
95
|
+
res.status(200).send(page);
|
96
|
+
} catch (err) {
|
97
|
+
res.status(500).send({ message: err.message });
|
98
|
+
}
|
99
|
+
};
|
100
|
+
return {
|
101
|
+
create,
|
102
|
+
read,
|
103
|
+
update,
|
104
|
+
delete: deletePage
|
105
|
+
};
|
106
|
+
};
|
107
|
+
var pages_factory = createPageController;
|
108
|
+
const controllerFactory = pages_factory;
|
109
|
+
var pages_routes = function(app, db, origins, publicPath) {
|
110
|
+
const controller = controllerFactory(db);
|
111
|
+
app.get(
|
112
|
+
"/api/pages/read",
|
113
|
+
controller.read
|
114
|
+
);
|
115
|
+
app.post(
|
116
|
+
"/api/pages/create",
|
117
|
+
controller.create
|
118
|
+
);
|
119
|
+
app.put(
|
120
|
+
"/api/pages/update",
|
121
|
+
controller.update
|
122
|
+
);
|
123
|
+
app.delete(
|
124
|
+
"/api/pages/delete",
|
125
|
+
controller.delete
|
126
|
+
);
|
127
|
+
};
|
128
|
+
const ModelPage = page_model;
|
129
|
+
const RoutesPage = pages_routes;
|
130
|
+
const FactoryPage = pages_factory;
|
131
|
+
function initializePages(app, db, origins, publicPath) {
|
132
|
+
db.page = ModelPage(db);
|
133
|
+
if (app) {
|
134
|
+
RoutesPage(app, db);
|
135
|
+
}
|
136
|
+
}
|
137
|
+
var pages_server = {
|
138
|
+
initialize: initializePages,
|
139
|
+
models: {
|
140
|
+
ModelPage
|
141
|
+
},
|
142
|
+
routes: {
|
143
|
+
RoutesPage
|
144
|
+
},
|
145
|
+
controllers: {
|
146
|
+
FactoryPage
|
147
|
+
}
|
148
|
+
};
|
149
|
+
const pages_server$1 = /* @__PURE__ */ _commonjsHelpers.getDefaultExportFromCjs(pages_server);
|
150
|
+
module.exports = pages_server$1;
|
@@ -0,0 +1,151 @@
|
|
1
|
+
import { g as getDefaultExportFromCjs } from "./_commonjsHelpers-CUmg6egw.mjs";
|
2
|
+
import "./queryProcessor-DQSFR9YA.mjs";
|
3
|
+
import "node-cache";
|
4
|
+
var page_model = (db) => {
|
5
|
+
const PageSchema = new db.mongoose.Schema({
|
6
|
+
name: { type: Object },
|
7
|
+
url: { type: String },
|
8
|
+
groups: { type: Array },
|
9
|
+
content: { type: [Object, Array] },
|
10
|
+
parent: {
|
11
|
+
type: db.mongoose.Schema.Types.ObjectId,
|
12
|
+
ref: "Page"
|
13
|
+
},
|
14
|
+
children: [{
|
15
|
+
type: db.mongoose.Schema.Types.ObjectId,
|
16
|
+
ref: "Page"
|
17
|
+
}]
|
18
|
+
}, {
|
19
|
+
timestamps: { currentTime: () => Date.now() }
|
20
|
+
});
|
21
|
+
const Page = db.mongoose.model("Page", PageSchema);
|
22
|
+
return Page;
|
23
|
+
};
|
24
|
+
const createPageController = (db) => {
|
25
|
+
const Page = db.page;
|
26
|
+
async function populateChildrenRecursively(page) {
|
27
|
+
await page.populate("children");
|
28
|
+
for (let child of page.children) {
|
29
|
+
await populateChildrenRecursively(child);
|
30
|
+
}
|
31
|
+
}
|
32
|
+
const create = async (req, res) => {
|
33
|
+
try {
|
34
|
+
const page = await Page.create(req.body);
|
35
|
+
if (!page) {
|
36
|
+
return res.status(404).send({ message: "Something wrong when creating page." });
|
37
|
+
}
|
38
|
+
if (req.body.parent) {
|
39
|
+
const parentPage = await Page.findById(req.body.parent);
|
40
|
+
if (parentPage) {
|
41
|
+
if (!parentPage.children) {
|
42
|
+
parentPage.children = [];
|
43
|
+
}
|
44
|
+
parentPage.children.push(page._id);
|
45
|
+
await parentPage.save();
|
46
|
+
} else {
|
47
|
+
console.warn(`Parent page with id ${req.body.parent} not found.`);
|
48
|
+
}
|
49
|
+
}
|
50
|
+
res.status(200).send(page);
|
51
|
+
} catch (err) {
|
52
|
+
res.status(500).send({ message: err.message });
|
53
|
+
}
|
54
|
+
};
|
55
|
+
const read = async (req, res) => {
|
56
|
+
try {
|
57
|
+
const { url } = req.query;
|
58
|
+
if (url) {
|
59
|
+
const page = await Page.findOne({ url }).populate("parent");
|
60
|
+
if (!page) {
|
61
|
+
return res.status(404).json({ message: "Page not found" });
|
62
|
+
}
|
63
|
+
await populateChildrenRecursively(page);
|
64
|
+
res.status(200).send(page);
|
65
|
+
} else {
|
66
|
+
const topLevelPages = await Page.find({ parent: null });
|
67
|
+
for (let page of topLevelPages) {
|
68
|
+
await populateChildrenRecursively(page);
|
69
|
+
}
|
70
|
+
res.json(topLevelPages);
|
71
|
+
}
|
72
|
+
} catch (error) {
|
73
|
+
console.error("Error:", error);
|
74
|
+
res.status(500).json({ message: "Server error" });
|
75
|
+
}
|
76
|
+
};
|
77
|
+
const update = async (req, res) => {
|
78
|
+
try {
|
79
|
+
const page = await Page.findOneAndUpdate({ _id: req.body._id }, req.body);
|
80
|
+
if (!page) {
|
81
|
+
return res.status(404).send({ message: "Page not found." });
|
82
|
+
}
|
83
|
+
res.status(200).send(page);
|
84
|
+
} catch (err) {
|
85
|
+
res.status(500).send({ message: err.message });
|
86
|
+
}
|
87
|
+
};
|
88
|
+
const deletePage = async (req, res) => {
|
89
|
+
try {
|
90
|
+
const page = await Page.findOneAndDelete({ _id: req.body._id });
|
91
|
+
if (!page) {
|
92
|
+
return res.status(404).send({ message: "Something wrong when deleting page." });
|
93
|
+
}
|
94
|
+
res.status(200).send(page);
|
95
|
+
} catch (err) {
|
96
|
+
res.status(500).send({ message: err.message });
|
97
|
+
}
|
98
|
+
};
|
99
|
+
return {
|
100
|
+
create,
|
101
|
+
read,
|
102
|
+
update,
|
103
|
+
delete: deletePage
|
104
|
+
};
|
105
|
+
};
|
106
|
+
var pages_factory = createPageController;
|
107
|
+
const controllerFactory = pages_factory;
|
108
|
+
var pages_routes = function(app, db, origins, publicPath) {
|
109
|
+
const controller = controllerFactory(db);
|
110
|
+
app.get(
|
111
|
+
"/api/pages/read",
|
112
|
+
controller.read
|
113
|
+
);
|
114
|
+
app.post(
|
115
|
+
"/api/pages/create",
|
116
|
+
controller.create
|
117
|
+
);
|
118
|
+
app.put(
|
119
|
+
"/api/pages/update",
|
120
|
+
controller.update
|
121
|
+
);
|
122
|
+
app.delete(
|
123
|
+
"/api/pages/delete",
|
124
|
+
controller.delete
|
125
|
+
);
|
126
|
+
};
|
127
|
+
const ModelPage = page_model;
|
128
|
+
const RoutesPage = pages_routes;
|
129
|
+
const FactoryPage = pages_factory;
|
130
|
+
function initializePages(app, db, origins, publicPath) {
|
131
|
+
db.page = ModelPage(db);
|
132
|
+
if (app) {
|
133
|
+
RoutesPage(app, db);
|
134
|
+
}
|
135
|
+
}
|
136
|
+
var pages_server = {
|
137
|
+
initialize: initializePages,
|
138
|
+
models: {
|
139
|
+
ModelPage
|
140
|
+
},
|
141
|
+
routes: {
|
142
|
+
RoutesPage
|
143
|
+
},
|
144
|
+
controllers: {
|
145
|
+
FactoryPage
|
146
|
+
}
|
147
|
+
};
|
148
|
+
const pages_server$1 = /* @__PURE__ */ getDefaultExportFromCjs(pages_server);
|
149
|
+
export {
|
150
|
+
pages_server$1 as default
|
151
|
+
};
|