underpost 2.8.876 → 2.8.877
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/README.md +6 -2
- package/cli.md +3 -1
- package/manifests/deployment/dd-default-development/deployment.yaml +2 -2
- package/manifests/deployment/dd-test-development/deployment.yaml +6 -6
- package/package.json +1 -1
- package/src/cli/deploy.js +2 -1
- package/src/cli/index.js +2 -0
- package/src/cli/repository.js +10 -2
- package/src/cli/run.js +24 -9
- package/src/client/components/core/Auth.js +0 -1
- package/src/client/services/core/core.service.js +4 -20
- package/src/client/services/default/default.service.js +4 -0
- package/src/client/services/test/test.service.js +3 -0
- package/src/client/services/user/user.service.js +3 -0
- package/src/index.js +1 -1
- package/src/server/auth.js +1 -1
- package/src/server/runtime.js +77 -71
package/README.md
CHANGED
|
@@ -53,13 +53,15 @@
|
|
|
53
53
|
|
|
54
54
|
|
|
55
55
|
|
|
56
|
+
|
|
57
|
+
|
|
56
58
|
|
|
57
59
|
|
|
58
60
|
|
|
59
61
|
<!-- badges -->
|
|
60
62
|
|
|
61
63
|
|
|
62
|
-
[](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.877) [](https://coveralls.io/github/underpostnet/engine?branch=master) [](https://www.npmjs.org/package/underpost) [](https://www.npmjs.com/package/underpost)
|
|
63
65
|
|
|
64
66
|
|
|
65
67
|
<!-- end-badges -->
|
|
@@ -101,6 +103,8 @@
|
|
|
101
103
|
|
|
102
104
|
|
|
103
105
|
|
|
106
|
+
|
|
107
|
+
|
|
104
108
|
|
|
105
109
|
|
|
106
110
|
|
|
@@ -148,7 +152,7 @@ Run dev client server
|
|
|
148
152
|
npm run dev
|
|
149
153
|
```
|
|
150
154
|
<!-- -->
|
|
151
|
-
## underpost ci/cd cli v2.8.
|
|
155
|
+
## underpost ci/cd cli v2.8.877
|
|
152
156
|
|
|
153
157
|
### Usage: `underpost [options] [command]`
|
|
154
158
|
```
|
package/cli.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
## underpost ci/cd cli v2.8.
|
|
1
|
+
## underpost ci/cd cli v2.8.877
|
|
2
2
|
|
|
3
3
|
### Usage: `underpost [options] [command]`
|
|
4
4
|
```
|
|
@@ -609,6 +609,8 @@ Options:
|
|
|
609
609
|
--command <command-array> Array of commands to run.
|
|
610
610
|
--args <args-array> Array of arguments to pass to the command.
|
|
611
611
|
--dev Sets the development context environment for the script.
|
|
612
|
+
--build Set builder context runner
|
|
613
|
+
--replicas <replicas> Sets a custom number of replicas for deployment.
|
|
612
614
|
--pod-name <pod-name> Optional: Specifies the pod name for test execution.
|
|
613
615
|
--volume-host-path <volume-host-path> Optional: Specifies the volume host path for test execution.
|
|
614
616
|
--volume-mount-path <volume-mount-path> Optional: Specifies the volume mount path for test execution.
|
|
@@ -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.877
|
|
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.877
|
|
104
104
|
# resources:
|
|
105
105
|
# requests:
|
|
106
106
|
# memory: "124Ki"
|
|
@@ -17,13 +17,13 @@ spec:
|
|
|
17
17
|
spec:
|
|
18
18
|
containers:
|
|
19
19
|
- name: dd-test-development-blue
|
|
20
|
-
image: localhost/rockylinux9-underpost:v2.8.
|
|
20
|
+
image: localhost/rockylinux9-underpost:v2.8.877
|
|
21
21
|
# resources:
|
|
22
22
|
# requests:
|
|
23
|
-
# memory: "
|
|
23
|
+
# memory: "94Ki"
|
|
24
24
|
# cpu: "75m"
|
|
25
25
|
# limits:
|
|
26
|
-
# memory: "
|
|
26
|
+
# memory: "1504Ki"
|
|
27
27
|
# cpu: "1200m"
|
|
28
28
|
command:
|
|
29
29
|
- /bin/sh
|
|
@@ -104,13 +104,13 @@ spec:
|
|
|
104
104
|
spec:
|
|
105
105
|
containers:
|
|
106
106
|
- name: dd-test-development-green
|
|
107
|
-
image: localhost/rockylinux9-underpost:v2.8.
|
|
107
|
+
image: localhost/rockylinux9-underpost:v2.8.877
|
|
108
108
|
# resources:
|
|
109
109
|
# requests:
|
|
110
|
-
# memory: "
|
|
110
|
+
# memory: "94Ki"
|
|
111
111
|
# cpu: "75m"
|
|
112
112
|
# limits:
|
|
113
|
-
# memory: "
|
|
113
|
+
# memory: "1504Ki"
|
|
114
114
|
# cpu: "1200m"
|
|
115
115
|
command:
|
|
116
116
|
- /bin/sh
|
package/package.json
CHANGED
package/src/cli/deploy.js
CHANGED
|
@@ -384,7 +384,8 @@ EOF`);
|
|
|
384
384
|
if (!options.remove === true) {
|
|
385
385
|
if (!options.disableUpdateDeployment) shellExec(`sudo kubectl apply -f ./${manifestsPath}/deployment.yaml`);
|
|
386
386
|
shellExec(`sudo kubectl apply -f ./${manifestsPath}/proxy.yaml`);
|
|
387
|
-
|
|
387
|
+
|
|
388
|
+
if (UnderpostDeploy.API.isValidTLSContext({ host: Object.keys(confServer)[0], env, options }))
|
|
388
389
|
shellExec(`sudo kubectl apply -f ./${manifestsPath}/secret.yaml`);
|
|
389
390
|
}
|
|
390
391
|
}
|
package/src/cli/index.js
CHANGED
|
@@ -350,6 +350,8 @@ program
|
|
|
350
350
|
.option('--command <command-array>', 'Array of commands to run.')
|
|
351
351
|
.option('--args <args-array>', 'Array of arguments to pass to the command.')
|
|
352
352
|
.option('--dev', 'Sets the development context environment for the script.')
|
|
353
|
+
.option('--build', 'Set builder context runner')
|
|
354
|
+
.option('--replicas <replicas>', 'Sets a custom number of replicas for deployment.')
|
|
353
355
|
.option('--pod-name <pod-name>', 'Optional: Specifies the pod name for test execution.')
|
|
354
356
|
.option('--volume-host-path <volume-host-path>', 'Optional: Specifies the volume host path for test execution.')
|
|
355
357
|
.option('--volume-mount-path <volume-mount-path>', 'Optional: Specifies the volume mount path for test execution.')
|
package/src/cli/repository.js
CHANGED
|
@@ -160,10 +160,18 @@ class UnderpostRepository {
|
|
|
160
160
|
`Version mismatch: deploy-version:${packageJsonDeploy.version} !== engine-version:${packageJsonEngine.version},
|
|
161
161
|
Prevent build private config repo.`,
|
|
162
162
|
);
|
|
163
|
-
return {
|
|
163
|
+
return {
|
|
164
|
+
validVersion: false,
|
|
165
|
+
engineVersion: packageJsonEngine.version,
|
|
166
|
+
deployVersion: packageJsonDeploy.version,
|
|
167
|
+
};
|
|
164
168
|
}
|
|
165
169
|
shellExec(`node bin/build ${deployId} conf`);
|
|
166
|
-
return {
|
|
170
|
+
return {
|
|
171
|
+
validVersion: true,
|
|
172
|
+
engineVersion: packageJsonEngine.version,
|
|
173
|
+
deployVersion: packageJsonDeploy.version,
|
|
174
|
+
};
|
|
167
175
|
},
|
|
168
176
|
};
|
|
169
177
|
}
|
package/src/cli/run.js
CHANGED
|
@@ -8,6 +8,7 @@ import { range, setPad, timer } from '../client/components/core/CommonJs.js';
|
|
|
8
8
|
import UnderpostDeploy from './deploy.js';
|
|
9
9
|
import UnderpostRootEnv from './env.js';
|
|
10
10
|
import UnderpostRepository from './repository.js';
|
|
11
|
+
import os from 'os';
|
|
11
12
|
|
|
12
13
|
const logger = loggerFactory(import.meta);
|
|
13
14
|
|
|
@@ -20,6 +21,8 @@ class UnderpostRun {
|
|
|
20
21
|
imageName: '',
|
|
21
22
|
containerName: '',
|
|
22
23
|
namespace: '',
|
|
24
|
+
build: false,
|
|
25
|
+
replicas: 1,
|
|
23
26
|
};
|
|
24
27
|
static RUNNERS = {
|
|
25
28
|
'spark-template': (path, options = UnderpostRun.DEFAULT_OPTION) => {
|
|
@@ -154,17 +157,21 @@ class UnderpostRun {
|
|
|
154
157
|
const env = options.dev ? 'development' : 'production';
|
|
155
158
|
const baseCommand = options.dev || true ? 'node bin' : 'underpost';
|
|
156
159
|
shellExec(`${baseCommand} run clean`);
|
|
157
|
-
const
|
|
158
|
-
let [deployId, replicas, image, node] = path ? path.split(',') :
|
|
159
|
-
deployId = deployId ??
|
|
160
|
-
replicas = replicas ??
|
|
161
|
-
|
|
162
|
-
|
|
160
|
+
const defaultPath = ['dd-default', 1, ``, ``, 'kind-control-plane'];
|
|
161
|
+
let [deployId, replicas, versions, image, node] = path ? path.split(',') : defaultPath;
|
|
162
|
+
deployId = deployId ?? defaultPath[0];
|
|
163
|
+
replicas = replicas ?? defaultPath[1];
|
|
164
|
+
versions = versions ?? defaultPath[2];
|
|
165
|
+
image = image ?? defaultPath[3];
|
|
166
|
+
node = node ?? defaultPath[4];
|
|
163
167
|
shellExec(
|
|
164
168
|
`${baseCommand} deploy --kubeadm --build-manifest --sync --info-router --replicas ${
|
|
165
169
|
replicas ?? 1
|
|
166
|
-
} --node ${node}${image ? ` --image ${image}` : ''}
|
|
170
|
+
} --node ${node}${image ? ` --image ${image}` : ''}${
|
|
171
|
+
versions ? ` --versions ${versions.replaceAll('+', ',')}` : ''
|
|
172
|
+
} dd ${env}`,
|
|
167
173
|
);
|
|
174
|
+
if (!options.build) shellExec(`${baseCommand} deploy --kubeadm ${deployId} ${env}`);
|
|
168
175
|
},
|
|
169
176
|
'ls-deployments': async (path, options = UnderpostRun.DEFAULT_OPTION) => {
|
|
170
177
|
console.table(await UnderpostDeploy.API.get(path, 'deployments'));
|
|
@@ -303,13 +310,21 @@ class UnderpostRun {
|
|
|
303
310
|
},
|
|
304
311
|
deploy: async (path, options = UnderpostRun.DEFAULT_OPTION) => {
|
|
305
312
|
const deployId = path;
|
|
306
|
-
const { validVersion } = UnderpostRepository.API.privateConfUpdate(deployId);
|
|
313
|
+
const { validVersion, deployVersion } = UnderpostRepository.API.privateConfUpdate(deployId);
|
|
307
314
|
if (!validVersion) throw new Error('Version mismatch');
|
|
308
315
|
const currentTraffic = UnderpostDeploy.API.getCurrentTraffic(deployId);
|
|
309
316
|
const targetTraffic = currentTraffic === 'blue' ? 'green' : 'blue';
|
|
310
317
|
const env = 'production';
|
|
311
318
|
const ignorePods = UnderpostDeploy.API.get(`${deployId}-${env}-${targetTraffic}`).map((p) => p.NAME);
|
|
312
|
-
|
|
319
|
+
|
|
320
|
+
if (options.build === true) {
|
|
321
|
+
// deployId, replicas, versions, image, node
|
|
322
|
+
shellExec(
|
|
323
|
+
`node bin run sync ${deployId},${options.replicas ?? 1},${targetTraffic},${
|
|
324
|
+
options.imageName ?? `localhost/rockylinux9-underpost:${deployVersion}`
|
|
325
|
+
},${os.hostname()}`,
|
|
326
|
+
);
|
|
327
|
+
} else shellExec(`sudo kubectl rollout restart deployment/${deployId}-${env}-${targetTraffic}`);
|
|
313
328
|
|
|
314
329
|
let checkStatusIteration = 0;
|
|
315
330
|
const checkStatusIterationMsDelay = 1000;
|
|
@@ -4,7 +4,6 @@ import { loggerFactory } from './Logger.js';
|
|
|
4
4
|
import { LogIn } from './LogIn.js';
|
|
5
5
|
import { LogOut } from './LogOut.js';
|
|
6
6
|
import { NotificationManager } from './NotificationManager.js';
|
|
7
|
-
import { SignUp } from './SignUp.js';
|
|
8
7
|
import { Translate } from './Translate.js';
|
|
9
8
|
import { s } from './VanillaJs.js';
|
|
10
9
|
|
|
@@ -35,8 +35,6 @@ const getWsBaseUrl = (options = { id: '', endpoint: '', wsBasePath: '' }) =>
|
|
|
35
35
|
const headersFactory = (headerId = '') => {
|
|
36
36
|
const headers = {
|
|
37
37
|
Authorization: Auth.getJWT(),
|
|
38
|
-
withCredentials: true,
|
|
39
|
-
credentials: 'include', // no cors: 'same-origin'
|
|
40
38
|
};
|
|
41
39
|
switch (headerId) {
|
|
42
40
|
case 'file':
|
|
@@ -71,29 +69,12 @@ const CoreService = {
|
|
|
71
69
|
return reject(error);
|
|
72
70
|
}),
|
|
73
71
|
),
|
|
74
|
-
getRandomImage: (options = { category: ['city'], mimetype: 'image/jpg' }) => {
|
|
75
|
-
const src = `https://api.api-ninjas.com/v1/randomimage?category=${options.category[0]}`;
|
|
76
|
-
return new Promise((resolve) => {
|
|
77
|
-
fetch(src, {
|
|
78
|
-
headers: { 'X-Api-Key': 'FyITmcxRXkCaUehbX6K0/g==uxZcFKL0dZUUg48G', Accept: options.mimetype },
|
|
79
|
-
})
|
|
80
|
-
.then((res) => res.blob())
|
|
81
|
-
.then(async (blob) => {
|
|
82
|
-
return resolve({
|
|
83
|
-
file: {
|
|
84
|
-
mimetype: 'image/jpg',
|
|
85
|
-
name: 'image.jpg',
|
|
86
|
-
},
|
|
87
|
-
url: URL.createObjectURL(blob),
|
|
88
|
-
});
|
|
89
|
-
});
|
|
90
|
-
});
|
|
91
|
-
},
|
|
92
72
|
post: (options = { id: '', body: {} }) =>
|
|
93
73
|
new Promise((resolve, reject) =>
|
|
94
74
|
fetch(getApiBaseUrl({ id: options.id, endpoint }), {
|
|
95
75
|
method: 'POST',
|
|
96
76
|
headers: headersFactory(),
|
|
77
|
+
credentials: 'include',
|
|
97
78
|
body: payloadFactory(options.body),
|
|
98
79
|
})
|
|
99
80
|
.then(async (res) => {
|
|
@@ -113,6 +94,7 @@ const CoreService = {
|
|
|
113
94
|
fetch(getApiBaseUrl({ id: options.id, endpoint }), {
|
|
114
95
|
method: 'PUT',
|
|
115
96
|
headers: headersFactory(),
|
|
97
|
+
credentials: 'include',
|
|
116
98
|
body: payloadFactory(options.body),
|
|
117
99
|
})
|
|
118
100
|
.then(async (res) => {
|
|
@@ -132,6 +114,7 @@ const CoreService = {
|
|
|
132
114
|
fetch(getApiBaseUrl({ id: options.id, endpoint }), {
|
|
133
115
|
method: 'GET',
|
|
134
116
|
headers: headersFactory(),
|
|
117
|
+
credentials: 'include',
|
|
135
118
|
})
|
|
136
119
|
.then(async (res) => {
|
|
137
120
|
return await res.json();
|
|
@@ -150,6 +133,7 @@ const CoreService = {
|
|
|
150
133
|
fetch(getApiBaseUrl({ id: options.id, endpoint }), {
|
|
151
134
|
method: 'DELETE',
|
|
152
135
|
headers: headersFactory(),
|
|
136
|
+
credentials: 'include',
|
|
153
137
|
body: payloadFactory(options.body),
|
|
154
138
|
})
|
|
155
139
|
.then(async (res) => {
|
|
@@ -14,6 +14,7 @@ const DefaultService = {
|
|
|
14
14
|
fetch(getApiBaseUrl({ id: options.id, endpoint }), {
|
|
15
15
|
method: 'POST',
|
|
16
16
|
headers: headersFactory(),
|
|
17
|
+
credentials: 'include',
|
|
17
18
|
body: payloadFactory(options.body),
|
|
18
19
|
})
|
|
19
20
|
.then(async (res) => {
|
|
@@ -33,6 +34,7 @@ const DefaultService = {
|
|
|
33
34
|
fetch(getApiBaseUrl({ id: options.id, endpoint }), {
|
|
34
35
|
method: 'PUT',
|
|
35
36
|
headers: headersFactory(),
|
|
37
|
+
credentials: 'include',
|
|
36
38
|
body: payloadFactory(options.body),
|
|
37
39
|
})
|
|
38
40
|
.then(async (res) => {
|
|
@@ -56,6 +58,7 @@ const DefaultService = {
|
|
|
56
58
|
fetch(url.toString(), {
|
|
57
59
|
method: 'GET',
|
|
58
60
|
headers: headersFactory(),
|
|
61
|
+
credentials: 'include',
|
|
59
62
|
})
|
|
60
63
|
.then(async (res) => {
|
|
61
64
|
return await res.json();
|
|
@@ -75,6 +78,7 @@ const DefaultService = {
|
|
|
75
78
|
fetch(getApiBaseUrl({ id: options.id, endpoint }), {
|
|
76
79
|
method: 'DELETE',
|
|
77
80
|
headers: headersFactory(),
|
|
81
|
+
credentials: 'include',
|
|
78
82
|
body: payloadFactory(options.body),
|
|
79
83
|
})
|
|
80
84
|
.then(async (res) => {
|
|
@@ -14,6 +14,7 @@ const TestService = {
|
|
|
14
14
|
fetch(getApiBaseUrl({ id: options.id, endpoint }), {
|
|
15
15
|
method: 'POST',
|
|
16
16
|
headers: headersFactory(),
|
|
17
|
+
credentials: 'include',
|
|
17
18
|
body: payloadFactory(options.body),
|
|
18
19
|
})
|
|
19
20
|
.then(async (res) => {
|
|
@@ -33,6 +34,7 @@ const TestService = {
|
|
|
33
34
|
fetch(getApiBaseUrl({ id: options.id, endpoint }), {
|
|
34
35
|
method: 'GET',
|
|
35
36
|
headers: headersFactory(),
|
|
37
|
+
credentials: 'include',
|
|
36
38
|
})
|
|
37
39
|
.then(async (res) => {
|
|
38
40
|
return await res.json();
|
|
@@ -51,6 +53,7 @@ const TestService = {
|
|
|
51
53
|
fetch(getApiBaseUrl({ id: options.id, endpoint }), {
|
|
52
54
|
method: 'DELETE',
|
|
53
55
|
headers: headersFactory(),
|
|
56
|
+
credentials: 'include',
|
|
54
57
|
body: payloadFactory(options.body),
|
|
55
58
|
})
|
|
56
59
|
.then(async (res) => {
|
|
@@ -22,6 +22,7 @@ const UserService = {
|
|
|
22
22
|
fetch(getApiBaseUrl({ id: options.id, endpoint }), {
|
|
23
23
|
method: 'POST',
|
|
24
24
|
headers: headersFactory(),
|
|
25
|
+
credentials: 'include',
|
|
25
26
|
body: payloadFactory(options.body),
|
|
26
27
|
})
|
|
27
28
|
.then(async (res) => {
|
|
@@ -47,6 +48,7 @@ const UserService = {
|
|
|
47
48
|
fetch(url, {
|
|
48
49
|
method: 'GET',
|
|
49
50
|
headers: headersFactory(),
|
|
51
|
+
credentials: 'include',
|
|
50
52
|
})
|
|
51
53
|
.then(async (res) => {
|
|
52
54
|
return await res.json();
|
|
@@ -66,6 +68,7 @@ const UserService = {
|
|
|
66
68
|
fetch(getApiBaseUrl({ id: options.id, endpoint }), {
|
|
67
69
|
method: 'DELETE',
|
|
68
70
|
headers: headersFactory(),
|
|
71
|
+
credentials: 'include',
|
|
69
72
|
body: payloadFactory(options.body),
|
|
70
73
|
})
|
|
71
74
|
.then(async (res) => {
|
package/src/index.js
CHANGED
package/src/server/auth.js
CHANGED
|
@@ -552,7 +552,7 @@ function applySecurity(app, opts = {}) {
|
|
|
552
552
|
origin: origin || false,
|
|
553
553
|
methods: ['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'OPTIONS'],
|
|
554
554
|
credentials: true,
|
|
555
|
-
allowedHeaders: ['Content-Type', 'Authorization', 'X-Requested-With', 'Accept', 'withcredentials'],
|
|
555
|
+
allowedHeaders: ['Content-Type', 'Authorization', 'X-Requested-With', 'Accept', 'withcredentials', 'credentials'],
|
|
556
556
|
maxAge: 600,
|
|
557
557
|
}),
|
|
558
558
|
);
|
package/src/server/runtime.js
CHANGED
|
@@ -63,6 +63,7 @@ const buildRuntime = async () => {
|
|
|
63
63
|
singleReplica,
|
|
64
64
|
replicas,
|
|
65
65
|
valkey,
|
|
66
|
+
apiBaseHost,
|
|
66
67
|
} = confServer[host][path];
|
|
67
68
|
|
|
68
69
|
const { redirectTarget, singleReplicaHost } = await getInstanceContext({
|
|
@@ -188,97 +189,102 @@ const buildRuntime = async () => {
|
|
|
188
189
|
await UnderpostStartUp.API.listenPortController(app, port, runningData);
|
|
189
190
|
break;
|
|
190
191
|
}
|
|
192
|
+
// instance server
|
|
193
|
+
const server = createServer({}, app);
|
|
194
|
+
if (peer) currentPort++;
|
|
191
195
|
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
196
|
+
if (!apiBaseHost) {
|
|
197
|
+
const swaggerJsonPath = `./public/${host}${path === '/' ? path : `${path}/`}swagger-output.json`;
|
|
198
|
+
if (fs.existsSync(swaggerJsonPath)) {
|
|
199
|
+
// logger.info('Build swagger serve', swaggerJsonPath);
|
|
195
200
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
201
|
+
const swaggerInstance =
|
|
202
|
+
(swaggerDoc) =>
|
|
203
|
+
(...args) =>
|
|
204
|
+
swaggerUi.setup(swaggerDoc)(...args);
|
|
200
205
|
|
|
201
|
-
|
|
206
|
+
const swaggerDoc = JSON.parse(fs.readFileSync(swaggerJsonPath, 'utf8'));
|
|
202
207
|
|
|
203
|
-
|
|
204
|
-
|
|
208
|
+
app.use(
|
|
209
|
+
`${path === '/' ? `/api-docs` : `${path}/api-docs`}`,
|
|
210
|
+
swaggerUi.serve,
|
|
211
|
+
swaggerInstance(swaggerDoc),
|
|
212
|
+
);
|
|
213
|
+
}
|
|
205
214
|
|
|
206
|
-
|
|
215
|
+
if (db && apis) await DataBaseProvider.load({ apis, host, path, db });
|
|
207
216
|
|
|
208
|
-
|
|
209
|
-
|
|
217
|
+
// valkey server
|
|
218
|
+
if (valkey) await createValkeyConnection({ host, path }, valkey);
|
|
210
219
|
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
220
|
+
if (mailer) {
|
|
221
|
+
const mailerSsrConf = confSSR[getCapVariableName(client)];
|
|
222
|
+
await MailerProvider.load({
|
|
223
|
+
id: `${host}${path}`,
|
|
224
|
+
meta: `mailer-${host}${path}`,
|
|
225
|
+
host,
|
|
226
|
+
path,
|
|
227
|
+
...mailer,
|
|
228
|
+
templates: mailerSsrConf ? mailerSsrConf.mailer : {},
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
if (apis) {
|
|
232
|
+
const authMiddleware = authMiddlewareFactory({ host, path });
|
|
233
|
+
|
|
234
|
+
const apiPath = `${path === '/' ? '' : path}/${process.env.BASE_API}`;
|
|
235
|
+
for (const api of apis)
|
|
236
|
+
await (async () => {
|
|
237
|
+
const { ApiRouter } = await import(`../api/${api}/${api}.router.js`);
|
|
238
|
+
const router = ApiRouter({ host, path, apiPath, mailer, db, authMiddleware });
|
|
239
|
+
// router.use(cors({ origin: origins }));
|
|
240
|
+
// logger.info('Load api router', { host, path: apiPath, api });
|
|
241
|
+
app.use(`${apiPath}/${api}`, router);
|
|
242
|
+
})();
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
// load ssr
|
|
246
|
+
const ssr = await ssrMiddlewareFactory({ app, directory, rootHostPath, path });
|
|
247
|
+
for (const [_, ssrMiddleware] of Object.entries(ssr)) app.use(ssrMiddleware);
|
|
224
248
|
|
|
225
|
-
|
|
226
|
-
for (const api of apis)
|
|
249
|
+
if (ws)
|
|
227
250
|
await (async () => {
|
|
228
|
-
const {
|
|
229
|
-
|
|
230
|
-
//
|
|
231
|
-
|
|
232
|
-
|
|
251
|
+
const { createIoServer } = await import(`../ws/${ws}/${ws}.ws.server.js`);
|
|
252
|
+
// logger.info('Load socket.io ws router', { host, ws });
|
|
253
|
+
// start socket.io
|
|
254
|
+
const { options, meta } = await createIoServer(server, {
|
|
255
|
+
host,
|
|
256
|
+
path,
|
|
257
|
+
db,
|
|
258
|
+
port,
|
|
259
|
+
origins,
|
|
260
|
+
});
|
|
261
|
+
await UnderpostStartUp.API.listenPortController(UnderpostStartUp.API.listenServerFactory(), port, {
|
|
262
|
+
runtime: 'nodejs',
|
|
263
|
+
client: null,
|
|
264
|
+
host,
|
|
265
|
+
path: options.path,
|
|
266
|
+
meta,
|
|
267
|
+
});
|
|
233
268
|
})();
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
// load ssr
|
|
237
|
-
const ssr = await ssrMiddlewareFactory({ app, directory, rootHostPath, path });
|
|
238
|
-
for (const [_, ssrMiddleware] of Object.entries(ssr)) app.use(ssrMiddleware);
|
|
239
269
|
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
// logger.info('Load socket.io ws router', { host, ws });
|
|
247
|
-
// start socket.io
|
|
248
|
-
const { options, meta } = await createIoServer(server, {
|
|
270
|
+
if (peer) {
|
|
271
|
+
const peerPort = newInstance(currentPort);
|
|
272
|
+
const { options, meta, peerServer } = await createPeerServer({
|
|
273
|
+
port: peerPort,
|
|
274
|
+
devPort: port,
|
|
275
|
+
origins,
|
|
249
276
|
host,
|
|
250
277
|
path,
|
|
251
|
-
db,
|
|
252
|
-
port,
|
|
253
|
-
origins,
|
|
254
278
|
});
|
|
255
|
-
|
|
279
|
+
|
|
280
|
+
await UnderpostStartUp.API.listenPortController(peerServer, peerPort, {
|
|
256
281
|
runtime: 'nodejs',
|
|
257
282
|
client: null,
|
|
258
283
|
host,
|
|
259
284
|
path: options.path,
|
|
260
285
|
meta,
|
|
261
286
|
});
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
if (peer) {
|
|
265
|
-
currentPort++;
|
|
266
|
-
const peerPort = newInstance(currentPort);
|
|
267
|
-
const { options, meta, peerServer } = await createPeerServer({
|
|
268
|
-
port: peerPort,
|
|
269
|
-
devPort: port,
|
|
270
|
-
origins,
|
|
271
|
-
host,
|
|
272
|
-
path,
|
|
273
|
-
});
|
|
274
|
-
|
|
275
|
-
await UnderpostStartUp.API.listenPortController(peerServer, peerPort, {
|
|
276
|
-
runtime: 'nodejs',
|
|
277
|
-
client: null,
|
|
278
|
-
host,
|
|
279
|
-
path: options.path,
|
|
280
|
-
meta,
|
|
281
|
-
});
|
|
287
|
+
}
|
|
282
288
|
}
|
|
283
289
|
|
|
284
290
|
await UnderpostStartUp.API.listenPortController(server, port, runningData);
|