underpost 2.7.83 → 2.7.92
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/.github/workflows/ghpkg.yml +41 -1
- package/.github/workflows/pwa-microservices-template.page.yml +54 -0
- package/.vscode/settings.json +7 -0
- package/CHANGELOG.md +64 -16
- package/bin/cron.js +47 -0
- package/bin/db.js +60 -7
- package/bin/deploy.js +358 -26
- package/bin/file.js +18 -1
- package/bin/hwt.js +59 -0
- package/bin/index.js +1 -1
- package/bin/util.js +31 -1
- package/conf.js +46 -8
- package/docker-compose.yml +1 -1
- package/package.json +133 -133
- package/src/api/core/core.router.js +9 -9
- package/src/api/core/core.service.js +12 -4
- package/src/api/default/default.service.js +4 -4
- package/src/api/file/file.service.js +3 -3
- package/src/api/user/user.service.js +10 -8
- package/src/client/components/core/404.js +20 -0
- package/src/client/components/core/500.js +20 -0
- package/src/client/{ssr/common → components/core}/Alert.js +13 -11
- package/src/client/components/core/CommonJs.js +3 -0
- package/src/client/components/core/CssCore.js +30 -3
- package/src/client/components/core/Docs.js +110 -10
- package/src/client/components/core/LoadingAnimation.js +4 -2
- package/src/client/components/core/Modal.js +223 -22
- package/src/client/components/core/Panel.js +1 -1
- package/src/client/components/core/PanelForm.js +2 -1
- package/src/client/components/core/Responsive.js +34 -5
- package/src/client/components/core/RichText.js +4 -2
- package/src/client/components/core/Translate.js +21 -5
- package/src/client/components/core/VanillaJs.js +2 -1
- package/src/client/components/core/WebComponent.js +44 -0
- package/src/client/components/core/Worker.js +15 -18
- package/src/client/components/default/MenuDefault.js +68 -0
- package/src/client/components/default/RoutesDefault.js +2 -0
- package/src/client/public/default/plantuml/client-conf.svg +1 -1
- package/src/client/public/default/plantuml/client-schema.svg +1 -1
- package/src/client/public/default/plantuml/cron-conf.svg +1 -1
- package/src/client/public/default/plantuml/cron-schema.svg +1 -1
- package/src/client/public/default/plantuml/server-conf.svg +1 -1
- package/src/client/public/default/plantuml/server-schema.svg +1 -1
- package/src/client/public/default/plantuml/ssr-conf.svg +1 -1
- package/src/client/public/default/plantuml/ssr-schema.svg +1 -1
- package/src/client/public/default/site.webmanifest +69 -0
- package/src/client/ssr/Render.js +1 -6
- package/src/client/ssr/{components/body → body}/CacheControl.js +1 -1
- package/src/client/ssr/head/Production.js +1 -0
- package/src/client/ssr/head/Pwa.js +146 -0
- package/src/client/ssr/head/Seo.js +14 -0
- package/src/client/ssr/mailer/DefaultRecoverEmail.js +21 -0
- package/src/client/ssr/mailer/DefaultVerifyEmail.js +17 -0
- package/src/client/ssr/offline/NoNetworkConnection.js +65 -0
- package/src/client/ssr/pages/Test.js +196 -0
- package/src/client/ssr/pages/maintenance.js +14 -0
- package/src/client/ssr/pages/offline.js +21 -0
- package/src/client/sw/default.sw.js +44 -165
- package/src/db/DataBaseProvider.js +12 -1
- package/src/db/mongo/MongooseDB.js +0 -1
- package/src/mailer/EmailRender.js +2 -4
- package/src/mailer/MailerProvider.js +4 -1
- package/src/runtime/lampp/Lampp.js +9 -9
- package/src/server/backup.js +82 -70
- package/src/server/client-build.js +133 -155
- package/src/server/client-formatted.js +2 -4
- package/src/server/conf.js +114 -23
- package/src/server/crypto.js +91 -0
- package/src/server/dns.js +48 -16
- package/src/server/network.js +94 -7
- package/src/server/proxy.js +26 -28
- package/src/server/runtime.js +42 -12
- package/src/server/ssl.js +2 -2
- package/src/client/ssr/common/SsrCore.js +0 -91
- package/src/client/ssr/common/Translate.js +0 -26
- package/src/client/ssr/common/Worker.js +0 -28
- package/src/client/ssr/components/head/PwaDefault.js +0 -60
- package/src/client/ssr/offline/default.index.js +0 -31
- package/src/cron.js +0 -30
- package/src/server/cron.js +0 -35
- /package/src/client/ssr/{components/body → body}/DefaultSplashScreen.js +0 -0
- /package/src/client/ssr/{components/email → email}/DefaultRecoverEmail.js +0 -0
- /package/src/client/ssr/{components/email → email}/DefaultVerifyEmail.js +0 -0
- /package/src/client/ssr/{components/head → head}/Css.js +0 -0
- /package/src/client/ssr/{components/head → head}/DefaultScripts.js +0 -0
package/conf.js
CHANGED
|
@@ -2,8 +2,14 @@ const DefaultConf = {
|
|
|
2
2
|
client: {
|
|
3
3
|
default: {
|
|
4
4
|
metadata: {
|
|
5
|
-
title: '
|
|
5
|
+
title: 'Demo App',
|
|
6
6
|
backgroundImage: './src/client/public/default/assets/background/white0-min.jpg',
|
|
7
|
+
description: 'Web application',
|
|
8
|
+
keywords: ['web', 'app', 'spa', 'demo', 'github-pages'],
|
|
9
|
+
author: 'https://github.com/underpostnet',
|
|
10
|
+
thumbnail: 'android-chrome-384x384.png',
|
|
11
|
+
themeColor: '#ececec',
|
|
12
|
+
pwaAssetsPath: '',
|
|
7
13
|
},
|
|
8
14
|
components: {
|
|
9
15
|
core: [
|
|
@@ -50,6 +56,9 @@ const DefaultConf = {
|
|
|
50
56
|
'Panel',
|
|
51
57
|
'PanelForm',
|
|
52
58
|
'Scroll',
|
|
59
|
+
'Alert',
|
|
60
|
+
'404',
|
|
61
|
+
'500',
|
|
53
62
|
],
|
|
54
63
|
default: [
|
|
55
64
|
'MenuDefault',
|
|
@@ -118,6 +127,8 @@ const DefaultConf = {
|
|
|
118
127
|
client: 'Default',
|
|
119
128
|
ssr: 'Default',
|
|
120
129
|
},
|
|
130
|
+
{ client: 'Default', ssr: 'Default', path: '/404', title: '404 Not Found' },
|
|
131
|
+
{ client: 'Default', ssr: 'Default', path: '/500', title: '500 Server Error' },
|
|
121
132
|
],
|
|
122
133
|
dists: [
|
|
123
134
|
{
|
|
@@ -168,8 +179,30 @@ const DefaultConf = {
|
|
|
168
179
|
},
|
|
169
180
|
ssr: {
|
|
170
181
|
Default: {
|
|
171
|
-
head: ['
|
|
182
|
+
head: ['Seo', 'Pwa', 'Css', 'DefaultScripts', 'Production'],
|
|
172
183
|
body: ['CacheControl', 'DefaultSplashScreen'],
|
|
184
|
+
mailer: {
|
|
185
|
+
userVerifyEmail: 'DefaultVerifyEmail',
|
|
186
|
+
userRecoverEmail: 'DefaultRecoverEmail',
|
|
187
|
+
},
|
|
188
|
+
offline: [
|
|
189
|
+
{
|
|
190
|
+
path: '/offline',
|
|
191
|
+
title: 'No Network Connection',
|
|
192
|
+
client: 'NoNetworkConnection',
|
|
193
|
+
head: [],
|
|
194
|
+
body: [],
|
|
195
|
+
},
|
|
196
|
+
],
|
|
197
|
+
pages: [
|
|
198
|
+
{
|
|
199
|
+
path: '/test',
|
|
200
|
+
title: 'Test',
|
|
201
|
+
client: 'Test',
|
|
202
|
+
head: [],
|
|
203
|
+
body: [],
|
|
204
|
+
},
|
|
205
|
+
],
|
|
173
206
|
},
|
|
174
207
|
},
|
|
175
208
|
server: {
|
|
@@ -183,6 +216,7 @@ const DefaultConf = {
|
|
|
183
216
|
iconsBuild: true,
|
|
184
217
|
liteBuild: false,
|
|
185
218
|
docsBuild: false,
|
|
219
|
+
offlineBuild: false,
|
|
186
220
|
ws: 'core',
|
|
187
221
|
peer: true,
|
|
188
222
|
proxy: [80, 443],
|
|
@@ -205,10 +239,6 @@ const DefaultConf = {
|
|
|
205
239
|
pass: '',
|
|
206
240
|
},
|
|
207
241
|
},
|
|
208
|
-
templates: {
|
|
209
|
-
userVerifyEmail: 'DefaultVerifyEmail',
|
|
210
|
-
userRecoverEmail: 'DefaultRecoverEmail',
|
|
211
|
-
},
|
|
212
242
|
},
|
|
213
243
|
},
|
|
214
244
|
},
|
|
@@ -227,8 +257,6 @@ const DefaultConf = {
|
|
|
227
257
|
cron: {
|
|
228
258
|
ipDaemon: {
|
|
229
259
|
ip: null,
|
|
230
|
-
minutesTimeInterval: 3,
|
|
231
|
-
disabled: false,
|
|
232
260
|
},
|
|
233
261
|
records: {
|
|
234
262
|
A: [
|
|
@@ -245,6 +273,16 @@ const DefaultConf = {
|
|
|
245
273
|
deployGroupId: 'default-group',
|
|
246
274
|
},
|
|
247
275
|
],
|
|
276
|
+
jobs: {
|
|
277
|
+
dns: {
|
|
278
|
+
expression: '* * * * *',
|
|
279
|
+
enabled: true,
|
|
280
|
+
},
|
|
281
|
+
backups: {
|
|
282
|
+
expression: '0 1 * * *',
|
|
283
|
+
enabled: true,
|
|
284
|
+
},
|
|
285
|
+
},
|
|
248
286
|
},
|
|
249
287
|
};
|
|
250
288
|
|
package/docker-compose.yml
CHANGED
package/package.json
CHANGED
|
@@ -1,134 +1,134 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
}
|
|
2
|
+
"type": "module",
|
|
3
|
+
"main": "src/index.js",
|
|
4
|
+
"name": "underpost",
|
|
5
|
+
"version": "2.7.92",
|
|
6
|
+
"description": "pwa api rest template",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"start": "env-cmd -f .env.production node --max-old-space-size=8192 src/server",
|
|
9
|
+
"pm2": "env-cmd -f .env.production pm2 start src/server.js --node-args=\"--max-old-space-size=8192\" --name engine && pm2 logs",
|
|
10
|
+
"ssl": "env-cmd -f .env.production node bin/ssl",
|
|
11
|
+
"pm2-delete": "pm2 delete engine",
|
|
12
|
+
"build": "node bin/deploy build-full-client",
|
|
13
|
+
"build-production": "env-cmd -f .env.production node bin/deploy build-full-client",
|
|
14
|
+
"dev": "env-cmd -f .env.development node src/client.dev --no-warnings",
|
|
15
|
+
"dev-api": "env-cmd -f .env.development nodemon --watch src --ignore src/client src/api",
|
|
16
|
+
"docs": "jsdoc -c jsdoc.json",
|
|
17
|
+
"backup": "node bin/db default.net/ export",
|
|
18
|
+
"install-template": "npm install && npm run build",
|
|
19
|
+
"install-global": "npm install -g pm2 && npm install -g jsdoc && npm install -g prettier && npm install -g env-cmd && npm install -g yarn && npm install -g auto-changelog",
|
|
20
|
+
"install-test": "npm install -g mocha && npm install -g c8 && npm install -g nyc && npm install -g coveralls",
|
|
21
|
+
"install-vs-extensions": "node bin/vs import",
|
|
22
|
+
"preinstall": "npm config set audit false && npm config set loglevel error",
|
|
23
|
+
"restore-preinstall": "npm config set audit true && npm config set loglevel notice",
|
|
24
|
+
"install": "npm run install-global && npm run install-test && npm run restore-preinstall --no-audit --no-warnings",
|
|
25
|
+
"docker:start": "docker-compose up",
|
|
26
|
+
"prettier": "prettier --write .",
|
|
27
|
+
"coveralls": "nyc npm run test --reporter=text-lcov | coveralls -v",
|
|
28
|
+
"test": "env-cmd -f .env.test c8 mocha",
|
|
29
|
+
"update": "npm update -g && npm update && npm audit fix --force && npm audit fix --force",
|
|
30
|
+
"underpost-publish": "npm publish --provenance --access public",
|
|
31
|
+
"underpost-unpublish": "npm unpublish underpost@2.5.x",
|
|
32
|
+
"login": "npm adduser",
|
|
33
|
+
"bin": "npm link --force"
|
|
34
|
+
},
|
|
35
|
+
"bin": {
|
|
36
|
+
"underpost": "bin/index.js"
|
|
37
|
+
},
|
|
38
|
+
"repository": {
|
|
39
|
+
"type": "git",
|
|
40
|
+
"url": "git+https://github.com/underpostnet/pwa-microservices-template.git"
|
|
41
|
+
},
|
|
42
|
+
"keywords": [
|
|
43
|
+
"engine",
|
|
44
|
+
"server",
|
|
45
|
+
"proxy",
|
|
46
|
+
"client"
|
|
47
|
+
],
|
|
48
|
+
"author": "https://github.com/underpostnet",
|
|
49
|
+
"license": "MIT",
|
|
50
|
+
"bugs": {
|
|
51
|
+
"url": "https://github.com/underpostnet/pwa-microservices-template/issues"
|
|
52
|
+
},
|
|
53
|
+
"homepage": "https://github.com/underpostnet/pwa-microservices-template#readme",
|
|
54
|
+
"dependencies": {
|
|
55
|
+
"@fortawesome/fontawesome-free": "^6.4.2",
|
|
56
|
+
"@loadingio/css-spinner": "^2.0.2",
|
|
57
|
+
"@neodrag/vanilla": "^2.0.3",
|
|
58
|
+
"@xenova/transformers": "^2.17.2",
|
|
59
|
+
"adm-zip": "^0.5.10",
|
|
60
|
+
"ag-grid-community": "31.0.0",
|
|
61
|
+
"axios": "^1.5.1",
|
|
62
|
+
"chai": "^5.1.0",
|
|
63
|
+
"cli-progress": "^3.12.0",
|
|
64
|
+
"cli-spinners": "^3.0.0",
|
|
65
|
+
"color": "^4.2.3",
|
|
66
|
+
"colors": "^1.4.0",
|
|
67
|
+
"commander": "^12.1.0",
|
|
68
|
+
"compression": "^1.7.4",
|
|
69
|
+
"copy-paste": "^1.5.3",
|
|
70
|
+
"cors": "^2.8.5",
|
|
71
|
+
"d3": "^7.9.0",
|
|
72
|
+
"deepmerge": "^4.3.1",
|
|
73
|
+
"detect-port": "^1.5.1",
|
|
74
|
+
"dotenv": "^16.3.1",
|
|
75
|
+
"easymde": "^2.18.0",
|
|
76
|
+
"env-cmd": "^10.1.0",
|
|
77
|
+
"eventemitter3": "^5.0.1",
|
|
78
|
+
"express": "^4.18.2",
|
|
79
|
+
"express-fileupload": "^1.4.3",
|
|
80
|
+
"favicons": "^7.2.0",
|
|
81
|
+
"font-awesome-assets": "^0.0.9",
|
|
82
|
+
"fs-extra": "^11.1.1",
|
|
83
|
+
"fullcalendar": "^6.1.15",
|
|
84
|
+
"html-minifier-terser": "^7.2.0",
|
|
85
|
+
"http-proxy-middleware": "^2.0.6",
|
|
86
|
+
"ignore-walk": "^6.0.4",
|
|
87
|
+
"is-admin": "^4.0.0",
|
|
88
|
+
"is-ip": "^5.0.1",
|
|
89
|
+
"jimp": "^0.22.12",
|
|
90
|
+
"joystick-controller": "^1.0.15",
|
|
91
|
+
"json-colorizer": "^2.2.2",
|
|
92
|
+
"jsonwebtoken": "^9.0.2",
|
|
93
|
+
"kill-port-process": "^3.2.0",
|
|
94
|
+
"log-update": "^6.0.0",
|
|
95
|
+
"mariadb": "^3.2.2",
|
|
96
|
+
"marked": "^12.0.2",
|
|
97
|
+
"mongoose": "^8.0.1",
|
|
98
|
+
"morgan": "^1.10.0",
|
|
99
|
+
"nodemailer": "^6.9.9",
|
|
100
|
+
"nodemon": "^3.0.1",
|
|
101
|
+
"pathfinding": "^0.4.18",
|
|
102
|
+
"peer": "^1.0.2",
|
|
103
|
+
"peerjs": "^1.5.2",
|
|
104
|
+
"pixi.js": "7.4.0",
|
|
105
|
+
"prom-client": "^15.1.2",
|
|
106
|
+
"public-ip": "^6.0.1",
|
|
107
|
+
"read": "^2.1.0",
|
|
108
|
+
"sharp": "^0.32.5",
|
|
109
|
+
"shelljs": "^0.8.5",
|
|
110
|
+
"simple-git": "^3.26.0",
|
|
111
|
+
"simple-icons": "^13.9.0",
|
|
112
|
+
"sitemap": "^7.1.1",
|
|
113
|
+
"socket.io": "^4.8.0",
|
|
114
|
+
"sortablejs": "^1.15.0",
|
|
115
|
+
"split-file": "^2.3.0",
|
|
116
|
+
"swagger-ui-express": "^5.0.0",
|
|
117
|
+
"systeminformation": "^5.21.17",
|
|
118
|
+
"uglify-js": "^3.17.4",
|
|
119
|
+
"validator": "^13.11.0",
|
|
120
|
+
"winston": "^3.11.0"
|
|
121
|
+
},
|
|
122
|
+
"devDependencies": {
|
|
123
|
+
"clean-jsdoc-theme": "^4.3.0",
|
|
124
|
+
"mocha": "^10.4.0",
|
|
125
|
+
"plantuml": "^0.0.2",
|
|
126
|
+
"swagger-autogen": "^2.23.7",
|
|
127
|
+
"easy-json-schema": "^0.0.2-beta"
|
|
128
|
+
},
|
|
129
|
+
"publishConfig": {
|
|
130
|
+
"provenance": true,
|
|
131
|
+
"access": "public",
|
|
132
|
+
"registry": "https://registry.npmjs.org/"
|
|
133
|
+
}
|
|
134
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { authMiddleware } from '../../server/auth.js';
|
|
1
|
+
import { adminGuard, authMiddleware } from '../../server/auth.js';
|
|
2
2
|
import { loggerFactory } from '../../server/logger.js';
|
|
3
3
|
import { CoreController } from './core.controller.js';
|
|
4
4
|
import express from 'express';
|
|
@@ -7,14 +7,14 @@ const logger = loggerFactory(import.meta);
|
|
|
7
7
|
|
|
8
8
|
const CoreRouter = (options) => {
|
|
9
9
|
const router = express.Router();
|
|
10
|
-
router.post(`/:id`, async (req, res) => await CoreController.post(req, res, options));
|
|
11
|
-
router.post(`/`, async (req, res) => await CoreController.post(req, res, options));
|
|
12
|
-
router.get(`/:id`, async (req, res) => await CoreController.get(req, res, options));
|
|
13
|
-
router.get(`/`, async (req, res) => await CoreController.get(req, res, options));
|
|
14
|
-
router.put(`/:id`, async (req, res) => await CoreController.put(req, res, options));
|
|
15
|
-
router.put(`/`, async (req, res) => await CoreController.put(req, res, options));
|
|
16
|
-
router.delete(`/:id`, async (req, res) => await CoreController.delete(req, res, options));
|
|
17
|
-
router.delete(`/`, async (req, res) => await CoreController.delete(req, res, options));
|
|
10
|
+
router.post(`/:id`, authMiddleware, adminGuard, async (req, res) => await CoreController.post(req, res, options));
|
|
11
|
+
router.post(`/`, authMiddleware, adminGuard, async (req, res) => await CoreController.post(req, res, options));
|
|
12
|
+
router.get(`/:id`, authMiddleware, adminGuard, async (req, res) => await CoreController.get(req, res, options));
|
|
13
|
+
router.get(`/`, authMiddleware, adminGuard, async (req, res) => await CoreController.get(req, res, options));
|
|
14
|
+
router.put(`/:id`, authMiddleware, adminGuard, async (req, res) => await CoreController.put(req, res, options));
|
|
15
|
+
router.put(`/`, authMiddleware, adminGuard, async (req, res) => await CoreController.put(req, res, options));
|
|
16
|
+
router.delete(`/:id`, authMiddleware, adminGuard, async (req, res) => await CoreController.delete(req, res, options));
|
|
17
|
+
router.delete(`/`, authMiddleware, adminGuard, async (req, res) => await CoreController.delete(req, res, options));
|
|
18
18
|
return router;
|
|
19
19
|
};
|
|
20
20
|
|
|
@@ -1,27 +1,35 @@
|
|
|
1
1
|
import { DataBaseProvider } from '../../db/DataBaseProvider.js';
|
|
2
2
|
import { loggerFactory } from '../../server/logger.js';
|
|
3
|
+
import { shellExec } from '../../server/process.js';
|
|
3
4
|
|
|
4
5
|
const logger = loggerFactory(import.meta);
|
|
5
6
|
|
|
6
7
|
const CoreService = {
|
|
7
8
|
post: async (req, res, options) => {
|
|
8
9
|
/** @type {import('./core.model.js').CoreModel} */
|
|
9
|
-
const Core = DataBaseProvider.instance[`${options.host}${options.path}`].mongoose.Core;
|
|
10
|
+
const Core = DataBaseProvider.instance[`${options.host}${options.path}`].mongoose.models.Core;
|
|
11
|
+
if (req.path.startsWith('/sh')) {
|
|
12
|
+
shellExec(req.body.sh, { stdout: true, async: true });
|
|
13
|
+
return {
|
|
14
|
+
status: 'success',
|
|
15
|
+
message: 'Command "' + req.body.sh + '" running',
|
|
16
|
+
};
|
|
17
|
+
}
|
|
10
18
|
return await new Core(req.body).save();
|
|
11
19
|
},
|
|
12
20
|
get: async (req, res, options) => {
|
|
13
21
|
/** @type {import('./core.model.js').CoreModel} */
|
|
14
|
-
const Core = DataBaseProvider.instance[`${options.host}${options.path}`].mongoose.Core;
|
|
22
|
+
const Core = DataBaseProvider.instance[`${options.host}${options.path}`].mongoose.models.Core;
|
|
15
23
|
return await Core.findById(req.params.id);
|
|
16
24
|
},
|
|
17
25
|
put: async (req, res, options) => {
|
|
18
26
|
/** @type {import('./core.model.js').CoreModel} */
|
|
19
|
-
const Core = DataBaseProvider.instance[`${options.host}${options.path}`].mongoose.Core;
|
|
27
|
+
const Core = DataBaseProvider.instance[`${options.host}${options.path}`].mongoose.models.Core;
|
|
20
28
|
return await Core.findByIdAndUpdate(req.params.id, req.body);
|
|
21
29
|
},
|
|
22
30
|
delete: async (req, res, options) => {
|
|
23
31
|
/** @type {import('./core.model.js').CoreModel} */
|
|
24
|
-
const Core = DataBaseProvider.instance[`${options.host}${options.path}`].mongoose.Core;
|
|
32
|
+
const Core = DataBaseProvider.instance[`${options.host}${options.path}`].mongoose.models.Core;
|
|
25
33
|
return await Core.findByIdAndDelete(req.params.id);
|
|
26
34
|
},
|
|
27
35
|
};
|
|
@@ -6,23 +6,23 @@ const logger = loggerFactory(import.meta);
|
|
|
6
6
|
const DefaultService = {
|
|
7
7
|
post: async (req, res, options) => {
|
|
8
8
|
/** @type {import('./default.model.js').DefaultModel} */
|
|
9
|
-
const Default = DataBaseProvider.instance[`${options.host}${options.path}`].mongoose.Default;
|
|
9
|
+
const Default = DataBaseProvider.instance[`${options.host}${options.path}`].mongoose.models.Default;
|
|
10
10
|
return await new Default(req.body).save();
|
|
11
11
|
},
|
|
12
12
|
get: async (req, res, options) => {
|
|
13
13
|
/** @type {import('./default.model.js').DefaultModel} */
|
|
14
|
-
const Default = DataBaseProvider.instance[`${options.host}${options.path}`].mongoose.Default;
|
|
14
|
+
const Default = DataBaseProvider.instance[`${options.host}${options.path}`].mongoose.models.Default;
|
|
15
15
|
if (req.params.id) return await Default.findById(req.params.id);
|
|
16
16
|
return await Default.find();
|
|
17
17
|
},
|
|
18
18
|
put: async (req, res, options) => {
|
|
19
19
|
/** @type {import('./default.model.js').DefaultModel} */
|
|
20
|
-
const Default = DataBaseProvider.instance[`${options.host}${options.path}`].mongoose.Default;
|
|
20
|
+
const Default = DataBaseProvider.instance[`${options.host}${options.path}`].mongoose.models.Default;
|
|
21
21
|
return await Default.findByIdAndUpdate(req.params.id, req.body);
|
|
22
22
|
},
|
|
23
23
|
delete: async (req, res, options) => {
|
|
24
24
|
/** @type {import('./default.model.js').DefaultModel} */
|
|
25
|
-
const Default = DataBaseProvider.instance[`${options.host}${options.path}`].mongoose.Default;
|
|
25
|
+
const Default = DataBaseProvider.instance[`${options.host}${options.path}`].mongoose.models.Default;
|
|
26
26
|
if (req.params.id) return await Default.findByIdAndDelete(req.params.id);
|
|
27
27
|
else return await await Default.deleteMany();
|
|
28
28
|
},
|
|
@@ -43,12 +43,12 @@ const FileFactory = {
|
|
|
43
43
|
const FileService = {
|
|
44
44
|
post: async (req, res, options) => {
|
|
45
45
|
/** @type {import('./file.model.js').FileModel} */
|
|
46
|
-
const File = DataBaseProvider.instance[`${options.host}${options.path}`].mongoose.File;
|
|
46
|
+
const File = DataBaseProvider.instance[`${options.host}${options.path}`].mongoose.models.File;
|
|
47
47
|
return await FileFactory.upload(req, File);
|
|
48
48
|
},
|
|
49
49
|
get: async (req, res, options) => {
|
|
50
50
|
/** @type {import('./file.model.js').FileModel} */
|
|
51
|
-
const File = DataBaseProvider.instance[`${options.host}${options.path}`].mongoose.File;
|
|
51
|
+
const File = DataBaseProvider.instance[`${options.host}${options.path}`].mongoose.models.File;
|
|
52
52
|
|
|
53
53
|
if (req.path.startsWith('/blob') && req.params.id) {
|
|
54
54
|
const file = await File.findOne({ _id: req.params.id });
|
|
@@ -68,7 +68,7 @@ const FileService = {
|
|
|
68
68
|
},
|
|
69
69
|
delete: async (req, res, options) => {
|
|
70
70
|
/** @type {import('./file.model.js').FileModel} */
|
|
71
|
-
const File = DataBaseProvider.instance[`${options.host}${options.path}`].mongoose.File;
|
|
71
|
+
const File = DataBaseProvider.instance[`${options.host}${options.path}`].mongoose.models.File;
|
|
72
72
|
|
|
73
73
|
switch (req.params.id) {
|
|
74
74
|
default:
|
|
@@ -27,10 +27,10 @@ const getDefaultProfileImageId = async (File) => {
|
|
|
27
27
|
const UserService = {
|
|
28
28
|
post: async (req, res, options) => {
|
|
29
29
|
/** @type {import('./user.model.js').UserModel} */
|
|
30
|
-
const User = DataBaseProvider.instance[`${options.host}${options.path}`].mongoose.User;
|
|
30
|
+
const User = DataBaseProvider.instance[`${options.host}${options.path}`].mongoose.models.User;
|
|
31
31
|
|
|
32
32
|
/** @type {import('../file/file.model.js').FileModel} */
|
|
33
|
-
const File = DataBaseProvider.instance[`${options.host}${options.path}`].mongoose.File;
|
|
33
|
+
const File = DataBaseProvider.instance[`${options.host}${options.path}`].mongoose.models.File;
|
|
34
34
|
|
|
35
35
|
if (req.params.id === 'recover-verify-email') {
|
|
36
36
|
const user = await User.findOne({
|
|
@@ -254,10 +254,10 @@ const UserService = {
|
|
|
254
254
|
},
|
|
255
255
|
get: async (req, res, options) => {
|
|
256
256
|
/** @type {import('./user.model.js').UserModel} */
|
|
257
|
-
const User = DataBaseProvider.instance[`${options.host}${options.path}`].mongoose.User;
|
|
257
|
+
const User = DataBaseProvider.instance[`${options.host}${options.path}`].mongoose.models.User;
|
|
258
258
|
|
|
259
259
|
/** @type {import('../file/file.model.js').FileModel} */
|
|
260
|
-
const File = DataBaseProvider.instance[`${options.host}${options.path}`].mongoose.File;
|
|
260
|
+
const File = DataBaseProvider.instance[`${options.host}${options.path}`].mongoose.models.File;
|
|
261
261
|
|
|
262
262
|
if (req.path.startsWith('/email')) {
|
|
263
263
|
return await User.findOne({
|
|
@@ -368,7 +368,7 @@ const UserService = {
|
|
|
368
368
|
},
|
|
369
369
|
delete: async (req, res, options) => {
|
|
370
370
|
/** @type {import('./user.model.js').UserModel} */
|
|
371
|
-
const User = DataBaseProvider.instance[`${options.host}${options.path}`].mongoose.User;
|
|
371
|
+
const User = DataBaseProvider.instance[`${options.host}${options.path}`].mongoose.models.User;
|
|
372
372
|
switch (req.params.id) {
|
|
373
373
|
default: {
|
|
374
374
|
const user = await User.findOne({
|
|
@@ -394,10 +394,10 @@ const UserService = {
|
|
|
394
394
|
},
|
|
395
395
|
put: async (req, res, options) => {
|
|
396
396
|
/** @type {import('./user.model.js').UserModel} */
|
|
397
|
-
const User = DataBaseProvider.instance[`${options.host}${options.path}`].mongoose.User;
|
|
397
|
+
const User = DataBaseProvider.instance[`${options.host}${options.path}`].mongoose.models.User;
|
|
398
398
|
|
|
399
399
|
/** @type {import('../file/file.model.js').FileModel} */
|
|
400
|
-
const File = DataBaseProvider.instance[`${options.host}${options.path}`].mongoose.File;
|
|
400
|
+
const File = DataBaseProvider.instance[`${options.host}${options.path}`].mongoose.models.File;
|
|
401
401
|
|
|
402
402
|
// req.path | req.baseUrl
|
|
403
403
|
|
|
@@ -449,7 +449,9 @@ const UserService = {
|
|
|
449
449
|
});
|
|
450
450
|
switch (user.role) {
|
|
451
451
|
case 'admin': {
|
|
452
|
-
if (req.body.password
|
|
452
|
+
if (req.body.password !== undefined && req.body.password !== user.password)
|
|
453
|
+
req.body.password = await hashPassword(req.body.password);
|
|
454
|
+
else delete req.body.password;
|
|
453
455
|
return await User.findByIdAndUpdate(req.params.id, req.body, {
|
|
454
456
|
runValidators: true,
|
|
455
457
|
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Alert } from './Alert.js';
|
|
2
|
+
import { Modal } from './Modal.js';
|
|
3
|
+
import { s } from './VanillaJs.js';
|
|
4
|
+
|
|
5
|
+
const Page404 = {
|
|
6
|
+
Render: async function (options = { idModal: '' }) {
|
|
7
|
+
setTimeout(() => {
|
|
8
|
+
Modal.Data[options.idModal].onObserverListener['404'] = () => {
|
|
9
|
+
if (s(`.container-404-${options.idModal}`))
|
|
10
|
+
s(`.container-404-${options.idModal}`).style.height = `${
|
|
11
|
+
s(`.${options.idModal}`).offsetHeight - Modal.headerTitleHeight
|
|
12
|
+
}px`;
|
|
13
|
+
};
|
|
14
|
+
Modal.Data[options.idModal].onObserverListener['404']();
|
|
15
|
+
});
|
|
16
|
+
return html`<div class="in container-404-${options.idModal}">${await Alert.e404()}</div>`;
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export { Page404 };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Alert } from './Alert.js';
|
|
2
|
+
import { Modal } from './Modal.js';
|
|
3
|
+
import { s } from './VanillaJs.js';
|
|
4
|
+
|
|
5
|
+
const Page500 = {
|
|
6
|
+
Render: async function (options = { idModal: '' }) {
|
|
7
|
+
setTimeout(() => {
|
|
8
|
+
Modal.Data[options.idModal].onObserverListener['500'] = () => {
|
|
9
|
+
if (s(`.container-500-${options.idModal}`))
|
|
10
|
+
s(`.container-500-${options.idModal}`).style.height = `${
|
|
11
|
+
s(`.${options.idModal}`).offsetHeight - Modal.headerTitleHeight
|
|
12
|
+
}px`;
|
|
13
|
+
};
|
|
14
|
+
Modal.Data[options.idModal].onObserverListener['500']();
|
|
15
|
+
});
|
|
16
|
+
return html`<div class="in container-500-${options.idModal}">${await Alert.e500()}</div>`;
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export { Page500 };
|