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.
Files changed (85) hide show
  1. package/.github/workflows/ghpkg.yml +41 -1
  2. package/.github/workflows/pwa-microservices-template.page.yml +54 -0
  3. package/.vscode/settings.json +7 -0
  4. package/CHANGELOG.md +64 -16
  5. package/bin/cron.js +47 -0
  6. package/bin/db.js +60 -7
  7. package/bin/deploy.js +358 -26
  8. package/bin/file.js +18 -1
  9. package/bin/hwt.js +59 -0
  10. package/bin/index.js +1 -1
  11. package/bin/util.js +31 -1
  12. package/conf.js +46 -8
  13. package/docker-compose.yml +1 -1
  14. package/package.json +133 -133
  15. package/src/api/core/core.router.js +9 -9
  16. package/src/api/core/core.service.js +12 -4
  17. package/src/api/default/default.service.js +4 -4
  18. package/src/api/file/file.service.js +3 -3
  19. package/src/api/user/user.service.js +10 -8
  20. package/src/client/components/core/404.js +20 -0
  21. package/src/client/components/core/500.js +20 -0
  22. package/src/client/{ssr/common → components/core}/Alert.js +13 -11
  23. package/src/client/components/core/CommonJs.js +3 -0
  24. package/src/client/components/core/CssCore.js +30 -3
  25. package/src/client/components/core/Docs.js +110 -10
  26. package/src/client/components/core/LoadingAnimation.js +4 -2
  27. package/src/client/components/core/Modal.js +223 -22
  28. package/src/client/components/core/Panel.js +1 -1
  29. package/src/client/components/core/PanelForm.js +2 -1
  30. package/src/client/components/core/Responsive.js +34 -5
  31. package/src/client/components/core/RichText.js +4 -2
  32. package/src/client/components/core/Translate.js +21 -5
  33. package/src/client/components/core/VanillaJs.js +2 -1
  34. package/src/client/components/core/WebComponent.js +44 -0
  35. package/src/client/components/core/Worker.js +15 -18
  36. package/src/client/components/default/MenuDefault.js +68 -0
  37. package/src/client/components/default/RoutesDefault.js +2 -0
  38. package/src/client/public/default/plantuml/client-conf.svg +1 -1
  39. package/src/client/public/default/plantuml/client-schema.svg +1 -1
  40. package/src/client/public/default/plantuml/cron-conf.svg +1 -1
  41. package/src/client/public/default/plantuml/cron-schema.svg +1 -1
  42. package/src/client/public/default/plantuml/server-conf.svg +1 -1
  43. package/src/client/public/default/plantuml/server-schema.svg +1 -1
  44. package/src/client/public/default/plantuml/ssr-conf.svg +1 -1
  45. package/src/client/public/default/plantuml/ssr-schema.svg +1 -1
  46. package/src/client/public/default/site.webmanifest +69 -0
  47. package/src/client/ssr/Render.js +1 -6
  48. package/src/client/ssr/{components/body → body}/CacheControl.js +1 -1
  49. package/src/client/ssr/head/Production.js +1 -0
  50. package/src/client/ssr/head/Pwa.js +146 -0
  51. package/src/client/ssr/head/Seo.js +14 -0
  52. package/src/client/ssr/mailer/DefaultRecoverEmail.js +21 -0
  53. package/src/client/ssr/mailer/DefaultVerifyEmail.js +17 -0
  54. package/src/client/ssr/offline/NoNetworkConnection.js +65 -0
  55. package/src/client/ssr/pages/Test.js +196 -0
  56. package/src/client/ssr/pages/maintenance.js +14 -0
  57. package/src/client/ssr/pages/offline.js +21 -0
  58. package/src/client/sw/default.sw.js +44 -165
  59. package/src/db/DataBaseProvider.js +12 -1
  60. package/src/db/mongo/MongooseDB.js +0 -1
  61. package/src/mailer/EmailRender.js +2 -4
  62. package/src/mailer/MailerProvider.js +4 -1
  63. package/src/runtime/lampp/Lampp.js +9 -9
  64. package/src/server/backup.js +82 -70
  65. package/src/server/client-build.js +133 -155
  66. package/src/server/client-formatted.js +2 -4
  67. package/src/server/conf.js +114 -23
  68. package/src/server/crypto.js +91 -0
  69. package/src/server/dns.js +48 -16
  70. package/src/server/network.js +94 -7
  71. package/src/server/proxy.js +26 -28
  72. package/src/server/runtime.js +42 -12
  73. package/src/server/ssl.js +2 -2
  74. package/src/client/ssr/common/SsrCore.js +0 -91
  75. package/src/client/ssr/common/Translate.js +0 -26
  76. package/src/client/ssr/common/Worker.js +0 -28
  77. package/src/client/ssr/components/head/PwaDefault.js +0 -60
  78. package/src/client/ssr/offline/default.index.js +0 -31
  79. package/src/cron.js +0 -30
  80. package/src/server/cron.js +0 -35
  81. /package/src/client/ssr/{components/body → body}/DefaultSplashScreen.js +0 -0
  82. /package/src/client/ssr/{components/email → email}/DefaultRecoverEmail.js +0 -0
  83. /package/src/client/ssr/{components/email → email}/DefaultVerifyEmail.js +0 -0
  84. /package/src/client/ssr/{components/head → head}/Css.js +0 -0
  85. /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: 'Default',
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: ['PwaDefault', 'Css', 'DefaultScripts'],
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
 
