underpost 2.8.84 → 2.8.86
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 +1 -0
- package/.env.production +1 -0
- package/.env.test +1 -0
- package/.github/workflows/{ghpkg.yml → ghpkg.ci.yml} +1 -1
- package/.github/workflows/{npmpkg.yml → npmpkg.ci.yml} +1 -1
- package/.github/workflows/{publish.yml → publish.ci.yml} +1 -1
- package/.github/workflows/{pwa-microservices-template.page.yml → pwa-microservices-template-page.cd.yml} +2 -2
- package/.github/workflows/{pwa-microservices-template.test.yml → pwa-microservices-template-test.ci.yml} +1 -1
- package/.github/workflows/release.cd.yml +37 -0
- package/.vscode/settings.json +0 -1
- package/README.md +16 -10
- package/bin/build.js +15 -5
- package/bin/cyberia0.js +78 -0
- package/bin/db.js +1 -3
- package/bin/deploy.js +29 -431
- package/bin/file.js +26 -9
- package/cli.md +102 -61
- package/conf.js +1 -1
- package/manifests/deployment/{dd-template-development → dd-default-development}/deployment.yaml +16 -16
- package/manifests/deployment/{dd-template-development → dd-default-development}/proxy.yaml +3 -3
- package/manifests/grafana/deployment.yaml +57 -0
- package/manifests/grafana/kustomization.yaml +7 -0
- package/manifests/grafana/pvc.yaml +12 -0
- package/manifests/grafana/service.yaml +14 -0
- package/manifests/maas/gpu-diag.sh +1 -1
- package/manifests/maas/ssh-cluster-info.sh +14 -0
- package/manifests/prometheus/deployment.yaml +82 -0
- package/package.json +4 -7
- package/src/api/user/user.router.js +24 -1
- package/src/api/user/user.service.js +9 -38
- package/src/cli/cluster.js +83 -29
- package/src/cli/cron.js +12 -45
- package/src/cli/db.js +149 -0
- package/src/cli/deploy.js +40 -81
- package/src/cli/index.js +29 -6
- package/src/cli/monitor.js +9 -16
- package/src/cli/repository.js +12 -5
- package/src/cli/run.js +175 -7
- package/src/cli/ssh.js +32 -0
- package/src/client/Default.index.js +7 -5
- package/src/client/components/core/Account.js +7 -3
- package/src/client/components/core/Chat.js +1 -1
- package/src/client/components/core/CommonJs.js +24 -22
- package/src/client/components/core/Content.js +12 -12
- package/src/client/components/core/Css.js +262 -18
- package/src/client/components/core/CssCore.js +8 -8
- package/src/client/components/core/Docs.js +14 -61
- package/src/client/components/core/DropDown.js +137 -82
- package/src/client/components/core/EventsUI.js +92 -5
- package/src/client/components/core/Input.js +6 -1
- package/src/client/components/core/LoadingAnimation.js +8 -15
- package/src/client/components/core/LogIn.js +3 -0
- package/src/client/components/core/LogOut.js +1 -1
- package/src/client/components/core/Modal.js +601 -137
- package/src/client/components/core/NotificationManager.js +2 -2
- package/src/client/components/core/ObjectLayerEngine.js +638 -0
- package/src/client/components/core/Panel.js +158 -34
- package/src/client/components/core/PanelForm.js +12 -3
- package/src/client/components/core/Recover.js +6 -3
- package/src/client/components/core/Router.js +77 -17
- package/src/client/components/core/Scroll.js +65 -120
- package/src/client/components/core/SignUp.js +1 -0
- package/src/client/components/core/SocketIo.js +3 -3
- package/src/client/components/core/Translate.js +6 -2
- package/src/client/components/core/VanillaJs.js +48 -5
- package/src/client/components/core/Worker.js +3 -1
- package/src/client/components/default/CssDefault.js +17 -3
- package/src/client/components/default/MenuDefault.js +266 -47
- package/src/client/components/default/RoutesDefault.js +8 -14
- package/src/client/public/default/android-chrome-144x144.png +0 -0
- package/src/client/public/default/android-chrome-192x192.png +0 -0
- package/src/client/public/default/android-chrome-256x256.png +0 -0
- package/src/client/public/default/android-chrome-36x36.png +0 -0
- package/src/client/public/default/android-chrome-48x48.png +0 -0
- package/src/client/public/default/android-chrome-72x72.png +0 -0
- package/src/client/public/default/android-chrome-96x96.png +0 -0
- package/src/client/public/default/apple-touch-icon-114x114-precomposed.png +0 -0
- package/src/client/public/default/apple-touch-icon-114x114.png +0 -0
- package/src/client/public/default/apple-touch-icon-120x120-precomposed.png +0 -0
- package/src/client/public/default/apple-touch-icon-120x120.png +0 -0
- package/src/client/public/default/apple-touch-icon-144x144-precomposed.png +0 -0
- package/src/client/public/default/apple-touch-icon-144x144.png +0 -0
- package/src/client/public/default/apple-touch-icon-152x152-precomposed.png +0 -0
- package/src/client/public/default/apple-touch-icon-152x152.png +0 -0
- package/src/client/public/default/apple-touch-icon-180x180-precomposed.png +0 -0
- package/src/client/public/default/apple-touch-icon-180x180.png +0 -0
- package/src/client/public/default/apple-touch-icon-57x57-precomposed.png +0 -0
- package/src/client/public/default/apple-touch-icon-57x57.png +0 -0
- package/src/client/public/default/apple-touch-icon-60x60-precomposed.png +0 -0
- package/src/client/public/default/apple-touch-icon-60x60.png +0 -0
- package/src/client/public/default/apple-touch-icon-72x72-precomposed.png +0 -0
- package/src/client/public/default/apple-touch-icon-72x72.png +0 -0
- package/src/client/public/default/apple-touch-icon-76x76-precomposed.png +0 -0
- package/src/client/public/default/apple-touch-icon-76x76.png +0 -0
- package/src/client/public/default/apple-touch-icon-precomposed.png +0 -0
- package/src/client/public/default/apple-touch-icon.png +0 -0
- package/src/client/public/default/assets/background/dark.jpg +0 -0
- package/src/client/public/default/assets/background/dark.svg +557 -0
- package/src/client/public/default/assets/logo/base-icon.png +0 -0
- package/src/client/public/default/assets/logo/underpost.gif +0 -0
- package/src/client/public/default/assets/mailer/api-user-check.png +0 -0
- package/src/client/public/default/assets/mailer/api-user-invalid-token.png +0 -0
- package/src/client/public/default/assets/mailer/api-user-recover.png +0 -0
- package/src/client/public/default/favicon-16x16.png +0 -0
- package/src/client/public/default/favicon-32x32.png +0 -0
- package/src/client/public/default/favicon.ico +0 -0
- package/src/client/public/default/mstile-144x144.png +0 -0
- package/src/client/public/default/mstile-150x150.png +0 -0
- package/src/client/public/default/mstile-310x150.png +0 -0
- package/src/client/public/default/mstile-310x310.png +0 -0
- package/src/client/public/default/mstile-70x70.png +0 -0
- package/src/client/public/default/safari-pinned-tab.svg +24 -0
- package/src/client/ssr/body/DefaultSplashScreen.js +2 -2
- package/src/index.js +9 -1
- package/src/mailer/MailerProvider.js +37 -0
- package/src/monitor.js +24 -0
- package/src/runtime/lampp/Dockerfile +30 -39
- package/src/runtime/lampp/Lampp.js +11 -2
- package/src/server/client-build-docs.js +205 -0
- package/src/server/client-build-live.js +1 -1
- package/src/server/client-build.js +16 -166
- package/src/server/client-dev-server.js +1 -1
- package/src/server/conf.js +14 -277
- package/src/server/proxy.js +1 -2
- package/src/server/start.js +3 -3
- package/src/server/valkey.js +102 -41
- package/docker-compose.yml +0 -67
- package/prometheus.yml +0 -36
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
<?xml version="1.0" standalone="no"?>
|
|
2
|
+
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN"
|
|
3
|
+
"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
|
|
4
|
+
<svg version="1.0" xmlns="http://www.w3.org/2000/svg"
|
|
5
|
+
width="269.000000pt" height="269.000000pt" viewBox="0 0 269.000000 269.000000"
|
|
6
|
+
preserveAspectRatio="xMidYMid meet">
|
|
7
|
+
<metadata>
|
|
8
|
+
Created by potrace 1.11, written by Peter Selinger 2001-2013
|
|
9
|
+
</metadata>
|
|
10
|
+
<g transform="translate(0.000000,269.000000) scale(0.100000,-0.100000)"
|
|
11
|
+
fill="#000000" stroke="none">
|
|
12
|
+
<path d="M980 2475 l0 -65 65 0 65 0 0 65 0 65 -65 0 -65 0 0 -65z"/>
|
|
13
|
+
<path d="M1700 2475 l0 -65 65 0 65 0 0 65 0 65 -65 0 -65 0 0 -65z"/>
|
|
14
|
+
<path d="M1110 2325 l0 -65 -85 0 -85 0 0 -140 0 -140 -60 0 -60 0 0 -160 0
|
|
15
|
+
-160 75 0 75 0 0 -100 0 -100 95 0 95 0 0 -40 0 -40 -240 0 -240 0 0 -445 0
|
|
16
|
+
-445 -65 0 -65 0 0 -135 0 -135 65 0 65 0 0 -55 0 -55 65 0 65 0 0 475 0 475
|
|
17
|
+
85 0 85 0 0 -425 0 -425 425 0 425 0 0 425 0 425 85 0 85 0 0 -475 0 -475 65
|
|
18
|
+
0 65 0 0 55 0 55 60 0 60 0 0 135 0 135 -60 0 -60 0 0 445 0 445 -240 0 -240
|
|
19
|
+
0 0 35 0 35 95 0 95 0 0 105 0 105 75 0 75 0 0 160 0 160 -60 0 -60 0 0 140 0
|
|
20
|
+
140 -85 0 -85 0 0 65 0 65 -75 0 -75 0 0 -65 0 -65 -145 0 -145 0 0 65 0 65
|
|
21
|
+
-75 0 -75 0 0 -65z m210 -505 l0 -110 -110 0 -110 0 0 110 0 110 110 0 110 0
|
|
22
|
+
0 -110z m390 0 l0 -70 -70 0 -70 0 0 70 0 70 70 0 70 0 0 -70z"/>
|
|
23
|
+
</g>
|
|
24
|
+
</svg>
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
SrrComponent = ({ backgroundImage, metadata }) => html`
|
|
2
2
|
${backgroundImage
|
|
3
|
-
? html`<style>
|
|
3
|
+
? html`<style class="style-ssr-background-image">
|
|
4
4
|
.ssr-background-image {
|
|
5
5
|
background-image: url('${backgroundImage}');
|
|
6
6
|
}
|
|
7
7
|
</style>`
|
|
8
8
|
: metadata?.themeColor
|
|
9
|
-
? html`<style>
|
|
9
|
+
? html`<style class="style-ssr-background-image">
|
|
10
10
|
.ssr-background-image {
|
|
11
11
|
background: ${metadata.themeColor};
|
|
12
12
|
}
|
package/src/index.js
CHANGED
|
@@ -19,6 +19,7 @@ import UnderpostRepository from './cli/repository.js';
|
|
|
19
19
|
import UnderpostRun from './cli/run.js';
|
|
20
20
|
import UnderpostScript from './cli/script.js';
|
|
21
21
|
import UnderpostSecret from './cli/secrets.js';
|
|
22
|
+
import UnderpostSSH from './cli/ssh.js';
|
|
22
23
|
import UnderpostTest from './cli/test.js';
|
|
23
24
|
import UnderpostStartUp from './server/start.js';
|
|
24
25
|
|
|
@@ -34,7 +35,7 @@ class Underpost {
|
|
|
34
35
|
* @type {String}
|
|
35
36
|
* @memberof Underpost
|
|
36
37
|
*/
|
|
37
|
-
static version = 'v2.8.
|
|
38
|
+
static version = 'v2.8.86';
|
|
38
39
|
/**
|
|
39
40
|
* Repository cli API
|
|
40
41
|
* @static
|
|
@@ -126,6 +127,13 @@ class Underpost {
|
|
|
126
127
|
* @memberof Underpost
|
|
127
128
|
*/
|
|
128
129
|
static monitor = UnderpostMonitor.API;
|
|
130
|
+
/**
|
|
131
|
+
* SSH cli API
|
|
132
|
+
* @static
|
|
133
|
+
* @type {UnderpostSSH.API}
|
|
134
|
+
* @memberof Underpost
|
|
135
|
+
*/
|
|
136
|
+
static ssh = UnderpostSSH.API;
|
|
129
137
|
/**
|
|
130
138
|
* LXD cli API
|
|
131
139
|
* @static
|
|
@@ -48,6 +48,43 @@ const MailerProvider = {
|
|
|
48
48
|
...options,
|
|
49
49
|
transporter,
|
|
50
50
|
templates: await EmailRender.getTemplates(options),
|
|
51
|
+
translateTemplates: {
|
|
52
|
+
confirmEmail: {
|
|
53
|
+
H1: {
|
|
54
|
+
en: 'Confirm Your Email',
|
|
55
|
+
es: 'Confirma tu correo electrónico',
|
|
56
|
+
},
|
|
57
|
+
P1: {
|
|
58
|
+
en: `Email confirmed! Thanks.
|
|
59
|
+
<br />
|
|
60
|
+
<span style="font-size: 12px; color: gray">
|
|
61
|
+
If it is not automatically verified,
|
|
62
|
+
please allow the image to be seen, thank you.
|
|
63
|
+
</span>
|
|
64
|
+
`,
|
|
65
|
+
es: `Correo electrónico confirmado! Gracias.
|
|
66
|
+
<br />
|
|
67
|
+
<span style="font-size: 12px; color: gray">
|
|
68
|
+
Si no se verifica automáticamente, por favor permita que se vea la imagen, gracias.
|
|
69
|
+
</span>
|
|
70
|
+
`,
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
recoverEmail: {
|
|
74
|
+
H1: {
|
|
75
|
+
en: 'Recover your account',
|
|
76
|
+
es: 'Recupera tu cuenta',
|
|
77
|
+
},
|
|
78
|
+
P1: {
|
|
79
|
+
en: 'To recover your account, please click the button below:',
|
|
80
|
+
es: 'Para recuperar tu cuenta, haz click en el botón de abajo:',
|
|
81
|
+
},
|
|
82
|
+
BTN_LABEL: {
|
|
83
|
+
en: 'Recover Password',
|
|
84
|
+
es: 'Recuperar Contraseña',
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
},
|
|
51
88
|
};
|
|
52
89
|
|
|
53
90
|
return this.instance[id];
|
package/src/monitor.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// https://nodejs.org/api
|
|
4
|
+
// https://expressjs.com/en/4x/api.html
|
|
5
|
+
|
|
6
|
+
import dotenv from 'dotenv';
|
|
7
|
+
import { loggerFactory } from './server/logger.js';
|
|
8
|
+
import { ProcessController } from './server/process.js';
|
|
9
|
+
import { getUnderpostRootPath } from './server/conf.js';
|
|
10
|
+
import fs from 'fs-extra';
|
|
11
|
+
import UnderpostMonitor from './cli/monitor.js';
|
|
12
|
+
|
|
13
|
+
const underpostRootPath = getUnderpostRootPath();
|
|
14
|
+
fs.existsSync(`${underpostRootPath}/.env`)
|
|
15
|
+
? dotenv.config({ path: `${underpostRootPath}/.env`, override: true })
|
|
16
|
+
: dotenv.config();
|
|
17
|
+
|
|
18
|
+
const logger = loggerFactory(import.meta);
|
|
19
|
+
|
|
20
|
+
await logger.setUpInfo();
|
|
21
|
+
|
|
22
|
+
UnderpostMonitor.API.callback(process.argv[2], process.argv[3], { type: 'blue-green', sync: true });
|
|
23
|
+
|
|
24
|
+
ProcessController.init(logger);
|
|
@@ -1,43 +1,35 @@
|
|
|
1
1
|
FROM rockylinux:9
|
|
2
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
|
-
RUN sed -i.bak 's/display_errors=Off/display_errors=On/g' /opt/lampp/etc/php.ini
|
|
34
|
-
# Enable includes of several configuration files for Apache
|
|
35
|
-
RUN mkdir -p /opt/lampp/apache2/conf.d
|
|
36
|
-
RUN echo "IncludeOptional /opt/lampp/apache2/conf.d/*.conf" >>/opt/lampp/etc/httpd.conf
|
|
37
|
-
# Create a /www folder and a symbolic link to it in /opt/lampp/htdocs
|
|
38
|
-
# This is convenient because it doesn't interfere with xampp, phpmyadmin or other tools
|
|
39
|
-
RUN mkdir /www
|
|
40
|
-
RUN ln -s /www /opt/lampp/htdocs
|
|
3
|
+
# --- Update and install required packages
|
|
4
|
+
RUN dnf -y update && \
|
|
5
|
+
dnf -y install epel-release && \
|
|
6
|
+
dnf -y install --allowerasing \
|
|
7
|
+
bzip2 \
|
|
8
|
+
sudo \
|
|
9
|
+
curl \
|
|
10
|
+
net-tools \
|
|
11
|
+
openssh-server \
|
|
12
|
+
nano \
|
|
13
|
+
vim-enhanced \
|
|
14
|
+
less \
|
|
15
|
+
openssl-devel \
|
|
16
|
+
wget \
|
|
17
|
+
git \
|
|
18
|
+
gnupg2 \
|
|
19
|
+
libnsl \
|
|
20
|
+
perl && \
|
|
21
|
+
dnf clean all
|
|
22
|
+
|
|
23
|
+
# --- Download and install XAMPP
|
|
24
|
+
RUN curl -L -o /tmp/xampp-linux-installer.run "https://sourceforge.net/projects/xampp/files/XAMPP%20Linux/7.4.33/xampp-linux-x64-7.4.33-0-installer.run" && \
|
|
25
|
+
chmod +x /tmp/xampp-linux-installer.run && \
|
|
26
|
+
bash -c "/tmp/xampp-linux-installer.run --mode unattended" && \
|
|
27
|
+
ln -sf /opt/lampp/lampp /usr/bin/lampp
|
|
28
|
+
|
|
29
|
+
# --- Create /xampp/htdocs (static root) and set permissions
|
|
30
|
+
RUN mkdir -p /opt/lampp/htdocs && \
|
|
31
|
+
chown -R root:root /opt/lampp/htdocs && \
|
|
32
|
+
chmod -R a+rX /opt/lampp/htdocs
|
|
41
33
|
|
|
42
34
|
# Install Node.js
|
|
43
35
|
RUN curl -fsSL https://rpm.nodesource.com/setup_23.x | bash -
|
|
@@ -51,7 +43,6 @@ RUN npm --version
|
|
|
51
43
|
# Set working directory
|
|
52
44
|
WORKDIR /home/dd
|
|
53
45
|
|
|
54
|
-
# Expose necessary ports
|
|
55
46
|
EXPOSE 22
|
|
56
47
|
EXPOSE 80
|
|
57
48
|
EXPOSE 443
|
|
@@ -10,7 +10,16 @@ const Lampp = {
|
|
|
10
10
|
initService: async function (options = { daemon: false }) {
|
|
11
11
|
let cmd;
|
|
12
12
|
// linux
|
|
13
|
-
|
|
13
|
+
// /opt/lampp/apache2/conf/httpd.conf
|
|
14
|
+
fs.writeFileSync(`/opt/lampp/etc/extra/httpd-vhosts.conf`, this.router || '', 'utf8');
|
|
15
|
+
fs.writeFileSync(
|
|
16
|
+
`/opt/lampp/etc/httpd.conf`,
|
|
17
|
+
fs
|
|
18
|
+
.readFileSync(`/opt/lampp/etc/httpd.conf`, 'utf8')
|
|
19
|
+
.replace(`#Include etc/extra/httpd-vhosts.conf`, `Include etc/extra/httpd-vhosts.conf`),
|
|
20
|
+
'utf8',
|
|
21
|
+
);
|
|
22
|
+
|
|
14
23
|
cmd = `sudo /opt/lampp/lampp stop`;
|
|
15
24
|
if (!fs.readFileSync(`/opt/lampp/etc/httpd.conf`, 'utf8').match(`# Listen 80`))
|
|
16
25
|
fs.writeFileSync(
|
|
@@ -42,7 +51,7 @@ const Lampp = {
|
|
|
42
51
|
if (this.router) fs.writeFileSync(`./tmp/lampp-router.conf`, this.router, 'utf-8');
|
|
43
52
|
shellExec(cmd);
|
|
44
53
|
},
|
|
45
|
-
enabled: () => fs.existsSync(`/opt/lampp/
|
|
54
|
+
enabled: () => fs.existsSync(`/opt/lampp/etc/httpd.conf`),
|
|
46
55
|
appendRouter: function (render) {
|
|
47
56
|
if (!this.router) {
|
|
48
57
|
if (fs.existsSync(`./tmp/lampp-router.conf`))
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
import fs from 'fs-extra';
|
|
4
|
+
import swaggerAutoGen from 'swagger-autogen';
|
|
5
|
+
import { shellExec } from './process.js';
|
|
6
|
+
import { loggerFactory } from './logger.js';
|
|
7
|
+
import { JSONweb } from './client-formatted.js';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Builds API documentation using Swagger
|
|
11
|
+
* @param {Object} options - Documentation build options
|
|
12
|
+
* @param {string} options.host - The hostname for the API
|
|
13
|
+
* @param {string} options.path - The base path for the API
|
|
14
|
+
* @param {number} options.port - The port number for the API
|
|
15
|
+
* @param {Object} options.metadata - Metadata for the API documentation
|
|
16
|
+
* @param {Array<string>} options.apis - List of API modules to document
|
|
17
|
+
* @param {string} options.publicClientId - Client ID for the public documentation
|
|
18
|
+
* @param {string} options.rootClientPath - Root path for client files
|
|
19
|
+
* @param {Object} options.packageData - Package.json data
|
|
20
|
+
*/
|
|
21
|
+
const buildApiDocs = async ({
|
|
22
|
+
host,
|
|
23
|
+
path,
|
|
24
|
+
port,
|
|
25
|
+
metadata = {},
|
|
26
|
+
apis = [],
|
|
27
|
+
publicClientId,
|
|
28
|
+
rootClientPath,
|
|
29
|
+
packageData,
|
|
30
|
+
}) => {
|
|
31
|
+
const logger = loggerFactory(import.meta);
|
|
32
|
+
const basePath = path === '/' ? `${process.env.BASE_API}` : `/${process.env.BASE_API}`;
|
|
33
|
+
|
|
34
|
+
const doc = {
|
|
35
|
+
info: {
|
|
36
|
+
version: packageData.version,
|
|
37
|
+
title: metadata?.title ? `${metadata.title}` : 'REST API',
|
|
38
|
+
description: metadata?.description ? metadata.description : '',
|
|
39
|
+
},
|
|
40
|
+
servers: [
|
|
41
|
+
{
|
|
42
|
+
url:
|
|
43
|
+
process.env.NODE_ENV === 'development'
|
|
44
|
+
? `http://localhost:${port}${path}${basePath}`
|
|
45
|
+
: `https://${host}${path}${basePath}`,
|
|
46
|
+
description: `${process.env.NODE_ENV} server`,
|
|
47
|
+
},
|
|
48
|
+
],
|
|
49
|
+
tags: [
|
|
50
|
+
{
|
|
51
|
+
name: 'user',
|
|
52
|
+
description: 'User API operations',
|
|
53
|
+
},
|
|
54
|
+
],
|
|
55
|
+
components: {
|
|
56
|
+
schemas: {
|
|
57
|
+
userRequest: {
|
|
58
|
+
username: 'user123',
|
|
59
|
+
password: 'Password123',
|
|
60
|
+
email: 'user@example.com',
|
|
61
|
+
},
|
|
62
|
+
userResponse: {
|
|
63
|
+
status: 'success',
|
|
64
|
+
data: {
|
|
65
|
+
token: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyIjp7Il9pZCI6IjY2YzM3N2Y1N2Y5OWU1OTY5YjgxZG...',
|
|
66
|
+
user: {
|
|
67
|
+
_id: '66c377f57f99e5969b81de89',
|
|
68
|
+
email: 'user@example.com',
|
|
69
|
+
emailConfirmed: false,
|
|
70
|
+
username: 'user123',
|
|
71
|
+
role: 'user',
|
|
72
|
+
profileImageId: '66c377f57f99e5969b81de87',
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
userUpdateResponse: {
|
|
77
|
+
status: 'success',
|
|
78
|
+
data: {
|
|
79
|
+
_id: '66c377f57f99e5969b81de89',
|
|
80
|
+
email: 'user@example.com',
|
|
81
|
+
emailConfirmed: false,
|
|
82
|
+
username: 'user123222',
|
|
83
|
+
role: 'user',
|
|
84
|
+
profileImageId: '66c377f57f99e5969b81de87',
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
userGetResponse: {
|
|
88
|
+
status: 'success',
|
|
89
|
+
data: {
|
|
90
|
+
_id: '66c377f57f99e5969b81de89',
|
|
91
|
+
email: 'user@example.com',
|
|
92
|
+
emailConfirmed: false,
|
|
93
|
+
username: 'user123222',
|
|
94
|
+
role: 'user',
|
|
95
|
+
profileImageId: '66c377f57f99e5969b81de87',
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
userLogInRequest: {
|
|
99
|
+
email: 'user@example.com',
|
|
100
|
+
password: 'Password123',
|
|
101
|
+
},
|
|
102
|
+
userBadRequestResponse: {
|
|
103
|
+
status: 'error',
|
|
104
|
+
message: 'Bad request. Please check your inputs, and try again',
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
securitySchemes: {
|
|
108
|
+
bearerAuth: {
|
|
109
|
+
type: 'http',
|
|
110
|
+
scheme: 'bearer',
|
|
111
|
+
},
|
|
112
|
+
},
|
|
113
|
+
},
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
logger.warn('build swagger api docs', doc.info);
|
|
117
|
+
|
|
118
|
+
const outputFile = `./public/${host}${path === '/' ? path : `${path}/`}swagger-output.json`;
|
|
119
|
+
const routes = [];
|
|
120
|
+
for (const api of apis) {
|
|
121
|
+
if (['user'].includes(api)) routes.push(`./src/api/${api}/${api}.router.js`);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
await swaggerAutoGen({ openapi: '3.0.0' })(outputFile, routes, doc);
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Builds JSDoc documentation
|
|
129
|
+
* @param {Object} options - JSDoc build options
|
|
130
|
+
* @param {string} options.host - The hostname for the documentation
|
|
131
|
+
* @param {string} options.path - The base path for the documentation
|
|
132
|
+
* @param {Object} options.metadata - Metadata for the documentation
|
|
133
|
+
*/
|
|
134
|
+
const buildJsDocs = async ({ host, path, metadata = {} }) => {
|
|
135
|
+
const logger = loggerFactory(import.meta);
|
|
136
|
+
const jsDocsConfig = JSON.parse(fs.readFileSync(`./jsdoc.json`, 'utf8'));
|
|
137
|
+
|
|
138
|
+
jsDocsConfig.opts.destination = `./public/${host}${path === '/' ? path : `${path}/`}docs/`;
|
|
139
|
+
jsDocsConfig.opts.theme_opts.title = metadata?.title ? metadata.title : undefined;
|
|
140
|
+
jsDocsConfig.opts.theme_opts.favicon = `./public/${host}${path === '/' ? path : `${path}/favicon.ico`}`;
|
|
141
|
+
|
|
142
|
+
fs.writeFileSync(`./jsdoc.json`, JSON.stringify(jsDocsConfig, null, 4), 'utf8');
|
|
143
|
+
logger.warn('build jsdoc view', jsDocsConfig.opts.destination);
|
|
144
|
+
|
|
145
|
+
shellExec(`npm run docs`, { silent: true });
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Builds test coverage documentation
|
|
150
|
+
* @param {Object} options - Coverage build options
|
|
151
|
+
* @param {string} options.host - The hostname for the coverage
|
|
152
|
+
* @param {string} options.path - The base path for the coverage
|
|
153
|
+
*/
|
|
154
|
+
const buildCoverage = async ({ host, path }) => {
|
|
155
|
+
const logger = loggerFactory(import.meta);
|
|
156
|
+
const jsDocsConfig = JSON.parse(fs.readFileSync(`./jsdoc.json`, 'utf8'));
|
|
157
|
+
|
|
158
|
+
if (!fs.existsSync(`./coverage`)) {
|
|
159
|
+
shellExec(`npm test`);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
const coverageBuildPath = `${jsDocsConfig.opts.destination}/coverage`;
|
|
163
|
+
fs.mkdirSync(coverageBuildPath, { recursive: true });
|
|
164
|
+
fs.copySync(`./coverage`, coverageBuildPath);
|
|
165
|
+
|
|
166
|
+
logger.warn('build coverage', coverageBuildPath);
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Main function to build all documentation
|
|
171
|
+
* @param {Object} options - Documentation build options
|
|
172
|
+
* @param {string} options.host - The hostname
|
|
173
|
+
* @param {string} options.path - The base path
|
|
174
|
+
* @param {number} options.port - The port number
|
|
175
|
+
* @param {Object} options.metadata - Metadata for the documentation
|
|
176
|
+
* @param {Array<string>} options.apis - List of API modules to document
|
|
177
|
+
* @param {string} options.publicClientId - Client ID for the public documentation
|
|
178
|
+
* @param {string} options.rootClientPath - Root path for client files
|
|
179
|
+
* @param {Object} options.packageData - Package.json data
|
|
180
|
+
*/
|
|
181
|
+
const buildDocs = async ({
|
|
182
|
+
host,
|
|
183
|
+
path,
|
|
184
|
+
port,
|
|
185
|
+
metadata = {},
|
|
186
|
+
apis = [],
|
|
187
|
+
publicClientId,
|
|
188
|
+
rootClientPath,
|
|
189
|
+
packageData,
|
|
190
|
+
}) => {
|
|
191
|
+
await buildJsDocs({ host, path, metadata });
|
|
192
|
+
await buildCoverage({ host, path });
|
|
193
|
+
await buildApiDocs({
|
|
194
|
+
host,
|
|
195
|
+
path,
|
|
196
|
+
port,
|
|
197
|
+
metadata,
|
|
198
|
+
apis,
|
|
199
|
+
publicClientId,
|
|
200
|
+
rootClientPath,
|
|
201
|
+
packageData,
|
|
202
|
+
});
|
|
203
|
+
};
|
|
204
|
+
|
|
205
|
+
export { buildDocs };
|
|
@@ -59,7 +59,7 @@ const clientLiveBuild = async () => {
|
|
|
59
59
|
const updates = JSON.parse(fs.readFileSync(`./tmp/client.build.json`, 'utf8'));
|
|
60
60
|
const liveClientBuildPaths = [];
|
|
61
61
|
for (let srcPath of updates) {
|
|
62
|
-
srcPath = srcPath.replaceAll('/', `\\`);
|
|
62
|
+
srcPath = srcPath.replaceAll('/', `\\`);
|
|
63
63
|
|
|
64
64
|
const srcBuildPath = `./src${srcPath.split('src')[1].replace(/\\/g, '/')}`;
|
|
65
65
|
if (
|