underpost 2.7.7 → 2.7.9
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/.github/workflows/ghpkg.yml +115 -0
- package/.github/workflows/publish.yml +20 -3
- package/.github/workflows/pwa-microservices-template.page.yml +54 -0
- package/.github/workflows/pwa-microservices-template.test.yml +30 -0
- package/.vscode/settings.json +6 -0
- package/CHANGELOG.md +64 -16
- package/bin/cron.js +47 -0
- package/bin/db.js +9 -1
- package/bin/deploy.js +207 -11
- package/bin/file.js +17 -1
- package/bin/index.js +1 -1
- package/bin/util.js +22 -0
- package/conf.js +18 -4
- package/docker-compose.yml +1 -1
- package/package.json +3 -3
- package/src/api/core/core.router.js +9 -9
- package/src/api/core/core.service.js +6 -4
- package/src/api/default/default.service.js +4 -4
- package/src/api/file/file.service.js +3 -3
- package/src/api/user/user.service.js +7 -7
- package/src/client/components/core/Css.js +0 -222
- package/src/client/components/core/CssCore.js +30 -3
- package/src/client/components/core/Docs.js +110 -10
- package/src/client/components/core/Modal.js +224 -22
- package/src/client/components/core/Panel.js +1 -1
- package/src/client/components/core/PanelForm.js +2 -1
- package/src/client/components/core/Responsive.js +15 -0
- package/src/client/components/core/RichText.js +4 -2
- package/src/client/components/core/Translate.js +6 -2
- package/src/client/components/core/WebComponent.js +44 -0
- package/src/client/components/core/Worker.js +12 -4
- package/src/client/public/default/plantuml/client-conf.svg +1 -1
- package/src/client/public/default/plantuml/client-schema.svg +1 -1
- package/src/client/public/default/plantuml/cron-conf.svg +1 -1
- package/src/client/public/default/plantuml/cron-schema.svg +1 -1
- package/src/client/public/default/plantuml/server-conf.svg +1 -1
- package/src/client/public/default/plantuml/server-schema.svg +1 -1
- package/src/client/public/default/plantuml/ssr-conf.svg +1 -1
- package/src/client/public/default/plantuml/ssr-schema.svg +1 -1
- package/src/client/public/default/site.webmanifest +69 -0
- package/src/client/services/default/default.management.js +118 -120
- package/src/client/ssr/Render.js +224 -3
- package/src/client/ssr/common/Alert.js +75 -0
- package/src/client/ssr/common/SsrCore.js +91 -0
- package/src/client/ssr/common/Translate.js +26 -0
- package/src/client/ssr/common/Worker.js +28 -0
- package/src/client/ssr/{body-components → components/body}/CacheControl.js +1 -1
- package/src/client/ssr/{body-components → components/body}/DefaultSplashScreen.js +15 -4
- package/src/client/ssr/components/head/Pwa.js +146 -0
- package/src/client/ssr/pages/404.js +12 -0
- package/src/client/ssr/pages/500.js +12 -0
- package/src/client/ssr/pages/maintenance.js +14 -0
- package/src/client/ssr/pages/offline.js +21 -0
- package/src/client/sw/default.sw.js +13 -9
- package/src/db/DataBaseProvider.js +12 -1
- package/src/db/mongo/MongooseDB.js +0 -1
- package/src/mailer/EmailRender.js +1 -1
- package/src/server/backup.js +82 -70
- package/src/server/client-build-live.js +6 -0
- package/src/server/client-build.js +76 -73
- package/src/server/client-formatted.js +11 -1
- package/src/server/client-icons.js +1 -1
- package/src/server/conf.js +60 -12
- package/src/server/crypto.js +91 -0
- package/src/server/dns.js +42 -13
- package/src/server/network.js +94 -7
- package/src/server/proxy.js +27 -27
- package/src/server/runtime.js +27 -8
- package/.github/workflows/test.yml +0 -80
- package/src/client/ssr/head-components/Microdata.js +0 -11
- package/src/cron.js +0 -30
- package/src/server/cron.js +0 -35
- /package/src/client/ssr/{email-components → components/email}/DefaultRecoverEmail.js +0 -0
- /package/src/client/ssr/{email-components → components/email}/DefaultVerifyEmail.js +0 -0
- /package/src/client/ssr/{head-components → components/head}/Css.js +0 -0
- /package/src/client/ssr/{head-components → components/head}/DefaultScripts.js +0 -0
- /package/src/client/ssr/{head-components → components/head}/Production.js +0 -0
- /package/src/client/ssr/{head-components → components/head}/PwaDefault.js +0 -0
- /package/src/client/ssr/{head-components → components/head}/Seo.js +0 -0
package/src/server/runtime.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import fs from 'fs';
|
|
1
|
+
import fs from 'fs-extra';
|
|
2
2
|
import express from 'express';
|
|
3
3
|
import cors from 'cors';
|
|
4
4
|
import dotenv from 'dotenv';
|
|
@@ -18,13 +18,14 @@ import { DataBaseProvider } from '../db/DataBaseProvider.js';
|
|
|
18
18
|
import { createProxyMiddleware } from 'http-proxy-middleware';
|
|
19
19
|
import { createPeerServer } from './peer.js';
|
|
20
20
|
import { Lampp } from '../runtime/lampp/Lampp.js';
|
|
21
|
+
import { getDeployId } from './conf.js';
|
|
21
22
|
|
|
22
23
|
dotenv.config();
|
|
23
24
|
|
|
24
25
|
const logger = loggerFactory(import.meta);
|
|
25
26
|
|
|
26
27
|
const buildRuntime = async () => {
|
|
27
|
-
const deployId =
|
|
28
|
+
const deployId = getDeployId();
|
|
28
29
|
|
|
29
30
|
const collectDefaultMetrics = promClient.collectDefaultMetrics;
|
|
30
31
|
collectDefaultMetrics();
|
|
@@ -95,6 +96,7 @@ export PATH=$PATH:/opt/lampp/bin`,
|
|
|
95
96
|
runtime,
|
|
96
97
|
client,
|
|
97
98
|
meta: import.meta,
|
|
99
|
+
apis,
|
|
98
100
|
};
|
|
99
101
|
|
|
100
102
|
let redirectUrl;
|
|
@@ -114,10 +116,10 @@ export PATH=$PATH:/opt/lampp/bin`,
|
|
|
114
116
|
Listen ${port}
|
|
115
117
|
|
|
116
118
|
<VirtualHost *:${port}>
|
|
117
|
-
DocumentRoot "${directory ? directory
|
|
119
|
+
DocumentRoot "${directory ? directory : `${getRootDirectory()}${rootHostPath}`}"
|
|
118
120
|
ServerName ${host}:${port}
|
|
119
121
|
|
|
120
|
-
<Directory "${directory ? directory
|
|
122
|
+
<Directory "${directory ? directory : `${getRootDirectory()}${rootHostPath}`}">
|
|
121
123
|
Options Indexes FollowSymLinks MultiViews
|
|
122
124
|
AllowOverride All
|
|
123
125
|
Require all granted
|
|
@@ -134,6 +136,13 @@ export PATH=$PATH:/opt/lampp/bin`,
|
|
|
134
136
|
: ''
|
|
135
137
|
}
|
|
136
138
|
|
|
139
|
+
ErrorDocument 400 ${path === '/' ? '' : path}/400.html
|
|
140
|
+
ErrorDocument 404 ${path === '/' ? '' : path}/400.html
|
|
141
|
+
ErrorDocument 500 ${path === '/' ? '' : path}/500.html
|
|
142
|
+
ErrorDocument 502 ${path === '/' ? '' : path}/500.html
|
|
143
|
+
ErrorDocument 503 ${path === '/' ? '' : path}/500.html
|
|
144
|
+
ErrorDocument 504 ${path === '/' ? '' : path}/500.html
|
|
145
|
+
|
|
137
146
|
</VirtualHost>
|
|
138
147
|
|
|
139
148
|
`);
|
|
@@ -196,10 +205,10 @@ export PATH=$PATH:/opt/lampp/bin`,
|
|
|
196
205
|
Listen ${port}
|
|
197
206
|
|
|
198
207
|
<VirtualHost *:${port}>
|
|
199
|
-
DocumentRoot "${directory ? directory
|
|
208
|
+
DocumentRoot "${directory ? directory : `${getRootDirectory()}${rootHostPath}`}"
|
|
200
209
|
ServerName ${host}:${port}
|
|
201
210
|
|
|
202
|
-
<Directory "${directory ? directory
|
|
211
|
+
<Directory "${directory ? directory : `${getRootDirectory()}${rootHostPath}`}">
|
|
203
212
|
Options Indexes FollowSymLinks MultiViews
|
|
204
213
|
AllowOverride All
|
|
205
214
|
Require all granted
|
|
@@ -216,6 +225,13 @@ export PATH=$PATH:/opt/lampp/bin`,
|
|
|
216
225
|
: ''
|
|
217
226
|
}
|
|
218
227
|
|
|
228
|
+
ErrorDocument 400 ${path === '/' ? '' : path}/400.html
|
|
229
|
+
ErrorDocument 404 ${path === '/' ? '' : path}/400.html
|
|
230
|
+
ErrorDocument 500 ${path === '/' ? '' : path}/500.html
|
|
231
|
+
ErrorDocument 502 ${path === '/' ? '' : path}/500.html
|
|
232
|
+
ErrorDocument 503 ${path === '/' ? '' : path}/500.html
|
|
233
|
+
ErrorDocument 504 ${path === '/' ? '' : path}/500.html
|
|
234
|
+
|
|
219
235
|
</VirtualHost>
|
|
220
236
|
|
|
221
237
|
`);
|
|
@@ -369,13 +385,16 @@ export PATH=$PATH:/opt/lampp/bin`,
|
|
|
369
385
|
app.use(`${apiPath}/${api}`, router);
|
|
370
386
|
})();
|
|
371
387
|
}
|
|
372
|
-
|
|
373
388
|
app.use(function (req, res, next) {
|
|
374
|
-
|
|
389
|
+
const path404 = `${directory ? directory : `${getRootDirectory()}${rootHostPath}`}/404.html`;
|
|
390
|
+
if (fs.existsSync(path404)) return res.status(404).sendFile(path404);
|
|
391
|
+
else res.status(404).send('Sorry cant find that!');
|
|
375
392
|
});
|
|
376
393
|
|
|
377
394
|
app.use(function (err, req, res, next) {
|
|
378
395
|
logger.error(err, err.stack);
|
|
396
|
+
const path500 = `${directory ? directory : `${getRootDirectory()}${rootHostPath}`}/500.html`;
|
|
397
|
+
if (fs.existsSync(path500)) return res.status(500).sendFile(path500);
|
|
379
398
|
res.status(500).send('Something broke!');
|
|
380
399
|
});
|
|
381
400
|
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
name: Test
|
|
2
|
-
on:
|
|
3
|
-
push:
|
|
4
|
-
branches: ['master']
|
|
5
|
-
pull_request:
|
|
6
|
-
branches: ['master']
|
|
7
|
-
jobs:
|
|
8
|
-
test:
|
|
9
|
-
name: Node ${{ matrix.node }} on ${{ matrix.os }}
|
|
10
|
-
runs-on: ${{ matrix.os }}
|
|
11
|
-
strategy:
|
|
12
|
-
matrix:
|
|
13
|
-
node-version: [21.x]
|
|
14
|
-
os: [ubuntu-latest]
|
|
15
|
-
# os: [ubuntu-latest, windows-latest]
|
|
16
|
-
|
|
17
|
-
steps:
|
|
18
|
-
- name: Clone repository
|
|
19
|
-
uses: actions/checkout@v3
|
|
20
|
-
|
|
21
|
-
- name: Set Node.js version
|
|
22
|
-
uses: actions/setup-node@v3
|
|
23
|
-
with:
|
|
24
|
-
node-version: ${{ matrix.node }}
|
|
25
|
-
|
|
26
|
-
- name: Get npm root
|
|
27
|
-
run: sudo npm root -g
|
|
28
|
-
|
|
29
|
-
- name: Install underpost cli
|
|
30
|
-
run: sudo npm install -g underpost
|
|
31
|
-
|
|
32
|
-
- name: Run test
|
|
33
|
-
run: sudo underpost test
|
|
34
|
-
|
|
35
|
-
# for travis
|
|
36
|
-
# - name: Run coveralls
|
|
37
|
-
# run: npm run coveralls # nyc npm run test --reporter=text-lcov | coveralls -v
|
|
38
|
-
|
|
39
|
-
# - name: Test token
|
|
40
|
-
# run: echo "${{ secrets.COVERALLS_REPO_TOKEN }}"
|
|
41
|
-
|
|
42
|
-
# - name: Coveralls
|
|
43
|
-
# uses: coverallsapp/github-action@master
|
|
44
|
-
# with:
|
|
45
|
-
# github-token: ${{ secrets.GITHUB_TOKEN }}
|
|
46
|
-
# flag-name: ${{matrix.os}}-node-${{ matrix.node }}
|
|
47
|
-
# parallel: true
|
|
48
|
-
|
|
49
|
-
# - name: Coveralls
|
|
50
|
-
# uses: coverallsapp/github-action@master
|
|
51
|
-
# with:
|
|
52
|
-
# github-token: ${{ secrets.GITHUB_TOKEN }}
|
|
53
|
-
# path-to-lcov: '/usr/local/lib/node_modules/underpost/coverage/lcov.info'
|
|
54
|
-
# env:
|
|
55
|
-
# COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
|
|
56
|
-
# COVERALLS_GIT_BRANCH: "${{ github.ref }}"
|
|
57
|
-
|
|
58
|
-
# - name: Coveralls
|
|
59
|
-
# run: node ./node_modules/coveralls-next/bin/coveralls.js # cat ./coverage/lcov.info |
|
|
60
|
-
# env:
|
|
61
|
-
# COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
|
|
62
|
-
# COVERALLS_SERVICE_NAME: CI-pipeline
|
|
63
|
-
# COVERALLS_SERVICE_JOB_ID: ${{github.run_id}}
|
|
64
|
-
# COVERALLS_SERVICE_JOB_NUMBER: ${{github.run_number}}
|
|
65
|
-
# COVERALLS_FLAG_NAME: ${{matrix.os}}-node-${{ matrix.node }}
|
|
66
|
-
# COVERALLS_PARALLEL: true
|
|
67
|
-
# NODE_COVERALLS_DEBUG: 1
|
|
68
|
-
# finish:
|
|
69
|
-
# needs: test
|
|
70
|
-
# runs-on: ubuntu-latest
|
|
71
|
-
# steps:
|
|
72
|
-
# - name: Clone repository
|
|
73
|
-
# uses: actions/checkout@v2
|
|
74
|
-
|
|
75
|
-
# - name: Coveralls Finished
|
|
76
|
-
# run: |
|
|
77
|
-
# curl -kv -d 'payload[build_num]=${{github.run_id}}&payload[status]=done' https://coveralls.io/webhook?repo_token=${COVERALLS_REPO_TOKEN}
|
|
78
|
-
# env:
|
|
79
|
-
# COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
|
|
80
|
-
# COVERALLS_GIT_BRANCH: '${{ github.ref }}'
|
package/src/cron.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
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 { Dns } from './server/dns.js';
|
|
9
|
-
import { ProcessController } from './server/process.js';
|
|
10
|
-
import { Config } from './server/conf.js';
|
|
11
|
-
import { BackUpManagement } from './server/backup.js';
|
|
12
|
-
import { CronManagement } from './server/cron.js';
|
|
13
|
-
|
|
14
|
-
dotenv.config();
|
|
15
|
-
|
|
16
|
-
await Config.build();
|
|
17
|
-
|
|
18
|
-
const logger = loggerFactory(import.meta);
|
|
19
|
-
|
|
20
|
-
await logger.setUpInfo();
|
|
21
|
-
|
|
22
|
-
// every minutes
|
|
23
|
-
CronManagement.add('ip', '* * * * *', await Dns.InitIpDaemon());
|
|
24
|
-
|
|
25
|
-
// every day at 1 am
|
|
26
|
-
CronManagement.add('backup', '0 1 * * *', await BackUpManagement.Init());
|
|
27
|
-
|
|
28
|
-
await CronManagement.init();
|
|
29
|
-
|
|
30
|
-
ProcessController.init(logger);
|
package/src/server/cron.js
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import cron from 'node-cron';
|
|
2
|
-
import { loggerFactory } from './logger.js';
|
|
3
|
-
|
|
4
|
-
const logger = loggerFactory(import.meta);
|
|
5
|
-
|
|
6
|
-
const CronManagement = {
|
|
7
|
-
data: {},
|
|
8
|
-
init: function () {
|
|
9
|
-
// verify tokens
|
|
10
|
-
// https://github.com/settings/tokens
|
|
11
|
-
for (const cronKey of Object.keys(this.data)) {
|
|
12
|
-
if (this.data[cronKey].valid) {
|
|
13
|
-
this.data[cronKey].task.start();
|
|
14
|
-
logger.info(`Cron task "${this.data[cronKey].name}" started`);
|
|
15
|
-
} else {
|
|
16
|
-
logger.error(
|
|
17
|
-
`Invalid cron expression "${this.data[cronKey].expression}" for task "${this.data[cronKey].name}"`,
|
|
18
|
-
);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
},
|
|
22
|
-
add: function (name = 'task', expression = '* * * * *', callback = async () => null) {
|
|
23
|
-
const args = { name, expression, valid: cron.validate(expression) };
|
|
24
|
-
this.data[name] = {
|
|
25
|
-
...args,
|
|
26
|
-
task: cron.schedule(expression, callback, {
|
|
27
|
-
scheduled: false,
|
|
28
|
-
timezone: process.env.TIME_ZONE || 'America/New_York',
|
|
29
|
-
name,
|
|
30
|
-
}),
|
|
31
|
-
};
|
|
32
|
-
},
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
export { CronManagement };
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|