underpost 2.8.872 → 2.8.874
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/.env.development +2 -1
- package/.env.production +2 -1
- package/.env.test +2 -1
- package/.github/workflows/ghpkg.ci.yml +1 -1
- package/.github/workflows/npmpkg.ci.yml +1 -1
- package/.github/workflows/pwa-microservices-template-page.cd.yml +1 -1
- package/.github/workflows/pwa-microservices-template-test.ci.yml +1 -1
- package/.github/workflows/release.cd.yml +2 -4
- package/README.md +24 -2
- package/bin/build.js +4 -0
- package/bin/deploy.js +4 -0
- package/cli.md +5 -2
- package/manifests/deployment/dd-default-development/deployment.yaml +2 -2
- package/manifests/deployment/dd-test-development/deployment.yaml +174 -0
- package/manifests/deployment/dd-test-development/proxy.yaml +51 -0
- package/package.json +5 -1
- package/src/api/core/core.router.js +2 -1
- package/src/api/default/default.controller.js +6 -1
- package/src/api/default/default.router.js +6 -2
- package/src/api/default/default.service.js +10 -1
- package/src/api/file/file.router.js +2 -1
- package/src/api/test/test.router.js +1 -1
- package/src/api/user/postman_collection.json +216 -0
- package/src/api/user/user.controller.js +25 -60
- package/src/api/user/user.model.js +29 -7
- package/src/api/user/user.router.js +9 -4
- package/src/api/user/user.service.js +84 -32
- package/src/cli/baremetal.js +33 -3
- package/src/cli/cloud-init.js +11 -0
- package/src/cli/deploy.js +44 -22
- package/src/cli/index.js +2 -0
- package/src/cli/lxd.js +7 -0
- package/src/cli/run.js +17 -5
- package/src/cli/ssh.js +20 -6
- package/src/client/components/core/AgGrid.js +28 -6
- package/src/client/components/core/Auth.js +99 -55
- package/src/client/components/core/LogIn.js +16 -23
- package/src/client/components/core/LogOut.js +5 -1
- package/src/client/components/core/Pagination.js +202 -9
- package/src/client/components/core/Router.js +30 -3
- package/src/client/components/core/SignUp.js +1 -2
- package/src/client/components/default/LogInDefault.js +0 -6
- package/src/client/components/default/LogOutDefault.js +0 -16
- package/src/client/services/core/core.service.js +5 -1
- package/src/client/services/default/default.management.js +115 -18
- package/src/client/services/default/default.service.js +9 -4
- package/src/client/services/user/user.management.js +6 -0
- package/src/client/services/user/user.service.js +11 -4
- package/src/index.js +24 -2
- package/src/runtime/lampp/Lampp.js +89 -2
- package/src/runtime/xampp/Xampp.js +48 -1
- package/src/server/auth.js +518 -155
- package/src/server/conf.js +19 -1
- package/src/server/runtime.js +64 -228
- package/src/server/ssr.js +85 -0
- package/src/server/valkey.js +2 -1
package/.env.development
CHANGED
package/.env.production
CHANGED
package/.env.test
CHANGED
|
@@ -2,7 +2,7 @@ name: CD | Release deployment | remote ssh
|
|
|
2
2
|
|
|
3
3
|
on:
|
|
4
4
|
workflow_run:
|
|
5
|
-
workflows: [
|
|
5
|
+
workflows: ["CI | Publish npm package"]
|
|
6
6
|
types:
|
|
7
7
|
- completed
|
|
8
8
|
|
|
@@ -34,6 +34,4 @@ jobs:
|
|
|
34
34
|
node bin run --dev pull
|
|
35
35
|
underpost run secret
|
|
36
36
|
underpost run underpost-config
|
|
37
|
-
underpost run ssh-deploy engine-
|
|
38
|
-
underpost run ssh-deploy engine-lampp
|
|
39
|
-
underpost run ssh-deploy engine-cyberia
|
|
37
|
+
underpost run ssh-deploy engine-test
|
package/README.md
CHANGED
|
@@ -32,6 +32,17 @@
|
|
|
32
32
|
|
|
33
33
|
|
|
34
34
|
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
35
46
|
|
|
36
47
|
|
|
37
48
|
|
|
@@ -45,7 +56,7 @@
|
|
|
45
56
|
<!-- badges -->
|
|
46
57
|
|
|
47
58
|
|
|
48
|
-
[](https://github.com/underpostnet/engine/actions/workflows/docker-image.yml) [](https://github.com/underpostnet/engine/actions/workflows/coverall.yml) [](https://www.npmjs.com/package/underpost) [](https://github.com/underpostnet/engine/actions/workflows/docker-image.yml) [](https://github.com/underpostnet/engine/actions/workflows/coverall.yml) [](https://www.npmjs.com/package/underpost) [](https://socket.dev/npm/package/underpost/overview/2.8.874) [](https://coveralls.io/github/underpostnet/engine?branch=master) [](https://www.npmjs.org/package/underpost) [](https://www.npmjs.com/package/underpost)
|
|
49
60
|
|
|
50
61
|
|
|
51
62
|
<!-- end-badges -->
|
|
@@ -66,6 +77,17 @@
|
|
|
66
77
|
|
|
67
78
|
|
|
68
79
|
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
|
|
69
91
|
|
|
70
92
|
|
|
71
93
|
|
|
@@ -120,7 +142,7 @@ Run dev client server
|
|
|
120
142
|
npm run dev
|
|
121
143
|
```
|
|
122
144
|
<!-- -->
|
|
123
|
-
## underpost ci/cd cli v2.8.
|
|
145
|
+
## underpost ci/cd cli v2.8.874
|
|
124
146
|
|
|
125
147
|
### Usage: `underpost [options] [command]`
|
|
126
148
|
```
|
package/bin/build.js
CHANGED
|
@@ -191,6 +191,10 @@ const { DefaultConf } = await import(`../conf.${confName}.js`);
|
|
|
191
191
|
fs.copyFileSync(`./.github/workflows/${repoName}.ci.yml`, `${basePath}/.github/workflows/${repoName}.ci.yml`);
|
|
192
192
|
fs.copyFileSync(`./.github/workflows/${repoName}.cd.yml`, `${basePath}/.github/workflows/${repoName}.cd.yml`);
|
|
193
193
|
|
|
194
|
+
fs.copyFileSync(`./conf.${confName}.js`, `${basePath}/conf.js`);
|
|
195
|
+
fs.copyFileSync(`./manifests/deployment/${confName}-development/proxy.yaml`, `${basePath}/proxy.yaml`);
|
|
196
|
+
fs.copyFileSync(`./manifests/deployment/${confName}-development/deployment.yaml`, `${basePath}/deployment.yaml`);
|
|
197
|
+
|
|
194
198
|
if (fs.existsSync(`./src/ws/${confName.split('-')[1]}`)) {
|
|
195
199
|
fs.copySync(`./src/ws/${confName.split('-')[1]}`, `${basePath}/src/ws/${confName.split('-')[1]}`);
|
|
196
200
|
}
|
package/bin/deploy.js
CHANGED
|
@@ -372,6 +372,7 @@ try {
|
|
|
372
372
|
shellExec(`node bin run kill 4002`);
|
|
373
373
|
shellExec(`node bin run kill 4003`);
|
|
374
374
|
shellExec(`npm run update-template`);
|
|
375
|
+
shellExec(`cd ../pwa-microservices-template && npm install`);
|
|
375
376
|
shellExec(`cd ../pwa-microservices-template && npm run build && timeout 5s npm run dev`, {
|
|
376
377
|
async: true,
|
|
377
378
|
});
|
|
@@ -448,6 +449,9 @@ try {
|
|
|
448
449
|
shellExec(
|
|
449
450
|
`node bin deploy --kubeadm --build-manifest --sync --info-router --replicas 1 --node ${node} dd production`,
|
|
450
451
|
);
|
|
452
|
+
shellExec(
|
|
453
|
+
`node bin deploy --kubeadm --build-manifest --sync --info-router --replicas 1 --node ${node} dd development `,
|
|
454
|
+
);
|
|
451
455
|
for (const deployId of fs.readFileSync(`./engine-private/deploy/dd.router`, 'utf8').split(`,`)) {
|
|
452
456
|
fs.copySync(
|
|
453
457
|
`./engine-private/conf/${deployId}/build/development/deployment.yaml`,
|
package/cli.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
## underpost ci/cd cli v2.8.
|
|
1
|
+
## underpost ci/cd cli v2.8.874
|
|
2
2
|
|
|
3
3
|
### Usage: `underpost [options] [command]`
|
|
4
4
|
```
|
|
@@ -291,6 +291,8 @@ Options:
|
|
|
291
291
|
management commands.
|
|
292
292
|
--cert Resets TLS/SSL certificate secrets for
|
|
293
293
|
deployments.
|
|
294
|
+
--cert-hosts <hosts> Resets TLS/SSL certificate secrets for
|
|
295
|
+
specified hosts.
|
|
294
296
|
--node <node> Sets optional node for deployment
|
|
295
297
|
operations.
|
|
296
298
|
--build-manifest Builds Kubernetes YAML manifests, including
|
|
@@ -298,6 +300,7 @@ Options:
|
|
|
298
300
|
secrets.
|
|
299
301
|
--replicas <replicas> Sets a custom number of replicas for
|
|
300
302
|
deployments.
|
|
303
|
+
--image <image> Sets a custom image for deployments.
|
|
301
304
|
--versions <deployment-versions> A comma-separated list of custom deployment
|
|
302
305
|
versions.
|
|
303
306
|
--traffic <traffic-versions> A comma-separated list of custom deployment
|
|
@@ -599,7 +602,7 @@ Options:
|
|
|
599
602
|
Runs a script from the specified path.
|
|
600
603
|
|
|
601
604
|
Arguments:
|
|
602
|
-
runner-id The runner ID to run. Options: spark-template, rmi, kill, secret, underpost-config, gpu-env, tf-gpu-test, dev-cluster, ssh-cluster-info, cyberia-ide, engine-ide, template-deploy, clean, pull, release-deploy, ssh-deploy, ide, dev-client, dev-api,
|
|
605
|
+
runner-id The runner ID to run. Options: spark-template, rmi, kill, secret, underpost-config, gpu-env, tf-gpu-test, dev-cluster, ssh-cluster-info, cyberia-ide, engine-ide, template-deploy, clean, pull, release-deploy, ssh-deploy, ide, dev-client, dev-api, sync, ls-deployments, monitor, db-client, promote, metrics, cluster, deploy, tf-vae-test, deploy-job.
|
|
603
606
|
path The absolute or relative directory path where the script is located.
|
|
604
607
|
|
|
605
608
|
Options:
|
|
@@ -17,7 +17,7 @@ spec:
|
|
|
17
17
|
spec:
|
|
18
18
|
containers:
|
|
19
19
|
- name: dd-default-development-blue
|
|
20
|
-
image: localhost/rockylinux9-underpost:v2.8.
|
|
20
|
+
image: localhost/rockylinux9-underpost:v2.8.874
|
|
21
21
|
# resources:
|
|
22
22
|
# requests:
|
|
23
23
|
# memory: "124Ki"
|
|
@@ -100,7 +100,7 @@ spec:
|
|
|
100
100
|
spec:
|
|
101
101
|
containers:
|
|
102
102
|
- name: dd-default-development-green
|
|
103
|
-
image: localhost/rockylinux9-underpost:v2.8.
|
|
103
|
+
image: localhost/rockylinux9-underpost:v2.8.874
|
|
104
104
|
# resources:
|
|
105
105
|
# requests:
|
|
106
106
|
# memory: "124Ki"
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
---
|
|
2
|
+
apiVersion: apps/v1
|
|
3
|
+
kind: Deployment
|
|
4
|
+
metadata:
|
|
5
|
+
name: dd-test-development-blue
|
|
6
|
+
labels:
|
|
7
|
+
app: dd-test-development-blue
|
|
8
|
+
spec:
|
|
9
|
+
replicas: 1
|
|
10
|
+
selector:
|
|
11
|
+
matchLabels:
|
|
12
|
+
app: dd-test-development-blue
|
|
13
|
+
template:
|
|
14
|
+
metadata:
|
|
15
|
+
labels:
|
|
16
|
+
app: dd-test-development-blue
|
|
17
|
+
spec:
|
|
18
|
+
containers:
|
|
19
|
+
- name: dd-test-development-blue
|
|
20
|
+
image: localhost/rockylinux9-underpost:v2.8.874
|
|
21
|
+
# resources:
|
|
22
|
+
# requests:
|
|
23
|
+
# memory: "96294Ki"
|
|
24
|
+
# cpu: "75m"
|
|
25
|
+
# limits:
|
|
26
|
+
# memory: "1540709Ki"
|
|
27
|
+
# cpu: "1200m"
|
|
28
|
+
command:
|
|
29
|
+
- /bin/sh
|
|
30
|
+
- -c
|
|
31
|
+
- >
|
|
32
|
+
npm install -g npm@11.2.0 &&
|
|
33
|
+
npm install -g underpost &&
|
|
34
|
+
underpost secret underpost --create-from-file /etc/config/.env.development &&
|
|
35
|
+
underpost start --build --run dd-test development
|
|
36
|
+
volumeMounts:
|
|
37
|
+
- name: config-volume
|
|
38
|
+
mountPath: /etc/config
|
|
39
|
+
volumes:
|
|
40
|
+
- name: config-volume
|
|
41
|
+
configMap:
|
|
42
|
+
name: underpost-config
|
|
43
|
+
---
|
|
44
|
+
apiVersion: v1
|
|
45
|
+
kind: Service
|
|
46
|
+
metadata:
|
|
47
|
+
name: dd-test-development-blue-service
|
|
48
|
+
spec:
|
|
49
|
+
selector:
|
|
50
|
+
app: dd-test-development-blue
|
|
51
|
+
ports:
|
|
52
|
+
- name: 'tcp-4021'
|
|
53
|
+
protocol: TCP
|
|
54
|
+
port: 4021
|
|
55
|
+
targetPort: 4021
|
|
56
|
+
- name: 'udp-4021'
|
|
57
|
+
protocol: UDP
|
|
58
|
+
port: 4021
|
|
59
|
+
targetPort: 4021
|
|
60
|
+
|
|
61
|
+
- name: 'tcp-4022'
|
|
62
|
+
protocol: TCP
|
|
63
|
+
port: 4022
|
|
64
|
+
targetPort: 4022
|
|
65
|
+
- name: 'udp-4022'
|
|
66
|
+
protocol: UDP
|
|
67
|
+
port: 4022
|
|
68
|
+
targetPort: 4022
|
|
69
|
+
|
|
70
|
+
- name: 'tcp-4023'
|
|
71
|
+
protocol: TCP
|
|
72
|
+
port: 4023
|
|
73
|
+
targetPort: 4023
|
|
74
|
+
- name: 'udp-4023'
|
|
75
|
+
protocol: UDP
|
|
76
|
+
port: 4023
|
|
77
|
+
targetPort: 4023
|
|
78
|
+
|
|
79
|
+
- name: 'tcp-4024'
|
|
80
|
+
protocol: TCP
|
|
81
|
+
port: 4024
|
|
82
|
+
targetPort: 4024
|
|
83
|
+
- name: 'udp-4024'
|
|
84
|
+
protocol: UDP
|
|
85
|
+
port: 4024
|
|
86
|
+
targetPort: 4024
|
|
87
|
+
type: LoadBalancer
|
|
88
|
+
---
|
|
89
|
+
apiVersion: apps/v1
|
|
90
|
+
kind: Deployment
|
|
91
|
+
metadata:
|
|
92
|
+
name: dd-test-development-green
|
|
93
|
+
labels:
|
|
94
|
+
app: dd-test-development-green
|
|
95
|
+
spec:
|
|
96
|
+
replicas: 1
|
|
97
|
+
selector:
|
|
98
|
+
matchLabels:
|
|
99
|
+
app: dd-test-development-green
|
|
100
|
+
template:
|
|
101
|
+
metadata:
|
|
102
|
+
labels:
|
|
103
|
+
app: dd-test-development-green
|
|
104
|
+
spec:
|
|
105
|
+
containers:
|
|
106
|
+
- name: dd-test-development-green
|
|
107
|
+
image: localhost/rockylinux9-underpost:v2.8.874
|
|
108
|
+
# resources:
|
|
109
|
+
# requests:
|
|
110
|
+
# memory: "96294Ki"
|
|
111
|
+
# cpu: "75m"
|
|
112
|
+
# limits:
|
|
113
|
+
# memory: "1540709Ki"
|
|
114
|
+
# cpu: "1200m"
|
|
115
|
+
command:
|
|
116
|
+
- /bin/sh
|
|
117
|
+
- -c
|
|
118
|
+
- >
|
|
119
|
+
npm install -g npm@11.2.0 &&
|
|
120
|
+
npm install -g underpost &&
|
|
121
|
+
underpost secret underpost --create-from-file /etc/config/.env.development &&
|
|
122
|
+
underpost start --build --run dd-test development
|
|
123
|
+
volumeMounts:
|
|
124
|
+
- name: config-volume
|
|
125
|
+
mountPath: /etc/config
|
|
126
|
+
volumes:
|
|
127
|
+
- name: config-volume
|
|
128
|
+
configMap:
|
|
129
|
+
name: underpost-config
|
|
130
|
+
---
|
|
131
|
+
apiVersion: v1
|
|
132
|
+
kind: Service
|
|
133
|
+
metadata:
|
|
134
|
+
name: dd-test-development-green-service
|
|
135
|
+
spec:
|
|
136
|
+
selector:
|
|
137
|
+
app: dd-test-development-green
|
|
138
|
+
ports:
|
|
139
|
+
- name: 'tcp-4021'
|
|
140
|
+
protocol: TCP
|
|
141
|
+
port: 4021
|
|
142
|
+
targetPort: 4021
|
|
143
|
+
- name: 'udp-4021'
|
|
144
|
+
protocol: UDP
|
|
145
|
+
port: 4021
|
|
146
|
+
targetPort: 4021
|
|
147
|
+
|
|
148
|
+
- name: 'tcp-4022'
|
|
149
|
+
protocol: TCP
|
|
150
|
+
port: 4022
|
|
151
|
+
targetPort: 4022
|
|
152
|
+
- name: 'udp-4022'
|
|
153
|
+
protocol: UDP
|
|
154
|
+
port: 4022
|
|
155
|
+
targetPort: 4022
|
|
156
|
+
|
|
157
|
+
- name: 'tcp-4023'
|
|
158
|
+
protocol: TCP
|
|
159
|
+
port: 4023
|
|
160
|
+
targetPort: 4023
|
|
161
|
+
- name: 'udp-4023'
|
|
162
|
+
protocol: UDP
|
|
163
|
+
port: 4023
|
|
164
|
+
targetPort: 4023
|
|
165
|
+
|
|
166
|
+
- name: 'tcp-4024'
|
|
167
|
+
protocol: TCP
|
|
168
|
+
port: 4024
|
|
169
|
+
targetPort: 4024
|
|
170
|
+
- name: 'udp-4024'
|
|
171
|
+
protocol: UDP
|
|
172
|
+
port: 4024
|
|
173
|
+
targetPort: 4024
|
|
174
|
+
type: LoadBalancer
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
|
|
2
|
+
---
|
|
3
|
+
apiVersion: projectcontour.io/v1
|
|
4
|
+
kind: HTTPProxy
|
|
5
|
+
metadata:
|
|
6
|
+
name: test.nexodev.org
|
|
7
|
+
spec:
|
|
8
|
+
virtualhost:
|
|
9
|
+
fqdn: test.nexodev.org
|
|
10
|
+
routes:
|
|
11
|
+
- conditions:
|
|
12
|
+
- prefix: /
|
|
13
|
+
enableWebsockets: true
|
|
14
|
+
services:
|
|
15
|
+
- name: dd-test-development-blue-service
|
|
16
|
+
port: 4021
|
|
17
|
+
weight: 100
|
|
18
|
+
|
|
19
|
+
- conditions:
|
|
20
|
+
- prefix: /peer
|
|
21
|
+
enableWebsockets: true
|
|
22
|
+
services:
|
|
23
|
+
- name: dd-test-development-blue-service
|
|
24
|
+
port: 4022
|
|
25
|
+
weight: 100
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
apiVersion: projectcontour.io/v1
|
|
29
|
+
kind: HTTPProxy
|
|
30
|
+
metadata:
|
|
31
|
+
name: stagging.nexodev.org
|
|
32
|
+
spec:
|
|
33
|
+
virtualhost:
|
|
34
|
+
fqdn: stagging.nexodev.org
|
|
35
|
+
routes:
|
|
36
|
+
- conditions:
|
|
37
|
+
- prefix: /
|
|
38
|
+
enableWebsockets: true
|
|
39
|
+
services:
|
|
40
|
+
- name: dd-test-development-blue-service
|
|
41
|
+
port: 4023
|
|
42
|
+
weight: 100
|
|
43
|
+
|
|
44
|
+
- conditions:
|
|
45
|
+
- prefix: /peer
|
|
46
|
+
enableWebsockets: true
|
|
47
|
+
services:
|
|
48
|
+
- name: dd-test-development-blue-service
|
|
49
|
+
port: 4024
|
|
50
|
+
weight: 100
|
|
51
|
+
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"type": "module",
|
|
3
3
|
"main": "src/index.js",
|
|
4
4
|
"name": "underpost",
|
|
5
|
-
"version": "2.8.
|
|
5
|
+
"version": "2.8.874",
|
|
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",
|
|
@@ -63,6 +63,7 @@
|
|
|
63
63
|
"colors": "^1.4.0",
|
|
64
64
|
"commander": "^12.1.0",
|
|
65
65
|
"compression": "^1.7.4",
|
|
66
|
+
"cookie-parser": "^1.4.7",
|
|
66
67
|
"cors": "^2.8.5",
|
|
67
68
|
"d3": "^7.9.0",
|
|
68
69
|
"dotenv": "^16.3.1",
|
|
@@ -70,9 +71,12 @@
|
|
|
70
71
|
"env-cmd": "^10.1.0",
|
|
71
72
|
"express": "^4.18.2",
|
|
72
73
|
"express-fileupload": "^1.4.3",
|
|
74
|
+
"express-rate-limit": "^8.1.0",
|
|
75
|
+
"express-slow-down": "^3.0.0",
|
|
73
76
|
"favicons": "^7.2.0",
|
|
74
77
|
"fs-extra": "^11.1.1",
|
|
75
78
|
"fullcalendar": "^6.1.15",
|
|
79
|
+
"helmet": "^8.1.0",
|
|
76
80
|
"html-minifier-terser": "^7.2.0",
|
|
77
81
|
"http-proxy-middleware": "^2.0.6",
|
|
78
82
|
"ignore-walk": "^6.0.4",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { adminGuard
|
|
1
|
+
import { adminGuard } 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,6 +7,7 @@ const logger = loggerFactory(import.meta);
|
|
|
7
7
|
|
|
8
8
|
const CoreRouter = (options) => {
|
|
9
9
|
const router = express.Router();
|
|
10
|
+
const authMiddleware = options.authMiddleware;
|
|
10
11
|
router.post(`/:id`, authMiddleware, adminGuard, async (req, res) => await CoreController.post(req, res, options));
|
|
11
12
|
router.post(`/`, authMiddleware, adminGuard, async (req, res) => await CoreController.post(req, res, options));
|
|
12
13
|
router.get(`/:id`, authMiddleware, adminGuard, async (req, res) => await CoreController.get(req, res, options));
|
|
@@ -21,7 +21,12 @@ const DefaultController = {
|
|
|
21
21
|
},
|
|
22
22
|
get: async (req, res, options) => {
|
|
23
23
|
try {
|
|
24
|
-
const
|
|
24
|
+
const { page, limit } = req.query;
|
|
25
|
+
const result = await DefaultService.get(
|
|
26
|
+
{ ...req, query: { ...req.query, page: parseInt(page), limit: parseInt(limit) } },
|
|
27
|
+
res,
|
|
28
|
+
options,
|
|
29
|
+
);
|
|
25
30
|
return res.status(200).json({
|
|
26
31
|
status: 'success',
|
|
27
32
|
data: result,
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { authMiddleware } from '../../server/auth.js';
|
|
2
1
|
import { loggerFactory } from '../../server/logger.js';
|
|
3
2
|
import { DefaultController } from './default.controller.js';
|
|
4
3
|
import express from 'express';
|
|
@@ -7,9 +6,14 @@ const logger = loggerFactory(import.meta);
|
|
|
7
6
|
|
|
8
7
|
const DefaultRouter = (options) => {
|
|
9
8
|
const router = express.Router();
|
|
9
|
+
const authMiddleware = options.authMiddleware;
|
|
10
10
|
router.post(`/:id`, async (req, res) => await DefaultController.post(req, res, options));
|
|
11
11
|
router.post(`/`, async (req, res) => await DefaultController.post(req, res, options));
|
|
12
|
-
router.get(
|
|
12
|
+
router.get(
|
|
13
|
+
`/:id`,
|
|
14
|
+
// authMiddleware,
|
|
15
|
+
async (req, res) => await DefaultController.get(req, res, options),
|
|
16
|
+
);
|
|
13
17
|
router.get(`/`, async (req, res) => await DefaultController.get(req, res, options));
|
|
14
18
|
router.put(`/:id`, async (req, res) => await DefaultController.put(req, res, options));
|
|
15
19
|
router.put(`/`, async (req, res) => await DefaultController.put(req, res, options));
|
|
@@ -13,7 +13,16 @@ const DefaultService = {
|
|
|
13
13
|
/** @type {import('./default.model.js').DefaultModel} */
|
|
14
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
|
+
const { query, page = 1, limit = 10, sort = { updatedAt: -1 } } = req.query;
|
|
17
|
+
const queryPayload = query ? JSON.parse(query) : {};
|
|
18
|
+
const skip = (page - 1) * limit;
|
|
19
|
+
const [data, total] = await Promise.all([
|
|
20
|
+
Default.find(queryPayload).sort(sort).limit(limit).skip(skip),
|
|
21
|
+
Default.countDocuments(queryPayload),
|
|
22
|
+
]);
|
|
23
|
+
|
|
24
|
+
const totalPages = Math.ceil(total / limit);
|
|
25
|
+
return { data, total, page, totalPages };
|
|
17
26
|
},
|
|
18
27
|
put: async (req, res, options) => {
|
|
19
28
|
/** @type {import('./default.model.js').DefaultModel} */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { adminGuard
|
|
1
|
+
import { adminGuard } from '../../server/auth.js';
|
|
2
2
|
import { loggerFactory } from '../../server/logger.js';
|
|
3
3
|
import { FileController } from './file.controller.js';
|
|
4
4
|
import express from 'express';
|
|
@@ -6,6 +6,7 @@ const logger = loggerFactory(import.meta);
|
|
|
6
6
|
|
|
7
7
|
const FileRouter = (options) => {
|
|
8
8
|
const router = express.Router();
|
|
9
|
+
const authMiddleware = options.authMiddleware;
|
|
9
10
|
router.post(`/:id`, authMiddleware, async (req, res) => await FileController.post(req, res, options));
|
|
10
11
|
router.post(`/`, authMiddleware, async (req, res) => await FileController.post(req, res, options));
|
|
11
12
|
router.get(`/blob/:id`, async (req, res) => await FileController.get(req, res, options));
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { authMiddleware } from '../../server/auth.js';
|
|
2
1
|
import { loggerFactory } from '../../server/logger.js';
|
|
3
2
|
import { TestController } from './test.controller.js';
|
|
4
3
|
import express from 'express';
|
|
@@ -7,6 +6,7 @@ const logger = loggerFactory(import.meta);
|
|
|
7
6
|
|
|
8
7
|
const TestRouter = (options) => {
|
|
9
8
|
const router = express.Router();
|
|
9
|
+
const authMiddleware = options.authMiddleware;
|
|
10
10
|
router.post(`/:id`, async (req, res) => await TestController.post(req, res, options));
|
|
11
11
|
router.post(`/`, authMiddleware, async (req, res) => await TestController.post(req, res, options));
|
|
12
12
|
router.get(`/:id`, async (req, res) => await TestController.get(req, res, options));
|