@@ -58,7 +58,7 @@ services:
58
58
  cpus: '0.25'
59
59
  memory: 20M
60
60
  labels: # labels in Compose file instead of Dockerfile
61
- engine.version: '2.7.83'
61
+ engine.version: '2.7.92'
62
62
  networks:
63
63
  - load-balancer
64
64
 
package/package.json CHANGED
@@ -1,134 +1,134 @@
1
1
  {
2
- "type": "module",
3
- "main": "src/index.js",
4
- "name": "underpost",
5
- "version": "2.7.83",
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 --no-warnings",
13
- "dev": "env-cmd -f .env.development node src/client.dev --no-warnings",
14
- "dev-api": "env-cmd -f .env.development nodemon --watch src --ignore src/client src/api",
15
- "docs": "jsdoc -c jsdoc.json",
16
- "backup": "node bin/db default.net/ export",
17
- "install-template": "npm install && npm run build",
18
- "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",
19
- "install-test": "npm install -g mocha && npm install -g c8 && npm install -g nyc && npm install -g coveralls",
20
- "install-vs-extensions": "node bin/vs import",
21
- "preinstall": "npm config set audit false && npm config set loglevel error",
22
- "restore-preinstall": "npm config set audit true && npm config set loglevel notice",
23
- "install": "npm run install-global && npm run install-test && npm run restore-preinstall --no-audit --no-warnings",
24
- "docker:start": "docker-compose up",
25
- "prettier": "prettier --write .",
26
- "coveralls": "nyc npm run test --reporter=text-lcov | coveralls -v",
27
- "test": "env-cmd -f .env.test c8 mocha",
28
- "update": "npm update -g && npm update && npm audit fix --force && npm audit fix --force",
29
- "underpost-publish": "npm publish --provenance --access public",
30
- "underpost-unpublish": "npm unpublish underpost@2.5.x",
31
- "login": "npm adduser",
32
- "bin": "npm link --force"
33
- },
34
- "bin": {
35
- "underpost": "bin/index.js"
36
- },
37
- "repository": {
38
- "type": "git",
39
- "url": "git+https://github.com/underpostnet/pwa-microservices-template.git"
40
- },
41
- "keywords": [
42
- "engine",
43
- "server",
44
- "proxy",
45
- "client"
46
- ],
47
- "author": "https://github.com/underpostnet",
48
- "license": "MIT",
49
- "bugs": {
50
- "url": "https://github.com/underpostnet/pwa-microservices-template/issues"
51
- },
52
- "homepage": "https://github.com/underpostnet/pwa-microservices-template#readme",
53
- "dependencies": {
54
- "@fortawesome/fontawesome-free": "^6.4.2",
55
- "@loadingio/css-spinner": "^2.0.2",
56
- "@neodrag/vanilla": "^2.0.3",
57
- "@xenova/transformers": "^2.17.2",
58
- "adm-zip": "^0.5.10",
59
- "ag-grid-community": "31.0.0",
60
- "axios": "^1.5.1",
61
- "chai": "^5.1.0",
62
- "cli-progress": "^3.12.0",
63
- "cli-spinners": "^3.0.0",
64
- "color": "^4.2.3",
65
- "colors": "^1.4.0",
66
- "commander": "^12.1.0",
67
- "compression": "^1.7.4",
68
- "copy-paste": "^1.5.3",
69
- "cors": "^2.8.5",
70
- "d3": "^7.9.0",
71
- "deepmerge": "^4.3.1",
72
- "detect-port": "^1.5.1",
73
- "dotenv": "^16.3.1",
74
- "easymde": "^2.18.0",
75
- "env-cmd": "^10.1.0",
76
- "eventemitter3": "^5.0.1",
77
- "express": "^4.18.2",
78
- "express-fileupload": "^1.4.3",
79
- "favicons": "^7.2.0",
80
- "font-awesome-assets": "^0.0.9",
81
- "fs-extra": "^11.1.1",
82
- "fullcalendar": "^6.1.15",
83
- "html-minifier-terser": "^7.2.0",
84
- "http-proxy-middleware": "^2.0.6",
85
- "ignore-walk": "^6.0.4",
86
- "is-admin": "^4.0.0",
87
- "is-ip": "^5.0.1",
88
- "jimp": "^0.22.12",
89
- "joystick-controller": "^1.0.15",
90
- "json-colorizer": "^2.2.2",
91
- "jsonwebtoken": "^9.0.2",
92
- "kill-port-process": "^3.2.0",
93
- "log-update": "^6.0.0",
94
- "mariadb": "^3.2.2",
95
- "marked": "^12.0.2",
96
- "mongoose": "^8.0.1",
97
- "morgan": "^1.10.0",
98
- "node-cron": "^3.0.3",
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
- "to-json-schema": "^0.2.5"
128
- },
129
- "publishConfig": {
130
- "provenance": true,
131
- "access": "public",
132
- "registry": "https://registry.npmjs.org/"
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) req.body.password = await hashPassword(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 };