underpost 2.8.1 → 2.8.7
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/.dockerignore +1 -0
- package/.github/workflows/ghpkg.yml +19 -49
- package/.github/workflows/npmpkg.yml +67 -0
- package/.github/workflows/publish.yml +5 -5
- package/.github/workflows/pwa-microservices-template.page.yml +12 -4
- package/.github/workflows/pwa-microservices-template.test.yml +2 -2
- package/.vscode/extensions.json +18 -71
- package/.vscode/settings.json +20 -3
- package/AUTHORS.md +16 -5
- package/CHANGELOG.md +123 -3
- package/Dockerfile +27 -70
- package/README.md +39 -29
- package/bin/build.js +186 -0
- package/bin/db.js +2 -24
- package/bin/deploy.js +1467 -236
- package/bin/file.js +67 -16
- package/bin/hwt.js +0 -10
- package/bin/index.js +1 -77
- package/bin/ssl.js +19 -11
- package/bin/util.js +9 -104
- package/bin/vs.js +26 -2
- package/cli.md +451 -0
- package/conf.js +29 -138
- package/docker-compose.yml +1 -1
- package/jsdoc.json +1 -1
- package/manifests/calico-custom-resources.yaml +25 -0
- package/manifests/deployment/adminer/deployment.yaml +32 -0
- package/manifests/deployment/adminer/kustomization.yaml +7 -0
- package/manifests/deployment/adminer/service.yaml +13 -0
- package/manifests/deployment/fastapi/backend-deployment.yml +120 -0
- package/manifests/deployment/fastapi/backend-service.yml +19 -0
- package/manifests/deployment/fastapi/frontend-deployment.yml +54 -0
- package/manifests/deployment/fastapi/frontend-service.yml +15 -0
- package/manifests/deployment/kafka/deployment.yaml +69 -0
- package/manifests/deployment/mongo-express/deployment.yaml +60 -0
- package/manifests/deployment/phpmyadmin/deployment.yaml +54 -0
- package/manifests/kind-config-dev.yaml +12 -0
- package/manifests/kind-config.yaml +12 -0
- package/manifests/kubeadm-calico-config.yaml +119 -0
- package/manifests/letsencrypt-prod.yaml +15 -0
- package/manifests/mariadb/config.yaml +10 -0
- package/manifests/mariadb/kustomization.yaml +9 -0
- package/manifests/mariadb/pv.yaml +12 -0
- package/manifests/mariadb/pvc.yaml +10 -0
- package/manifests/mariadb/secret.yaml +8 -0
- package/manifests/mariadb/service.yaml +10 -0
- package/manifests/mariadb/statefulset.yaml +55 -0
- package/manifests/mongodb/backup-access.yaml +16 -0
- package/manifests/mongodb/backup-cronjob.yaml +42 -0
- package/manifests/mongodb/backup-pv-pvc.yaml +22 -0
- package/manifests/mongodb/configmap.yaml +26 -0
- package/manifests/mongodb/headless-service.yaml +10 -0
- package/manifests/mongodb/kustomization.yaml +11 -0
- package/manifests/mongodb/pv-pvc.yaml +23 -0
- package/manifests/mongodb/statefulset.yaml +125 -0
- package/manifests/mongodb-4.4/kustomization.yaml +7 -0
- package/manifests/mongodb-4.4/pv-pvc.yaml +23 -0
- package/manifests/mongodb-4.4/service-deployment.yaml +63 -0
- package/manifests/postgresql/configmap.yaml +9 -0
- package/manifests/postgresql/kustomization.yaml +10 -0
- package/manifests/postgresql/pv.yaml +15 -0
- package/manifests/postgresql/pvc.yaml +13 -0
- package/manifests/postgresql/service.yaml +10 -0
- package/manifests/postgresql/statefulset.yaml +37 -0
- package/manifests/valkey/kustomization.yaml +7 -0
- package/manifests/valkey/service.yaml +17 -0
- package/manifests/valkey/statefulset.yaml +41 -0
- package/package.json +127 -136
- package/src/api/core/core.service.js +1 -1
- package/src/api/default/default.service.js +1 -1
- package/src/api/user/user.model.js +16 -3
- package/src/api/user/user.service.js +15 -12
- package/src/cli/cluster.js +389 -0
- package/src/cli/cron.js +121 -0
- package/src/cli/db.js +222 -0
- package/src/cli/deploy.js +487 -0
- package/src/cli/env.js +58 -0
- package/src/cli/fs.js +161 -0
- package/src/cli/image.js +66 -0
- package/src/cli/index.js +312 -0
- package/src/cli/monitor.js +236 -0
- package/src/cli/repository.js +128 -0
- package/src/cli/script.js +53 -0
- package/src/cli/secrets.js +37 -0
- package/src/cli/test.js +118 -0
- package/src/client/components/core/Account.js +28 -24
- package/src/client/components/core/Auth.js +22 -4
- package/src/client/components/core/Blockchain.js +1 -1
- package/src/client/components/core/CalendarCore.js +128 -121
- package/src/client/components/core/CommonJs.js +283 -19
- package/src/client/components/core/CssCore.js +16 -4
- package/src/client/components/core/Docs.js +1 -2
- package/src/client/components/core/DropDown.js +5 -1
- package/src/client/components/core/EventsUI.js +3 -3
- package/src/client/components/core/FileExplorer.js +86 -78
- package/src/client/components/core/Input.js +22 -6
- package/src/client/components/core/JoyStick.js +2 -2
- package/src/client/components/core/LoadingAnimation.js +3 -12
- package/src/client/components/core/LogIn.js +3 -3
- package/src/client/components/core/LogOut.js +1 -1
- package/src/client/components/core/Modal.js +54 -20
- package/src/client/components/core/Panel.js +109 -90
- package/src/client/components/core/PanelForm.js +23 -30
- package/src/client/components/core/Recover.js +3 -3
- package/src/client/components/core/RichText.js +1 -11
- package/src/client/components/core/Router.js +3 -1
- package/src/client/components/core/Scroll.js +1 -0
- package/src/client/components/core/SignUp.js +2 -2
- package/src/client/components/core/Translate.js +47 -9
- package/src/client/components/core/Validator.js +9 -1
- package/src/client/components/core/VanillaJs.js +0 -9
- package/src/client/components/core/Worker.js +34 -31
- package/src/client/components/default/RoutesDefault.js +3 -2
- package/src/client/services/core/core.service.js +15 -10
- package/src/client/services/default/default.management.js +46 -37
- package/src/client/ssr/Render.js +6 -1
- package/src/client/ssr/body/CacheControl.js +2 -3
- package/src/client/sw/default.sw.js +3 -3
- package/src/db/mongo/MongooseDB.js +29 -1
- package/src/index.js +101 -19
- package/src/mailer/MailerProvider.js +3 -0
- package/src/runtime/lampp/Dockerfile +65 -0
- package/src/runtime/lampp/Lampp.js +1 -13
- package/src/runtime/xampp/Xampp.js +0 -13
- package/src/server/auth.js +3 -3
- package/src/server/backup.js +49 -93
- package/src/server/client-build.js +49 -46
- package/src/server/client-formatted.js +6 -3
- package/src/server/conf.js +297 -55
- package/src/server/dns.js +75 -62
- package/src/server/downloader.js +0 -8
- package/src/server/json-schema.js +77 -0
- package/src/server/logger.js +15 -10
- package/src/server/network.js +20 -161
- package/src/server/peer.js +2 -2
- package/src/server/process.js +25 -2
- package/src/server/proxy.js +7 -29
- package/src/server/runtime.js +53 -40
- package/src/server/ssl.js +1 -1
- package/src/server/start.js +122 -0
- package/src/server/valkey.js +27 -11
- package/test/api.test.js +0 -8
- package/src/dns.js +0 -22
- package/src/server/prompt-optimizer.js +0 -28
- package/startup.js +0 -11
package/package.json
CHANGED
|
@@ -1,137 +1,128 @@
|
|
|
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
|
-
"plantuml": "^0.0.2",
|
|
130
|
-
"swagger-autogen": "^2.23.7"
|
|
131
|
-
},
|
|
132
|
-
"publishConfig": {
|
|
133
|
-
"provenance": true,
|
|
134
|
-
"access": "public",
|
|
135
|
-
"registry": "https://registry.npmjs.org/"
|
|
136
|
-
}
|
|
137
|
-
}
|
|
2
|
+
"type": "module",
|
|
3
|
+
"main": "src/index.js",
|
|
4
|
+
"name": "underpost",
|
|
5
|
+
"version": "2.8.7",
|
|
6
|
+
"description": "pwa api rest template",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"start": "env-cmd -f .env.production node --max-old-space-size=8192 src/server",
|
|
9
|
+
"test": "env-cmd -f .env.test c8 mocha",
|
|
10
|
+
"pm2": "env-cmd -f .env.production pm2 start src/server.js --node-args=\"--max-old-space-size=8192\" --name engine",
|
|
11
|
+
"dev": "env-cmd -f .env.development node src/client.dev default",
|
|
12
|
+
"dev-img": "env-cmd -f .env.development node src/server",
|
|
13
|
+
"prod-img": "env-cmd -f .env.production node src/server",
|
|
14
|
+
"monitor": "pm2 start bin/deploy.js --name monitor -- monitor",
|
|
15
|
+
"dev-api": "env-cmd -f .env.development nodemon --watch src --ignore src/client src/api",
|
|
16
|
+
"dev-client": "env-cmd -f .env.development node src/client.dev",
|
|
17
|
+
"proxy": "node src/proxy proxy",
|
|
18
|
+
"docs": "jsdoc -c jsdoc.json",
|
|
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-underpost": "cp -a $(npm root -g)/underpost/node_modules ./node_modules && npm install --only=dev --ignore-scripts",
|
|
22
|
+
"install": "npm run install-global && npm run install-test",
|
|
23
|
+
"docker:start": "docker-compose up",
|
|
24
|
+
"prettier": "prettier --write .",
|
|
25
|
+
"fix": "npm audit fix --force && npm audit",
|
|
26
|
+
"changelog": "auto-changelog",
|
|
27
|
+
"build": "node bin/deploy build-full-client"
|
|
28
|
+
},
|
|
29
|
+
"bin": {
|
|
30
|
+
"underpost": "bin/index.js"
|
|
31
|
+
},
|
|
32
|
+
"repository": {
|
|
33
|
+
"type": "git",
|
|
34
|
+
"url": "git+https://github.com/underpostnet/pwa-microservices-template.git"
|
|
35
|
+
},
|
|
36
|
+
"keywords": [
|
|
37
|
+
"pwa",
|
|
38
|
+
"microservices",
|
|
39
|
+
"template",
|
|
40
|
+
"builder",
|
|
41
|
+
"engine",
|
|
42
|
+
"server",
|
|
43
|
+
"proxy",
|
|
44
|
+
"client"
|
|
45
|
+
],
|
|
46
|
+
"author": "https://github.com/underpostnet",
|
|
47
|
+
"license": "MIT",
|
|
48
|
+
"bugs": {
|
|
49
|
+
"url": "https://github.com/underpostnet/pwa-microservices-template/issues"
|
|
50
|
+
},
|
|
51
|
+
"homepage": "https://github.com/underpostnet/pwa-microservices-template#readme",
|
|
52
|
+
"dependencies": {
|
|
53
|
+
"@fortawesome/fontawesome-free": "^6.4.2",
|
|
54
|
+
"@fullcalendar/rrule": "^6.1.15",
|
|
55
|
+
"@loadingio/css-spinner": "^2.0.2",
|
|
56
|
+
"@neodrag/vanilla": "^2.0.3",
|
|
57
|
+
"adm-zip": "^0.5.10",
|
|
58
|
+
"ag-grid-community": "31.0.0",
|
|
59
|
+
"axios": "^1.5.1",
|
|
60
|
+
"chai": "^5.1.0",
|
|
61
|
+
"clean-jsdoc-theme": "^4.3.0",
|
|
62
|
+
"cli-progress": "^3.12.0",
|
|
63
|
+
"cli-spinners": "^3.0.0",
|
|
64
|
+
"clipboardy": "^4.0.0",
|
|
65
|
+
"cloudinary": "^2.5.1",
|
|
66
|
+
"color": "^4.2.3",
|
|
67
|
+
"colors": "^1.4.0",
|
|
68
|
+
"commander": "^12.1.0",
|
|
69
|
+
"compression": "^1.7.4",
|
|
70
|
+
"cors": "^2.8.5",
|
|
71
|
+
"d3": "^7.9.0",
|
|
72
|
+
"dotenv": "^16.3.1",
|
|
73
|
+
"easymde": "^2.18.0",
|
|
74
|
+
"env-cmd": "^10.1.0",
|
|
75
|
+
"express": "^4.18.2",
|
|
76
|
+
"express-fileupload": "^1.4.3",
|
|
77
|
+
"favicons": "^7.2.0",
|
|
78
|
+
"font-awesome-assets": "^0.0.9",
|
|
79
|
+
"fs-extra": "^11.1.1",
|
|
80
|
+
"fullcalendar": "^6.1.15",
|
|
81
|
+
"html-minifier-terser": "^7.2.0",
|
|
82
|
+
"http-proxy-middleware": "^2.0.6",
|
|
83
|
+
"ignore-walk": "^6.0.4",
|
|
84
|
+
"iovalkey": "^0.2.1",
|
|
85
|
+
"jimp": "^0.22.12",
|
|
86
|
+
"joystick-controller": "^1.0.15",
|
|
87
|
+
"json-colorizer": "^2.2.2",
|
|
88
|
+
"jsonwebtoken": "^9.0.2",
|
|
89
|
+
"keyword-extractor": "^0.0.28",
|
|
90
|
+
"log-update": "^6.0.0",
|
|
91
|
+
"mariadb": "^3.2.2",
|
|
92
|
+
"marked": "^12.0.2",
|
|
93
|
+
"mocha": "^10.8.2",
|
|
94
|
+
"mongoose": "^8.9.5",
|
|
95
|
+
"morgan": "^1.10.0",
|
|
96
|
+
"nodemailer": "^6.9.9",
|
|
97
|
+
"nodemon": "^3.0.1",
|
|
98
|
+
"pathfinding": "^0.4.18",
|
|
99
|
+
"peer": "^1.0.2",
|
|
100
|
+
"peerjs": "^1.5.2",
|
|
101
|
+
"pixi.js": "7.4.2",
|
|
102
|
+
"plantuml": "^0.0.2",
|
|
103
|
+
"prom-client": "^15.1.2",
|
|
104
|
+
"public-ip": "^6.0.1",
|
|
105
|
+
"read": "^2.1.0",
|
|
106
|
+
"rrule": "^2.8.1",
|
|
107
|
+
"sharp": "^0.32.5",
|
|
108
|
+
"shelljs": "^0.8.5",
|
|
109
|
+
"simple-icons": "^13.9.0",
|
|
110
|
+
"sitemap": "^7.1.1",
|
|
111
|
+
"socket.io": "^4.8.0",
|
|
112
|
+
"sortablejs": "^1.15.0",
|
|
113
|
+
"split-file": "^2.3.0",
|
|
114
|
+
"swagger-autogen": "^2.23.7",
|
|
115
|
+
"swagger-ui-express": "^5.0.0",
|
|
116
|
+
"systeminformation": "^5.23.7",
|
|
117
|
+
"uglify-js": "^3.17.4",
|
|
118
|
+
"validator": "^13.11.0",
|
|
119
|
+
"vanilla-jsoneditor": "^2.3.2",
|
|
120
|
+
"winston": "^3.11.0"
|
|
121
|
+
},
|
|
122
|
+
"devDependencies": {},
|
|
123
|
+
"publishConfig": {
|
|
124
|
+
"provenance": true,
|
|
125
|
+
"access": "public",
|
|
126
|
+
"registry": "https://registry.npmjs.org/"
|
|
127
|
+
}
|
|
128
|
+
}
|
|
@@ -9,7 +9,7 @@ const CoreService = {
|
|
|
9
9
|
/** @type {import('./core.model.js').CoreModel} */
|
|
10
10
|
const Core = DataBaseProvider.instance[`${options.host}${options.path}`].mongoose.models.Core;
|
|
11
11
|
if (req.path.startsWith('/sh')) {
|
|
12
|
-
if (req.body.
|
|
12
|
+
if (req.body.stdout) return shellExec(req.body.sh, { stdout: true });
|
|
13
13
|
shellExec(req.body.sh, { async: true });
|
|
14
14
|
return 'Command "' + req.body.sh + '" running';
|
|
15
15
|
}
|
|
@@ -24,7 +24,7 @@ const DefaultService = {
|
|
|
24
24
|
/** @type {import('./default.model.js').DefaultModel} */
|
|
25
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
|
-
else return await
|
|
27
|
+
else return await Default.deleteMany();
|
|
28
28
|
},
|
|
29
29
|
};
|
|
30
30
|
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { Schema, model } from 'mongoose';
|
|
2
2
|
import validator from 'validator';
|
|
3
|
+
import { userRoleEnum } from '../../client/components/core/CommonJs.js';
|
|
3
4
|
|
|
4
5
|
// https://mongoosejs.com/docs/2.7.x/docs/schematypes.html
|
|
5
6
|
|
|
6
|
-
const userRoleEnum = ['admin', 'moderator', 'user', 'guest'];
|
|
7
|
-
|
|
8
7
|
const UserSchema = new Schema(
|
|
9
8
|
{
|
|
10
9
|
email: {
|
|
@@ -26,7 +25,11 @@ const UserSchema = new Schema(
|
|
|
26
25
|
profileImageId: { type: Schema.Types.ObjectId, ref: 'File' },
|
|
27
26
|
phoneNumbers: [
|
|
28
27
|
{
|
|
29
|
-
type: {
|
|
28
|
+
type: {
|
|
29
|
+
type: String,
|
|
30
|
+
enum: ['office', 'home', 'private'],
|
|
31
|
+
},
|
|
32
|
+
number: { type: String },
|
|
30
33
|
},
|
|
31
34
|
],
|
|
32
35
|
publicKey: {
|
|
@@ -38,6 +41,12 @@ const UserSchema = new Schema(
|
|
|
38
41
|
],
|
|
39
42
|
default: [],
|
|
40
43
|
},
|
|
44
|
+
associatedCompanies: [
|
|
45
|
+
{
|
|
46
|
+
company: { type: Schema.Types.ObjectId, ref: 'Company', required: true },
|
|
47
|
+
context: [{ type: String, enum: ['client', 'supplier', 'employee', 'owner'] }],
|
|
48
|
+
},
|
|
49
|
+
],
|
|
41
50
|
},
|
|
42
51
|
{
|
|
43
52
|
timestamps: true,
|
|
@@ -58,6 +67,10 @@ const UserDto = {
|
|
|
58
67
|
},
|
|
59
68
|
},
|
|
60
69
|
auth: {
|
|
70
|
+
// TODO: -> set login device, location, ip, fingerprint
|
|
71
|
+
// and validate on authorization middleware
|
|
72
|
+
// -> dynamic refresh 100 tokens per session with 12h interval
|
|
73
|
+
// -> back secret per user, registrarion user model -> secret: { type: String }
|
|
61
74
|
payload: (user) => ({ _id: user._id.toString(), role: user.role, email: user.email }),
|
|
62
75
|
},
|
|
63
76
|
};
|
|
@@ -225,8 +225,8 @@ const UserService = {
|
|
|
225
225
|
} else throw new Error('invalid email or password');
|
|
226
226
|
|
|
227
227
|
case 'guest': {
|
|
228
|
-
const user = await ValkeyAPI.valkeyObjectFactory('user'
|
|
229
|
-
await ValkeyAPI.setValkeyObject(user.email, user);
|
|
228
|
+
const user = await ValkeyAPI.valkeyObjectFactory(options, 'user');
|
|
229
|
+
await ValkeyAPI.setValkeyObject(options, user.email, user);
|
|
230
230
|
return {
|
|
231
231
|
token: hashJWT({ user: UserDto.auth.payload(user) }),
|
|
232
232
|
user: selectDtoFactory(user, UserDto.select.get()),
|
|
@@ -237,7 +237,7 @@ const UserService = {
|
|
|
237
237
|
const validatePassword = validatePasswordMiddleware(req.body.password);
|
|
238
238
|
if (validatePassword.status === 'error') throw new Error(validatePassword.message);
|
|
239
239
|
req.body.password = await hashPassword(req.body.password);
|
|
240
|
-
req.body.role = 'user';
|
|
240
|
+
req.body.role = req.body.role === 'guest' ? 'guest' : 'user';
|
|
241
241
|
req.body.profileImageId = await getDefaultProfileImageId(File);
|
|
242
242
|
const { _id } = await new User(req.body).save();
|
|
243
243
|
if (_id) {
|
|
@@ -325,15 +325,18 @@ const UserService = {
|
|
|
325
325
|
return await User.find().select(UserDto.select.getAll());
|
|
326
326
|
|
|
327
327
|
case 'auth': {
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
328
|
+
let user;
|
|
329
|
+
if (req.auth.user._id.match('guest')) {
|
|
330
|
+
user = await ValkeyAPI.getValkeyObject(options, req.auth.user.email);
|
|
331
|
+
if (!user) throw new Error('guest user expired');
|
|
332
|
+
} else
|
|
333
|
+
user = await User.findOne({
|
|
334
|
+
_id: req.auth.user._id,
|
|
335
|
+
});
|
|
333
336
|
|
|
334
337
|
const file = await File.findOne({ _id: user.profileImageId });
|
|
335
338
|
|
|
336
|
-
if (!file && !(await ValkeyAPI.getValkeyObject(req.auth.user.email))) {
|
|
339
|
+
if (!file && !(await ValkeyAPI.getValkeyObject(options, req.auth.user.email))) {
|
|
337
340
|
await User.findByIdAndUpdate(
|
|
338
341
|
user._id,
|
|
339
342
|
{ profileImageId: await getDefaultProfileImageId(File) },
|
|
@@ -342,8 +345,8 @@ const UserService = {
|
|
|
342
345
|
},
|
|
343
346
|
);
|
|
344
347
|
}
|
|
345
|
-
return (await ValkeyAPI.getValkeyObject(req.auth.user.email))
|
|
346
|
-
? selectDtoFactory(await ValkeyAPI.getValkeyObject(req.auth.user.email), UserDto.select.get())
|
|
348
|
+
return (await ValkeyAPI.getValkeyObject(options, req.auth.user.email))
|
|
349
|
+
? selectDtoFactory(await ValkeyAPI.getValkeyObject(options, req.auth.user.email), UserDto.select.get())
|
|
347
350
|
: await User.findOne({
|
|
348
351
|
_id: req.auth.user._id,
|
|
349
352
|
}).select(UserDto.select.get());
|
|
@@ -378,7 +381,7 @@ const UserService = {
|
|
|
378
381
|
switch (user.role) {
|
|
379
382
|
case 'admin': {
|
|
380
383
|
if (req.params.id) return await User.findByIdAndDelete(req.params.id);
|
|
381
|
-
else return await
|
|
384
|
+
else return await User.deleteMany();
|
|
382
385
|
}
|
|
383
386
|
default:
|
|
384
387
|
if (req.auth.user._id !== req.params.id) throw new Error(`Invalid token user id`);
|