@underpostnet/underpost 2.8.1 → 2.8.4
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 +14 -11
- package/.github/workflows/pwa-microservices-template.page.yml +10 -3
- package/.vscode/extensions.json +17 -71
- package/.vscode/settings.json +10 -4
- package/AUTHORS.md +16 -5
- package/CHANGELOG.md +63 -3
- package/Dockerfile +41 -62
- package/README.md +1 -28
- package/bin/build.js +278 -0
- package/bin/db.js +2 -24
- package/bin/deploy.js +105 -55
- package/bin/file.js +33 -4
- package/bin/index.js +33 -51
- package/bin/ssl.js +19 -11
- package/bin/util.js +9 -89
- package/bin/vs.js +25 -2
- package/conf.js +31 -138
- package/docker-compose.yml +1 -1
- package/manifests/core/kustomization.yaml +11 -0
- package/manifests/core/underpost-engine-backup-access.yaml +16 -0
- package/manifests/core/underpost-engine-backup-pv-pvc.yaml +22 -0
- package/manifests/core/underpost-engine-headless-service.yaml +10 -0
- package/manifests/core/underpost-engine-mongodb-backup-cronjob.yaml +40 -0
- package/manifests/core/underpost-engine-mongodb-configmap.yaml +26 -0
- package/manifests/core/underpost-engine-pv-pvc.yaml +23 -0
- package/manifests/core/underpost-engine-statefulset.yaml +91 -0
- package/manifests/deployment/mongo-express.yaml +60 -0
- package/manifests/deployment/phpmyadmin.yaml +54 -0
- package/manifests/kind-config.yaml +12 -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/valkey/kustomization.yaml +7 -0
- package/manifests/valkey/underpost-engine-valkey-service.yaml +17 -0
- package/manifests/valkey/underpost-engine-valkey-statefulset.yaml +39 -0
- package/package.json +7 -28
- package/src/api/user/user.model.js +16 -3
- package/src/api/user/user.service.js +1 -1
- package/src/client/components/core/CalendarCore.js +115 -49
- package/src/client/components/core/CommonJs.js +150 -19
- package/src/client/components/core/CssCore.js +6 -0
- package/src/client/components/core/DropDown.js +5 -1
- package/src/client/components/core/Input.js +17 -3
- package/src/client/components/core/Modal.js +10 -5
- package/src/client/components/core/Panel.js +84 -25
- package/src/client/components/core/PanelForm.js +4 -18
- package/src/client/components/core/Translate.js +43 -9
- package/src/client/components/core/Validator.js +9 -1
- package/src/client/services/default/default.management.js +4 -2
- package/src/db/mongo/MongooseDB.js +13 -1
- package/src/index.js +8 -1
- 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/client-build.js +3 -13
- package/src/server/conf.js +296 -29
- package/src/server/dns.js +2 -3
- package/src/server/logger.js +10 -5
- package/src/server/network.js +0 -36
- package/src/server/process.js +25 -2
- package/src/server/project.js +39 -0
- package/src/server/proxy.js +4 -26
- package/src/server/runtime.js +6 -7
- package/src/server/ssl.js +1 -1
- package/src/server/valkey.js +2 -0
- package/startup.cjs +12 -0
- package/src/server/prompt-optimizer.js +0 -28
- package/startup.js +0 -11
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
apiVersion: batch/v1
|
|
2
|
+
kind: CronJob
|
|
3
|
+
metadata:
|
|
4
|
+
name: mongodb-backup
|
|
5
|
+
spec:
|
|
6
|
+
schedule: '*/5 * * * *' # Runs backup every five minutes
|
|
7
|
+
jobTemplate:
|
|
8
|
+
spec:
|
|
9
|
+
template:
|
|
10
|
+
spec:
|
|
11
|
+
containers:
|
|
12
|
+
- name: mongodump
|
|
13
|
+
image: docker.io/library/mongo:latest
|
|
14
|
+
command:
|
|
15
|
+
- sh
|
|
16
|
+
- -c
|
|
17
|
+
- |
|
|
18
|
+
# Perform backup
|
|
19
|
+
mongodump -u $MONGO_INITDB_ROOT_USERNAME -p $MONGO_INITDB_ROOT_PASSWORD --host=mongodb-service --port=27017 --out=/backup/$(date +\%Y-\%m-\%dT\%H-\%M-\%S)
|
|
20
|
+
# Remove backups older than 7 days
|
|
21
|
+
find /backup -type d -mtime +7 -exec rm -rf {} +
|
|
22
|
+
volumeMounts:
|
|
23
|
+
- name: backup-storage
|
|
24
|
+
mountPath: /backup
|
|
25
|
+
env:
|
|
26
|
+
- name: MONGO_INITDB_ROOT_USERNAME
|
|
27
|
+
valueFrom:
|
|
28
|
+
secretKeyRef:
|
|
29
|
+
name: mongodb-secret
|
|
30
|
+
key: username
|
|
31
|
+
- name: MONGO_INITDB_ROOT_PASSWORD
|
|
32
|
+
valueFrom:
|
|
33
|
+
secretKeyRef:
|
|
34
|
+
name: mongodb-secret
|
|
35
|
+
key: password
|
|
36
|
+
restartPolicy: Never
|
|
37
|
+
volumes:
|
|
38
|
+
- name: backup-storage
|
|
39
|
+
persistentVolumeClaim:
|
|
40
|
+
claimName: backup-pvc
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# origin conf: /etc/mongod.conf
|
|
2
|
+
apiVersion: v1
|
|
3
|
+
kind: ConfigMap
|
|
4
|
+
metadata:
|
|
5
|
+
name: mongodb-config-file
|
|
6
|
+
namespace: default
|
|
7
|
+
data:
|
|
8
|
+
mongod.conf: |
|
|
9
|
+
storage:
|
|
10
|
+
dbPath: /data/db
|
|
11
|
+
systemLog:
|
|
12
|
+
destination: file
|
|
13
|
+
logAppend: true
|
|
14
|
+
path: /var/log/mongodb/mongod.log
|
|
15
|
+
replication:
|
|
16
|
+
replSetName: rs0
|
|
17
|
+
net:
|
|
18
|
+
bindIp: 127.0.0.1
|
|
19
|
+
port: 27017
|
|
20
|
+
processManagement:
|
|
21
|
+
fork: true
|
|
22
|
+
setParameter:
|
|
23
|
+
enableLocalhostAuthBypass: false
|
|
24
|
+
security:
|
|
25
|
+
authorization: enabled
|
|
26
|
+
keyFile: /etc/mongodb-keyfile
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
apiVersion: v1
|
|
2
|
+
kind: PersistentVolume
|
|
3
|
+
metadata:
|
|
4
|
+
name: mongodb-pv
|
|
5
|
+
spec:
|
|
6
|
+
capacity:
|
|
7
|
+
storage: 5Gi
|
|
8
|
+
accessModes:
|
|
9
|
+
- ReadWriteOnce
|
|
10
|
+
hostPath:
|
|
11
|
+
path: /data/mongodb
|
|
12
|
+
---
|
|
13
|
+
apiVersion: v1
|
|
14
|
+
kind: PersistentVolumeClaim
|
|
15
|
+
metadata:
|
|
16
|
+
name: mongodb-pvc
|
|
17
|
+
spec:
|
|
18
|
+
storageClassName: ''
|
|
19
|
+
accessModes:
|
|
20
|
+
- ReadWriteOnce
|
|
21
|
+
resources:
|
|
22
|
+
requests:
|
|
23
|
+
storage: 5Gi
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
apiVersion: apps/v1
|
|
2
|
+
kind: StatefulSet
|
|
3
|
+
metadata:
|
|
4
|
+
name: mongodb # Specifies the name of the statefulset
|
|
5
|
+
spec:
|
|
6
|
+
serviceName: 'mongodb-service' # Specifies the service to use
|
|
7
|
+
replicas: 2
|
|
8
|
+
selector:
|
|
9
|
+
matchLabels:
|
|
10
|
+
app: mongodb
|
|
11
|
+
template:
|
|
12
|
+
metadata:
|
|
13
|
+
labels:
|
|
14
|
+
app: mongodb
|
|
15
|
+
spec:
|
|
16
|
+
containers:
|
|
17
|
+
- name: mongodb
|
|
18
|
+
image: docker.io/library/mongo:latest
|
|
19
|
+
command:
|
|
20
|
+
- mongod
|
|
21
|
+
- '--replSet'
|
|
22
|
+
- 'rs0'
|
|
23
|
+
# - '--config'
|
|
24
|
+
# - '-f'
|
|
25
|
+
# - '/etc/mongod.conf'
|
|
26
|
+
# - '--auth'
|
|
27
|
+
# - '--clusterAuthMode'
|
|
28
|
+
# - 'keyFile'
|
|
29
|
+
# - '--keyFile'
|
|
30
|
+
# - '/etc/mongodb-keyfile'
|
|
31
|
+
# - '--interleave'
|
|
32
|
+
# - 'all'
|
|
33
|
+
# - '--wiredTigerCacheSizeGB'
|
|
34
|
+
# - '0.25'
|
|
35
|
+
# - '--setParameter'
|
|
36
|
+
# - 'authenticationMechanisms=SCRAM-SHA-1'
|
|
37
|
+
# - '--fork'
|
|
38
|
+
- '--logpath'
|
|
39
|
+
- '/var/log/mongodb/mongod.log'
|
|
40
|
+
- '--bind_ip_all'
|
|
41
|
+
ports:
|
|
42
|
+
- containerPort: 27017
|
|
43
|
+
volumeMounts:
|
|
44
|
+
- name: mongodb-storage
|
|
45
|
+
mountPath: /data/db
|
|
46
|
+
- name: keyfile
|
|
47
|
+
mountPath: /etc/mongodb-keyfile
|
|
48
|
+
readOnly: true
|
|
49
|
+
# - name: mongodb-configuration-file
|
|
50
|
+
# mountPath: /etc/mongod.conf
|
|
51
|
+
# subPath: mongod.conf
|
|
52
|
+
# readOnly: true
|
|
53
|
+
# - name: mongodb-config
|
|
54
|
+
# mountPath: /config
|
|
55
|
+
env:
|
|
56
|
+
- name: MONGO_INITDB_ROOT_USERNAME
|
|
57
|
+
valueFrom:
|
|
58
|
+
secretKeyRef:
|
|
59
|
+
name: mongodb-secret
|
|
60
|
+
key: username
|
|
61
|
+
- name: MONGO_INITDB_ROOT_PASSWORD
|
|
62
|
+
valueFrom:
|
|
63
|
+
secretKeyRef:
|
|
64
|
+
name: mongodb-secret
|
|
65
|
+
key: password
|
|
66
|
+
resources:
|
|
67
|
+
requests:
|
|
68
|
+
cpu: '100m'
|
|
69
|
+
memory: '256Mi'
|
|
70
|
+
limits:
|
|
71
|
+
cpu: '500m'
|
|
72
|
+
memory: '512Mi'
|
|
73
|
+
volumes:
|
|
74
|
+
- name: keyfile
|
|
75
|
+
secret:
|
|
76
|
+
secretName: mongodb-keyfile
|
|
77
|
+
defaultMode: 0400
|
|
78
|
+
# - name: mongodb-configuration-file
|
|
79
|
+
# configMap:
|
|
80
|
+
# name: mongodb-config-file
|
|
81
|
+
# - name: mongodb-config
|
|
82
|
+
# configMap:
|
|
83
|
+
# name: mongodb-config
|
|
84
|
+
volumeClaimTemplates:
|
|
85
|
+
- metadata:
|
|
86
|
+
name: mongodb-storage
|
|
87
|
+
spec:
|
|
88
|
+
accessModes: ['ReadWriteOnce']
|
|
89
|
+
resources:
|
|
90
|
+
requests:
|
|
91
|
+
storage: 5Gi
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
apiVersion: apps/v1
|
|
2
|
+
kind: Deployment
|
|
3
|
+
metadata:
|
|
4
|
+
name: mongo-express
|
|
5
|
+
labels:
|
|
6
|
+
app: mongo-express
|
|
7
|
+
spec:
|
|
8
|
+
replicas: 1
|
|
9
|
+
selector:
|
|
10
|
+
matchLabels:
|
|
11
|
+
app: mongo-express
|
|
12
|
+
template:
|
|
13
|
+
metadata:
|
|
14
|
+
labels:
|
|
15
|
+
app: mongo-express
|
|
16
|
+
spec:
|
|
17
|
+
containers:
|
|
18
|
+
- name: mongo-express
|
|
19
|
+
image: mongo-express
|
|
20
|
+
ports:
|
|
21
|
+
- containerPort: 8081
|
|
22
|
+
env:
|
|
23
|
+
- name: ME_CONFIG_MONGODB_ADMINUSERNAME
|
|
24
|
+
valueFrom:
|
|
25
|
+
secretKeyRef:
|
|
26
|
+
name: mongodb-secret
|
|
27
|
+
key: username
|
|
28
|
+
- name: ME_CONFIG_MONGODB_ADMINPASSWORD
|
|
29
|
+
valueFrom:
|
|
30
|
+
secretKeyRef:
|
|
31
|
+
name: mongodb-secret
|
|
32
|
+
key: password
|
|
33
|
+
- name: ME_CONFIG_BASICAUTH_USERNAME
|
|
34
|
+
valueFrom:
|
|
35
|
+
secretKeyRef:
|
|
36
|
+
name: mongodb-secret
|
|
37
|
+
key: username
|
|
38
|
+
- name: ME_CONFIG_BASICAUTH_PASSWORD
|
|
39
|
+
valueFrom:
|
|
40
|
+
secretKeyRef:
|
|
41
|
+
name: mongodb-secret
|
|
42
|
+
key: password
|
|
43
|
+
- name: ME_CONFIG_MONGODB_SERVER
|
|
44
|
+
value: 'mongodb-0.mongodb-service'
|
|
45
|
+
- name: ME_CONFIG_MONGODB_ENABLE_ADMIN
|
|
46
|
+
value: 'true'
|
|
47
|
+
- name: ME_CONFIG_MONGODB_PORT
|
|
48
|
+
value: '27017'
|
|
49
|
+
---
|
|
50
|
+
apiVersion: v1
|
|
51
|
+
kind: Service
|
|
52
|
+
metadata:
|
|
53
|
+
name: mongo-express-service
|
|
54
|
+
spec:
|
|
55
|
+
selector:
|
|
56
|
+
app: mongo-express
|
|
57
|
+
ports:
|
|
58
|
+
- protocol: TCP
|
|
59
|
+
port: 8081
|
|
60
|
+
targetPort: 8081
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
apiVersion: apps/v1
|
|
2
|
+
kind: Deployment
|
|
3
|
+
metadata:
|
|
4
|
+
name: phpmyadmin-deployment
|
|
5
|
+
labels:
|
|
6
|
+
app: phpmyadmin
|
|
7
|
+
spec:
|
|
8
|
+
replicas: 1
|
|
9
|
+
selector:
|
|
10
|
+
matchLabels:
|
|
11
|
+
app: phpmyadmin
|
|
12
|
+
template:
|
|
13
|
+
metadata:
|
|
14
|
+
labels:
|
|
15
|
+
app: phpmyadmin
|
|
16
|
+
spec:
|
|
17
|
+
containers:
|
|
18
|
+
- name: phpmyadmin
|
|
19
|
+
image: phpmyadmin/phpmyadmin
|
|
20
|
+
ports:
|
|
21
|
+
- containerPort: 80
|
|
22
|
+
env:
|
|
23
|
+
- name: PMA_HOST
|
|
24
|
+
value: 'mariadb'
|
|
25
|
+
- name: PMA_PORT
|
|
26
|
+
value: '3306'
|
|
27
|
+
- name: PMA_USER
|
|
28
|
+
valueFrom:
|
|
29
|
+
secretKeyRef:
|
|
30
|
+
name: mariadb-secret
|
|
31
|
+
key: username
|
|
32
|
+
- name: PMA_PASSWORD
|
|
33
|
+
valueFrom:
|
|
34
|
+
secretKeyRef:
|
|
35
|
+
name: mariadb-secret
|
|
36
|
+
key: password
|
|
37
|
+
- name: UPLOAD_LIMIT
|
|
38
|
+
value: '300M'
|
|
39
|
+
- name: PMA_ARBITRARY
|
|
40
|
+
value: '1'
|
|
41
|
+
---
|
|
42
|
+
apiVersion: v1
|
|
43
|
+
kind: Service
|
|
44
|
+
metadata:
|
|
45
|
+
name: phpmyadmin-service
|
|
46
|
+
spec:
|
|
47
|
+
type: NodePort
|
|
48
|
+
selector:
|
|
49
|
+
app: phpmyadmin
|
|
50
|
+
ports:
|
|
51
|
+
- protocol: TCP
|
|
52
|
+
nodePort: 31008
|
|
53
|
+
port: 80
|
|
54
|
+
targetPort: 80
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
apiVersion: cert-manager.io/v1
|
|
2
|
+
kind: ClusterIssuer
|
|
3
|
+
metadata:
|
|
4
|
+
name: letsencrypt-prod
|
|
5
|
+
namespace: cert-manager
|
|
6
|
+
spec:
|
|
7
|
+
acme:
|
|
8
|
+
email: development@underpost.net
|
|
9
|
+
privateKeySecretRef:
|
|
10
|
+
name: letsencrypt-prod
|
|
11
|
+
server: https://acme-v02.api.letsencrypt.org/directory
|
|
12
|
+
solvers:
|
|
13
|
+
- http01:
|
|
14
|
+
ingress:
|
|
15
|
+
class: contour
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
apiVersion: apps/v1
|
|
2
|
+
kind: StatefulSet
|
|
3
|
+
metadata:
|
|
4
|
+
name: mariadb-statefulset
|
|
5
|
+
spec:
|
|
6
|
+
serviceName: mariadb
|
|
7
|
+
replicas: 1
|
|
8
|
+
selector:
|
|
9
|
+
matchLabels:
|
|
10
|
+
app: mariadb
|
|
11
|
+
template:
|
|
12
|
+
metadata:
|
|
13
|
+
labels:
|
|
14
|
+
app: mariadb
|
|
15
|
+
spec:
|
|
16
|
+
containers:
|
|
17
|
+
- name: mariadb
|
|
18
|
+
image: mariadb:latest
|
|
19
|
+
env:
|
|
20
|
+
- name: MYSQL_ROOT_PASSWORD
|
|
21
|
+
valueFrom:
|
|
22
|
+
secretKeyRef:
|
|
23
|
+
name: mariadb-secret
|
|
24
|
+
key: password
|
|
25
|
+
# - name: MYSQL_PASSWORD
|
|
26
|
+
# valueFrom:
|
|
27
|
+
# secretKeyRef:
|
|
28
|
+
# name: mariadb-secret
|
|
29
|
+
# key: password
|
|
30
|
+
# - name: MYSQL_USER
|
|
31
|
+
# valueFrom:
|
|
32
|
+
# secretKeyRef:
|
|
33
|
+
# name: mariadb-secret
|
|
34
|
+
# key: username
|
|
35
|
+
# - name: MYSQL_DATABASE
|
|
36
|
+
# value: default
|
|
37
|
+
ports:
|
|
38
|
+
- containerPort: 3306
|
|
39
|
+
volumeMounts:
|
|
40
|
+
- mountPath: /var/lib/mysql
|
|
41
|
+
name: mariadb-storage
|
|
42
|
+
# - mountPath: /etc/mysql/conf.d
|
|
43
|
+
# name: config-volume
|
|
44
|
+
# volumes:
|
|
45
|
+
# - name: config-volume
|
|
46
|
+
# configMap:
|
|
47
|
+
# name: mariadb-config
|
|
48
|
+
volumeClaimTemplates:
|
|
49
|
+
- metadata:
|
|
50
|
+
name: mariadb-storage
|
|
51
|
+
spec:
|
|
52
|
+
accessModes: ['ReadWriteOnce']
|
|
53
|
+
resources:
|
|
54
|
+
requests:
|
|
55
|
+
storage: 1Gi
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
---
|
|
2
|
+
apiVersion: v1
|
|
3
|
+
kind: Service
|
|
4
|
+
metadata:
|
|
5
|
+
name: service-valkey
|
|
6
|
+
namespace: default
|
|
7
|
+
spec:
|
|
8
|
+
ports:
|
|
9
|
+
- port: 6379
|
|
10
|
+
targetPort: 6379
|
|
11
|
+
selector:
|
|
12
|
+
app: service-valkey
|
|
13
|
+
ipFamilyPolicy: PreferDualStack
|
|
14
|
+
ipFamilies:
|
|
15
|
+
- IPv4
|
|
16
|
+
# - IPv6
|
|
17
|
+
type: ClusterIP
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
---
|
|
2
|
+
apiVersion: apps/v1
|
|
3
|
+
kind: StatefulSet
|
|
4
|
+
metadata:
|
|
5
|
+
name: service-valkey
|
|
6
|
+
namespace: default
|
|
7
|
+
spec:
|
|
8
|
+
serviceName: service-valkey
|
|
9
|
+
replicas: 1
|
|
10
|
+
selector:
|
|
11
|
+
matchLabels:
|
|
12
|
+
app: service-valkey
|
|
13
|
+
template:
|
|
14
|
+
metadata:
|
|
15
|
+
labels:
|
|
16
|
+
app: service-valkey
|
|
17
|
+
spec:
|
|
18
|
+
containers:
|
|
19
|
+
- name: service-valkey
|
|
20
|
+
image: docker.io/valkey/valkey:latest
|
|
21
|
+
env:
|
|
22
|
+
- name: TZ
|
|
23
|
+
value: Europe/Zurich
|
|
24
|
+
ports:
|
|
25
|
+
- containerPort: 6379
|
|
26
|
+
startupProbe:
|
|
27
|
+
tcpSocket:
|
|
28
|
+
port: 6379
|
|
29
|
+
failureThreshold: 30
|
|
30
|
+
periodSeconds: 5
|
|
31
|
+
timeoutSeconds: 5
|
|
32
|
+
livenessProbe:
|
|
33
|
+
tcpSocket:
|
|
34
|
+
port: 6379
|
|
35
|
+
failureThreshold: 2
|
|
36
|
+
periodSeconds: 30
|
|
37
|
+
timeoutSeconds: 5
|
|
38
|
+
restartPolicy: Always
|
|
39
|
+
automountServiceAccountToken: false
|
package/package.json
CHANGED
|
@@ -2,35 +2,20 @@
|
|
|
2
2
|
"type": "module",
|
|
3
3
|
"main": "src/index.js",
|
|
4
4
|
"name": "@underpostnet/underpost",
|
|
5
|
-
"version": "2.8.
|
|
5
|
+
"version": "2.8.4",
|
|
6
6
|
"description": "pwa api rest template",
|
|
7
7
|
"scripts": {
|
|
8
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
9
|
"build": "node bin/deploy build-full-client",
|
|
13
|
-
"
|
|
14
|
-
"dev": "env-cmd -f .env.development node src/client.dev",
|
|
10
|
+
"dev": "env-cmd -f .env.development node src/client.dev default",
|
|
15
11
|
"dev-api": "env-cmd -f .env.development nodemon --watch src --ignore src/client src/api",
|
|
16
12
|
"docs": "jsdoc -c jsdoc.json",
|
|
17
|
-
"backup": "node bin/db default.net/ export",
|
|
18
|
-
"install-template": "npm install && npm run build",
|
|
19
13
|
"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
14
|
"install-test": "npm install -g mocha && npm install -g c8 && npm install -g nyc && npm install -g coveralls",
|
|
21
|
-
"install
|
|
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",
|
|
15
|
+
"install": "npm run install-global && npm run install-test",
|
|
25
16
|
"docker:start": "docker-compose up",
|
|
26
17
|
"prettier": "prettier --write .",
|
|
27
|
-
"
|
|
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"
|
|
18
|
+
"test": "env-cmd -f .env.test c8 mocha"
|
|
34
19
|
},
|
|
35
20
|
"bin": {
|
|
36
21
|
"underpost": "bin/index.js"
|
|
@@ -53,6 +38,7 @@
|
|
|
53
38
|
"homepage": "https://github.com/underpostnet/pwa-microservices-template#readme",
|
|
54
39
|
"dependencies": {
|
|
55
40
|
"@fortawesome/fontawesome-free": "^6.4.2",
|
|
41
|
+
"@fullcalendar/rrule": "^6.1.15",
|
|
56
42
|
"@loadingio/css-spinner": "^2.0.2",
|
|
57
43
|
"@neodrag/vanilla": "^2.0.3",
|
|
58
44
|
"adm-zip": "^0.5.10",
|
|
@@ -61,19 +47,16 @@
|
|
|
61
47
|
"chai": "^5.1.0",
|
|
62
48
|
"cli-progress": "^3.12.0",
|
|
63
49
|
"cli-spinners": "^3.0.0",
|
|
50
|
+
"clipboardy": "^4.0.0",
|
|
64
51
|
"color": "^4.2.3",
|
|
65
52
|
"colors": "^1.4.0",
|
|
66
53
|
"commander": "^12.1.0",
|
|
67
54
|
"compression": "^1.7.4",
|
|
68
|
-
"copy-paste": "^1.5.3",
|
|
69
55
|
"cors": "^2.8.5",
|
|
70
56
|
"d3": "^7.9.0",
|
|
71
|
-
"deepmerge": "^4.3.1",
|
|
72
|
-
"detect-port": "^1.5.1",
|
|
73
57
|
"dotenv": "^16.3.1",
|
|
74
58
|
"easymde": "^2.18.0",
|
|
75
59
|
"env-cmd": "^10.1.0",
|
|
76
|
-
"eventemitter3": "^5.0.1",
|
|
77
60
|
"express": "^4.18.2",
|
|
78
61
|
"express-fileupload": "^1.4.3",
|
|
79
62
|
"favicons": "^7.2.0",
|
|
@@ -84,14 +67,11 @@
|
|
|
84
67
|
"http-proxy-middleware": "^2.0.6",
|
|
85
68
|
"ignore-walk": "^6.0.4",
|
|
86
69
|
"iovalkey": "^0.2.1",
|
|
87
|
-
"is-admin": "^4.0.0",
|
|
88
|
-
"is-ip": "^5.0.1",
|
|
89
70
|
"jimp": "^0.22.12",
|
|
90
71
|
"joystick-controller": "^1.0.15",
|
|
91
72
|
"json-colorizer": "^2.2.2",
|
|
92
73
|
"jsonwebtoken": "^9.0.2",
|
|
93
74
|
"keyword-extractor": "^0.0.28",
|
|
94
|
-
"kill-port-process": "^3.2.0",
|
|
95
75
|
"log-update": "^6.0.0",
|
|
96
76
|
"mariadb": "^3.2.2",
|
|
97
77
|
"marked": "^12.0.2",
|
|
@@ -106,9 +86,9 @@
|
|
|
106
86
|
"prom-client": "^15.1.2",
|
|
107
87
|
"public-ip": "^6.0.1",
|
|
108
88
|
"read": "^2.1.0",
|
|
89
|
+
"rrule": "^2.8.1",
|
|
109
90
|
"sharp": "^0.32.5",
|
|
110
91
|
"shelljs": "^0.8.5",
|
|
111
|
-
"simple-git": "^3.26.0",
|
|
112
92
|
"simple-icons": "^13.9.0",
|
|
113
93
|
"sitemap": "^7.1.1",
|
|
114
94
|
"socket.io": "^4.8.0",
|
|
@@ -119,7 +99,6 @@
|
|
|
119
99
|
"uglify-js": "^3.17.4",
|
|
120
100
|
"validator": "^13.11.0",
|
|
121
101
|
"vanilla-jsoneditor": "^2.3.2",
|
|
122
|
-
"web3": "^4.13.0",
|
|
123
102
|
"winston": "^3.11.0"
|
|
124
103
|
},
|
|
125
104
|
"devDependencies": {
|
|
@@ -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
|
};
|
|
@@ -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) {
|