underpost 2.7.83 → 2.7.92
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 +41 -1
- package/.github/workflows/pwa-microservices-template.page.yml +54 -0
- package/.vscode/settings.json +7 -0
- package/CHANGELOG.md +64 -16
- package/bin/cron.js +47 -0
- package/bin/db.js +60 -7
- package/bin/deploy.js +358 -26
- package/bin/file.js +18 -1
- package/bin/hwt.js +59 -0
- package/bin/index.js +1 -1
- package/bin/util.js +31 -1
- package/conf.js +46 -8
- package/docker-compose.yml +1 -1
- package/package.json +133 -133
- package/src/api/core/core.router.js +9 -9
- package/src/api/core/core.service.js +12 -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 +10 -8
- package/src/client/components/core/404.js +20 -0
- package/src/client/components/core/500.js +20 -0
- package/src/client/{ssr/common → components/core}/Alert.js +13 -11
- package/src/client/components/core/CommonJs.js +3 -0
- package/src/client/components/core/CssCore.js +30 -3
- package/src/client/components/core/Docs.js +110 -10
- package/src/client/components/core/LoadingAnimation.js +4 -2
- package/src/client/components/core/Modal.js +223 -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 +34 -5
- package/src/client/components/core/RichText.js +4 -2
- package/src/client/components/core/Translate.js +21 -5
- package/src/client/components/core/VanillaJs.js +2 -1
- package/src/client/components/core/WebComponent.js +44 -0
- package/src/client/components/core/Worker.js +15 -18
- package/src/client/components/default/MenuDefault.js +68 -0
- package/src/client/components/default/RoutesDefault.js +2 -0
- 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/ssr/Render.js +1 -6
- package/src/client/ssr/{components/body → body}/CacheControl.js +1 -1
- package/src/client/ssr/head/Production.js +1 -0
- package/src/client/ssr/head/Pwa.js +146 -0
- package/src/client/ssr/head/Seo.js +14 -0
- package/src/client/ssr/mailer/DefaultRecoverEmail.js +21 -0
- package/src/client/ssr/mailer/DefaultVerifyEmail.js +17 -0
- package/src/client/ssr/offline/NoNetworkConnection.js +65 -0
- package/src/client/ssr/pages/Test.js +196 -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 +44 -165
- package/src/db/DataBaseProvider.js +12 -1
- package/src/db/mongo/MongooseDB.js +0 -1
- package/src/mailer/EmailRender.js +2 -4
- package/src/mailer/MailerProvider.js +4 -1
- package/src/runtime/lampp/Lampp.js +9 -9
- package/src/server/backup.js +82 -70
- package/src/server/client-build.js +133 -155
- package/src/server/client-formatted.js +2 -4
- package/src/server/conf.js +114 -23
- package/src/server/crypto.js +91 -0
- package/src/server/dns.js +48 -16
- package/src/server/network.js +94 -7
- package/src/server/proxy.js +26 -28
- package/src/server/runtime.js +42 -12
- package/src/server/ssl.js +2 -2
- package/src/client/ssr/common/SsrCore.js +0 -91
- package/src/client/ssr/common/Translate.js +0 -26
- package/src/client/ssr/common/Worker.js +0 -28
- package/src/client/ssr/components/head/PwaDefault.js +0 -60
- package/src/client/ssr/offline/default.index.js +0 -31
- package/src/cron.js +0 -30
- package/src/server/cron.js +0 -35
- /package/src/client/ssr/{components/body → body}/DefaultSplashScreen.js +0 -0
- /package/src/client/ssr/{components/email → email}/DefaultRecoverEmail.js +0 -0
- /package/src/client/ssr/{components/email → email}/DefaultVerifyEmail.js +0 -0
- /package/src/client/ssr/{components/head → head}/Css.js +0 -0
- /package/src/client/ssr/{components/head → head}/DefaultScripts.js +0 -0
package/src/server/proxy.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
import express from 'express';
|
|
4
|
-
import fs from 'fs-extra';
|
|
5
4
|
import dotenv from 'dotenv';
|
|
6
5
|
|
|
7
6
|
import { createProxyMiddleware } from 'http-proxy-middleware';
|
|
@@ -9,7 +8,7 @@ import { loggerFactory, loggerMiddleware } from './logger.js';
|
|
|
9
8
|
import { listenPortController, network } from './network.js';
|
|
10
9
|
import { orderArrayFromAttrInt } from '../client/components/core/CommonJs.js';
|
|
11
10
|
import { createSslServer, sslRedirectMiddleware } from './ssl.js';
|
|
12
|
-
import { buildProxyRouter } from './conf.js';
|
|
11
|
+
import { buildProxyRouter, maintenanceMiddleware } from './conf.js';
|
|
13
12
|
|
|
14
13
|
dotenv.config();
|
|
15
14
|
|
|
@@ -25,6 +24,9 @@ const buildProxy = async () => {
|
|
|
25
24
|
for (let port of Object.keys(proxyRouter)) {
|
|
26
25
|
port = parseInt(port);
|
|
27
26
|
const hosts = proxyRouter[port];
|
|
27
|
+
const proxyPath = '/';
|
|
28
|
+
const proxyHost = 'localhost';
|
|
29
|
+
const runningData = { host: proxyHost, path: proxyPath, client: null, runtime: 'nodejs', meta: import.meta };
|
|
28
30
|
const app = express();
|
|
29
31
|
|
|
30
32
|
// set logger
|
|
@@ -47,6 +49,7 @@ const buildProxy = async () => {
|
|
|
47
49
|
onProxyReq: (proxyReq, req, res, options) => {
|
|
48
50
|
// https://wtools.io/check-http-status-code
|
|
49
51
|
// http://nexodev.org
|
|
52
|
+
maintenanceMiddleware(req, res, port, proxyRouter);
|
|
50
53
|
sslRedirectMiddleware(req, res, port, proxyRouter);
|
|
51
54
|
},
|
|
52
55
|
pathRewrite: {
|
|
@@ -54,30 +57,27 @@ const buildProxy = async () => {
|
|
|
54
57
|
// '^/target-path': '/',
|
|
55
58
|
},
|
|
56
59
|
};
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
// instance proxy server
|
|
79
|
-
const proxyPath = '/';
|
|
80
|
-
const proxyHost = 'localhost';
|
|
60
|
+
if (!process.argv.includes('maintenance')) {
|
|
61
|
+
// build router
|
|
62
|
+
Object.keys(hosts).map((hostKey) => {
|
|
63
|
+
let { host, path, target, proxy, peer } = hosts[hostKey];
|
|
64
|
+
if (process.env.NODE_ENV === 'development') host = `localhost`;
|
|
65
|
+
|
|
66
|
+
if (!proxy.includes(port)) return;
|
|
67
|
+
const absoluteHost = [80, 443].includes(port)
|
|
68
|
+
? `${host}${path === '/' ? '' : path}`
|
|
69
|
+
: `${host}:${port}${path === '/' ? '' : path}`;
|
|
70
|
+
|
|
71
|
+
if (!(absoluteHost in options.router)) options.router[absoluteHost] = target;
|
|
72
|
+
});
|
|
73
|
+
if (Object.keys(options.router).length === 0) continue;
|
|
74
|
+
|
|
75
|
+
// order router
|
|
76
|
+
const router = {};
|
|
77
|
+
for (const absoluteHostKey of orderArrayFromAttrInt(Object.keys(options.router), 'length'))
|
|
78
|
+
router[absoluteHostKey] = options.router[absoluteHostKey];
|
|
79
|
+
options.router = router;
|
|
80
|
+
}
|
|
81
81
|
|
|
82
82
|
const filter = false
|
|
83
83
|
? (pathname, req) => {
|
|
@@ -88,8 +88,6 @@ const buildProxy = async () => {
|
|
|
88
88
|
app.use(proxyPath, createProxyMiddleware(filter, options));
|
|
89
89
|
await network.port.portClean(port);
|
|
90
90
|
|
|
91
|
-
const runningData = { host: proxyHost, path: proxyPath, client: null, runtime: 'nodejs', meta: import.meta };
|
|
92
|
-
|
|
93
91
|
switch (process.env.NODE_ENV) {
|
|
94
92
|
case 'production':
|
|
95
93
|
switch (port) {
|
package/src/server/runtime.js
CHANGED
|
@@ -11,20 +11,22 @@ import { createServer } from 'http';
|
|
|
11
11
|
import { getRootDirectory } from './process.js';
|
|
12
12
|
import { network, listenPortController, saveRuntimeRouter, logRuntimeRouter, listenServerFactory } from './network.js';
|
|
13
13
|
import { loggerFactory, loggerMiddleware } from './logger.js';
|
|
14
|
-
import { newInstance } from '../client/components/core/CommonJs.js';
|
|
14
|
+
import { getCapVariableName, newInstance } from '../client/components/core/CommonJs.js';
|
|
15
15
|
import { Xampp } from '../runtime/xampp/Xampp.js';
|
|
16
16
|
import { MailerProvider } from '../mailer/MailerProvider.js';
|
|
17
17
|
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';
|
|
22
|
+
import { ssrFactory } from './client-formatted.js';
|
|
21
23
|
|
|
22
24
|
dotenv.config();
|
|
23
25
|
|
|
24
26
|
const logger = loggerFactory(import.meta);
|
|
25
27
|
|
|
26
28
|
const buildRuntime = async () => {
|
|
27
|
-
const deployId =
|
|
29
|
+
const deployId = getDeployId();
|
|
28
30
|
|
|
29
31
|
const collectDefaultMetrics = promClient.collectDefaultMetrics;
|
|
30
32
|
collectDefaultMetrics();
|
|
@@ -57,6 +59,7 @@ export PATH=$PATH:/opt/lampp/bin`,
|
|
|
57
59
|
const initPort = parseInt(process.env.PORT) + 1;
|
|
58
60
|
let currentPort = initPort;
|
|
59
61
|
const confServer = JSON.parse(fs.readFileSync(`./conf/conf.server.json`, 'utf8'));
|
|
62
|
+
const confSSR = JSON.parse(fs.readFileSync(`./conf/conf.ssr.json`, 'utf8'));
|
|
60
63
|
const singleReplicaHosts = [];
|
|
61
64
|
for (const host of Object.keys(confServer)) {
|
|
62
65
|
if (singleReplicaHosts.length > 0 && !singleReplicaHosts.includes(host)) {
|
|
@@ -95,6 +98,7 @@ export PATH=$PATH:/opt/lampp/bin`,
|
|
|
95
98
|
runtime,
|
|
96
99
|
client,
|
|
97
100
|
meta: import.meta,
|
|
101
|
+
apis,
|
|
98
102
|
};
|
|
99
103
|
|
|
100
104
|
let redirectUrl;
|
|
@@ -308,7 +312,7 @@ export PATH=$PATH:/opt/lampp/bin`,
|
|
|
308
312
|
app.use(fileUpload());
|
|
309
313
|
|
|
310
314
|
// json formatted response
|
|
311
|
-
app.set('json spaces', 2);
|
|
315
|
+
if (process.env.NODE_ENV === 'development') app.set('json spaces', 2);
|
|
312
316
|
|
|
313
317
|
// lang handling middleware
|
|
314
318
|
app.use(function (req, res, next) {
|
|
@@ -325,7 +329,7 @@ export PATH=$PATH:/opt/lampp/bin`,
|
|
|
325
329
|
apis && process.env.NODE_ENV === 'development' ? [`http://localhost:${currentPort + 2}`] : [],
|
|
326
330
|
),
|
|
327
331
|
};
|
|
328
|
-
logger.info('originPayload', originPayload);
|
|
332
|
+
// logger.info('originPayload', originPayload);
|
|
329
333
|
app.use(cors(originPayload));
|
|
330
334
|
|
|
331
335
|
if (redirect) {
|
|
@@ -363,15 +367,17 @@ export PATH=$PATH:/opt/lampp/bin`,
|
|
|
363
367
|
|
|
364
368
|
if (db && apis) await DataBaseProvider.load({ apis, host, path, db });
|
|
365
369
|
|
|
366
|
-
if (mailer)
|
|
370
|
+
if (mailer) {
|
|
371
|
+
const mailerSsrConf = confSSR[getCapVariableName(client)];
|
|
367
372
|
await MailerProvider.load({
|
|
368
373
|
id: `${host}${path}`,
|
|
369
374
|
meta: `mailer-${host}${path}`,
|
|
370
375
|
host,
|
|
371
376
|
path,
|
|
372
377
|
...mailer,
|
|
378
|
+
templates: mailerSsrConf ? mailerSsrConf.mailer : {},
|
|
373
379
|
});
|
|
374
|
-
|
|
380
|
+
}
|
|
375
381
|
if (apis) {
|
|
376
382
|
const apiPath = `${path === '/' ? '' : path}/${process.env.BASE_API}`;
|
|
377
383
|
for (const api of apis)
|
|
@@ -383,17 +389,41 @@ export PATH=$PATH:/opt/lampp/bin`,
|
|
|
383
389
|
app.use(`${apiPath}/${api}`, router);
|
|
384
390
|
})();
|
|
385
391
|
}
|
|
392
|
+
|
|
393
|
+
const Render = await ssrFactory();
|
|
394
|
+
const ssrPath = path === '/' ? path : `${path}/`;
|
|
395
|
+
|
|
396
|
+
const defaultHtmlSrc404 = Render({
|
|
397
|
+
title: '404 Not Found',
|
|
398
|
+
ssrPath,
|
|
399
|
+
ssrHeadComponents: '',
|
|
400
|
+
ssrBodyComponents: (await ssrFactory(`./src/client/ssr/body/404.js`))(),
|
|
401
|
+
});
|
|
402
|
+
const path404 = `${directory ? directory : `${getRootDirectory()}${rootHostPath}`}/404/index.html`;
|
|
403
|
+
const page404 = fs.existsSync(path404) ? `${path === '/' ? '' : path}/404` : undefined;
|
|
386
404
|
app.use(function (req, res, next) {
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
405
|
+
if (page404) return res.status(404).redirect(page404);
|
|
406
|
+
else {
|
|
407
|
+
res.set('Content-Type', 'text/html');
|
|
408
|
+
return res.status(404).send(defaultHtmlSrc404);
|
|
409
|
+
}
|
|
390
410
|
});
|
|
391
411
|
|
|
412
|
+
const defaultHtmlSrc500 = Render({
|
|
413
|
+
title: '500 Server Error',
|
|
414
|
+
ssrPath,
|
|
415
|
+
ssrHeadComponents: '',
|
|
416
|
+
ssrBodyComponents: (await ssrFactory(`./src/client/ssr/body/500.js`))(),
|
|
417
|
+
});
|
|
418
|
+
const path500 = `${directory ? directory : `${getRootDirectory()}${rootHostPath}`}/500/index.html`;
|
|
419
|
+
const page500 = fs.existsSync(path500) ? `${path === '/' ? '' : path}/500` : undefined;
|
|
392
420
|
app.use(function (err, req, res, next) {
|
|
393
421
|
logger.error(err, err.stack);
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
422
|
+
if (page500) return res.status(500).redirect(page500);
|
|
423
|
+
else {
|
|
424
|
+
res.set('Content-Type', 'text/html');
|
|
425
|
+
return res.status(500).send(defaultHtmlSrc500);
|
|
426
|
+
}
|
|
397
427
|
});
|
|
398
428
|
|
|
399
429
|
// instance server
|
package/src/server/ssl.js
CHANGED
|
@@ -16,7 +16,7 @@ const buildSSL = async (host) => {
|
|
|
16
16
|
const files = await fs.readdir(sslPath);
|
|
17
17
|
|
|
18
18
|
for (const folderHost of files)
|
|
19
|
-
if (folderHost.match(host.split('/')[0])) {
|
|
19
|
+
if (folderHost.match(host.split('/')[0]) && host.split('.')[0] === folderHost.split('.')[0]) {
|
|
20
20
|
for (const i of [''].concat(range(1, 10))) {
|
|
21
21
|
const privateKeyPath = `${sslPath}/${folderHost}/privkey${i}.pem`;
|
|
22
22
|
const certificatePath = `${sslPath}/${folderHost}/cert${i}.pem`;
|
|
@@ -51,7 +51,7 @@ const buildSSL = async (host) => {
|
|
|
51
51
|
fs.writeFileSync(`./engine-private/ssl/${host}/_ca_bundle.crt`, ca, 'utf8');
|
|
52
52
|
fs.writeFileSync(`./engine-private/ssl/${host}/_ca_full_bundle.crt`, caFull, 'utf8');
|
|
53
53
|
|
|
54
|
-
|
|
54
|
+
fs.removeSync(`${sslPath}/${folderHost}`);
|
|
55
55
|
return true;
|
|
56
56
|
}
|
|
57
57
|
}
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
const s = (el) => document.querySelector(el);
|
|
2
|
-
|
|
3
|
-
const append = (el, html) => s(el).insertAdjacentHTML('beforeend', html);
|
|
4
|
-
|
|
5
|
-
const htmls = (el, html) => (s(el).innerHTML = html);
|
|
6
|
-
|
|
7
|
-
const s4 = () => (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1);
|
|
8
|
-
|
|
9
|
-
const range = (start, end) => {
|
|
10
|
-
return end < start
|
|
11
|
-
? range(end, start).reverse()
|
|
12
|
-
: Array.apply(0, Array(end - start + 1)).map((element, index) => index + start);
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
const timer = (ms) => new Promise((res) => setTimeout(res, ms));
|
|
16
|
-
|
|
17
|
-
const newInstance = (obj) => {
|
|
18
|
-
// structuredClone() 2022 ES6 feature
|
|
19
|
-
try {
|
|
20
|
-
return JSON.parse(JSON.stringify(obj));
|
|
21
|
-
} catch (error) {
|
|
22
|
-
return { error: error.message };
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
const fullScreenIn = () => {
|
|
27
|
-
const elem = document.documentElement;
|
|
28
|
-
if (elem.requestFullscreen) {
|
|
29
|
-
elem.requestFullscreen();
|
|
30
|
-
} else if (elem.mozRequestFullScreen) {
|
|
31
|
-
/* Firefox */
|
|
32
|
-
elem.mozRequestFullScreen();
|
|
33
|
-
} else if (elem.webkitRequestFullscreen) {
|
|
34
|
-
/* Chrome, Safari & Opera */
|
|
35
|
-
elem.webkitRequestFullscreen();
|
|
36
|
-
} else if (elem.msRequestFullscreen) {
|
|
37
|
-
/* IE/Edge */
|
|
38
|
-
elem = window.top.document.body; //To break out of frame in IE
|
|
39
|
-
elem.msRequestFullscreen();
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
const borderChar = (px, color, selectors) => {
|
|
44
|
-
if (selectors) {
|
|
45
|
-
return selectors
|
|
46
|
-
.map(
|
|
47
|
-
(selector) => html`
|
|
48
|
-
<style>
|
|
49
|
-
${selector} {
|
|
50
|
-
text-shadow: ${px}px -${px}px ${px}px ${color}, -${px}px ${px}px ${px}px ${color},
|
|
51
|
-
-${px}px -${px}px ${px}px ${color}, ${px}px ${px}px ${px}px ${color};
|
|
52
|
-
}
|
|
53
|
-
</style>
|
|
54
|
-
`,
|
|
55
|
-
)
|
|
56
|
-
.join('');
|
|
57
|
-
}
|
|
58
|
-
return html`
|
|
59
|
-
text-shadow: ${px}px -${px}px ${px}px ${color}, -${px}px ${px}px ${px}px ${color}, -${px}px -${px}px ${px}px
|
|
60
|
-
${color}, ${px}px ${px}px ${px}px ${color};
|
|
61
|
-
`;
|
|
62
|
-
};
|
|
63
|
-
const getLang = () =>
|
|
64
|
-
localStorage.getItem('lang') ? localStorage.getItem('lang') : navigator.language || navigator.userLanguage;
|
|
65
|
-
|
|
66
|
-
const loggerFactory = (meta) => {
|
|
67
|
-
meta = meta.url.split('/').pop();
|
|
68
|
-
const types = ['error', 'warn', 'info', 'debug'];
|
|
69
|
-
const logger = {
|
|
70
|
-
log: function (type, args) {
|
|
71
|
-
if (location.hostname !== 'localhost' && console.log() !== null) {
|
|
72
|
-
console.log = () => null;
|
|
73
|
-
console.error = () => null;
|
|
74
|
-
console.info = () => null;
|
|
75
|
-
console.warn = () => null;
|
|
76
|
-
}
|
|
77
|
-
return location.hostname === 'localhost'
|
|
78
|
-
? console[type](`[${meta}] ${new Date().toISOString()} ${type}:`, ...args)
|
|
79
|
-
: null;
|
|
80
|
-
},
|
|
81
|
-
};
|
|
82
|
-
types.map(
|
|
83
|
-
(type) =>
|
|
84
|
-
(logger[type] = function (...args) {
|
|
85
|
-
return this.log(type, args);
|
|
86
|
-
}),
|
|
87
|
-
);
|
|
88
|
-
return logger;
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
export { getLang, s, append, s4, range, timer, htmls, newInstance, fullScreenIn, borderChar, loggerFactory };
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
const TranslateCore = {
|
|
2
|
-
['server-maintenance']: {
|
|
3
|
-
en: "The server is under maintenance <br> we'll be back soon.",
|
|
4
|
-
es: 'El servidor está en mantenimiento <br> volveremos pronto.',
|
|
5
|
-
},
|
|
6
|
-
['no-internet-connection']: {
|
|
7
|
-
en: 'No internet connection <br> verify your network',
|
|
8
|
-
es: 'Sin conexión a internet <br> verifica tu red',
|
|
9
|
-
},
|
|
10
|
-
['page-not-found']: {
|
|
11
|
-
en: 'Page not found',
|
|
12
|
-
es: 'Página no encontrada',
|
|
13
|
-
},
|
|
14
|
-
['page-broken']: {
|
|
15
|
-
es: 'Algo salio mal',
|
|
16
|
-
en: 'Something went wrong',
|
|
17
|
-
},
|
|
18
|
-
['back']: {
|
|
19
|
-
en: 'Back to <br> homepage',
|
|
20
|
-
es: 'Volver a <br> la pagina principal',
|
|
21
|
-
},
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
const Translate = (key) => TranslateCore[key][getLang().match('es') ? 'es' : 'en'];
|
|
25
|
-
|
|
26
|
-
export { Translate };
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
const Worker = {
|
|
2
|
-
instance: async function (options = { render: async () => {} }) {
|
|
3
|
-
window.serviceWorkerReady = true;
|
|
4
|
-
append(
|
|
5
|
-
'body',
|
|
6
|
-
html`
|
|
7
|
-
<style>
|
|
8
|
-
body {
|
|
9
|
-
background-color: #dcdcdc;
|
|
10
|
-
color: #303030;
|
|
11
|
-
font-family: arial;
|
|
12
|
-
font-size: 16px;
|
|
13
|
-
}
|
|
14
|
-
.page-render {
|
|
15
|
-
min-height: 100vh;
|
|
16
|
-
}
|
|
17
|
-
a {
|
|
18
|
-
color: #000000;
|
|
19
|
-
}
|
|
20
|
-
</style>
|
|
21
|
-
<div class="in page-render"></div>
|
|
22
|
-
`,
|
|
23
|
-
);
|
|
24
|
-
await options.render();
|
|
25
|
-
},
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
export { Worker };
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
SrrComponent = () => html`<link rel="icon" type="image/x-icon" href="/favicon.ico">
|
|
2
|
-
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
|
|
3
|
-
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
|
|
4
|
-
<link rel="icon" type="image/png" sizes="48x48" href="/favicon-48x48.png">
|
|
5
|
-
<link rel="manifest" href="/manifest.webmanifest" crossOrigin="use-credentials">
|
|
6
|
-
<meta name="mobile-web-app-capable" content="yes">
|
|
7
|
-
<meta name="theme-color" content="#fff">
|
|
8
|
-
<meta name="application-name" content="Default">
|
|
9
|
-
<link rel="apple-touch-icon" sizes="57x57" href="/apple-touch-icon-57x57.png">
|
|
10
|
-
<link rel="apple-touch-icon" sizes="60x60" href="/apple-touch-icon-60x60.png">
|
|
11
|
-
<link rel="apple-touch-icon" sizes="72x72" href="/apple-touch-icon-72x72.png">
|
|
12
|
-
<link rel="apple-touch-icon" sizes="76x76" href="/apple-touch-icon-76x76.png">
|
|
13
|
-
<link rel="apple-touch-icon" sizes="114x114" href="/apple-touch-icon-114x114.png">
|
|
14
|
-
<link rel="apple-touch-icon" sizes="120x120" href="/apple-touch-icon-120x120.png">
|
|
15
|
-
<link rel="apple-touch-icon" sizes="144x144" href="/apple-touch-icon-144x144.png">
|
|
16
|
-
<link rel="apple-touch-icon" sizes="152x152" href="/apple-touch-icon-152x152.png">
|
|
17
|
-
<link rel="apple-touch-icon" sizes="167x167" href="/apple-touch-icon-167x167.png">
|
|
18
|
-
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon-180x180.png">
|
|
19
|
-
<link rel="apple-touch-icon" sizes="1024x1024" href="/apple-touch-icon-1024x1024.png">
|
|
20
|
-
<meta name="apple-mobile-web-app-capable" content="yes">
|
|
21
|
-
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
|
|
22
|
-
<meta name="apple-mobile-web-app-title" content="Default">
|
|
23
|
-
<link rel="apple-touch-startup-image" media="(device-width: 320px) and (device-height: 568px) and (-webkit-device-pixel-ratio: 2) and (orientation: portrait)" href="/apple-touch-startup-image-640x1136.png">
|
|
24
|
-
<link rel="apple-touch-startup-image" media="(device-width: 320px) and (device-height: 568px) and (-webkit-device-pixel-ratio: 2) and (orientation: landscape)" href="/apple-touch-startup-image-1136x640.png">
|
|
25
|
-
<link rel="apple-touch-startup-image" media="(device-width: 375px) and (device-height: 667px) and (-webkit-device-pixel-ratio: 2) and (orientation: portrait)" href="/apple-touch-startup-image-750x1334.png">
|
|
26
|
-
<link rel="apple-touch-startup-image" media="(device-width: 375px) and (device-height: 667px) and (-webkit-device-pixel-ratio: 2) and (orientation: landscape)" href="/apple-touch-startup-image-1334x750.png">
|
|
27
|
-
<link rel="apple-touch-startup-image" media="(device-width: 375px) and (device-height: 812px) and (-webkit-device-pixel-ratio: 3) and (orientation: portrait)" href="/apple-touch-startup-image-1125x2436.png">
|
|
28
|
-
<link rel="apple-touch-startup-image" media="(device-width: 375px) and (device-height: 812px) and (-webkit-device-pixel-ratio: 3) and (orientation: landscape)" href="/apple-touch-startup-image-2436x1125.png">
|
|
29
|
-
<link rel="apple-touch-startup-image" media="(device-width: 390px) and (device-height: 844px) and (-webkit-device-pixel-ratio: 3) and (orientation: portrait)" href="/apple-touch-startup-image-1170x2532.png">
|
|
30
|
-
<link rel="apple-touch-startup-image" media="(device-width: 390px) and (device-height: 844px) and (-webkit-device-pixel-ratio: 3) and (orientation: landscape)" href="/apple-touch-startup-image-2532x1170.png">
|
|
31
|
-
<link rel="apple-touch-startup-image" media="(device-width: 393px) and (device-height: 852px) and (-webkit-device-pixel-ratio: 3) and (orientation: portrait)" href="/apple-touch-startup-image-1179x2556.png">
|
|
32
|
-
<link rel="apple-touch-startup-image" media="(device-width: 393px) and (device-height: 852px) and (-webkit-device-pixel-ratio: 3) and (orientation: landscape)" href="/apple-touch-startup-image-2556x1179.png">
|
|
33
|
-
<link rel="apple-touch-startup-image" media="(device-width: 414px) and (device-height: 896px) and (-webkit-device-pixel-ratio: 2) and (orientation: portrait)" href="/apple-touch-startup-image-828x1792.png">
|
|
34
|
-
<link rel="apple-touch-startup-image" media="(device-width: 414px) and (device-height: 896px) and (-webkit-device-pixel-ratio: 2) and (orientation: landscape)" href="/apple-touch-startup-image-1792x828.png">
|
|
35
|
-
<link rel="apple-touch-startup-image" media="(device-width: 414px) and (device-height: 896px) and (-webkit-device-pixel-ratio: 3) and (orientation: portrait)" href="/apple-touch-startup-image-1242x2688.png">
|
|
36
|
-
<link rel="apple-touch-startup-image" media="(device-width: 414px) and (device-height: 896px) and (-webkit-device-pixel-ratio: 3) and (orientation: landscape)" href="/apple-touch-startup-image-2688x1242.png">
|
|
37
|
-
<link rel="apple-touch-startup-image" media="(device-width: 414px) and (device-height: 736px) and (-webkit-device-pixel-ratio: 3) and (orientation: portrait)" href="/apple-touch-startup-image-1242x2208.png">
|
|
38
|
-
<link rel="apple-touch-startup-image" media="(device-width: 414px) and (device-height: 736px) and (-webkit-device-pixel-ratio: 3) and (orientation: landscape)" href="/apple-touch-startup-image-2208x1242.png">
|
|
39
|
-
<link rel="apple-touch-startup-image" media="(device-width: 428px) and (device-height: 926px) and (-webkit-device-pixel-ratio: 3) and (orientation: portrait)" href="/apple-touch-startup-image-1284x2778.png">
|
|
40
|
-
<link rel="apple-touch-startup-image" media="(device-width: 428px) and (device-height: 926px) and (-webkit-device-pixel-ratio: 3) and (orientation: landscape)" href="/apple-touch-startup-image-2778x1284.png">
|
|
41
|
-
<link rel="apple-touch-startup-image" media="(device-width: 430px) and (device-height: 932px) and (-webkit-device-pixel-ratio: 3) and (orientation: portrait)" href="/apple-touch-startup-image-1290x2796.png">
|
|
42
|
-
<link rel="apple-touch-startup-image" media="(device-width: 430px) and (device-height: 932px) and (-webkit-device-pixel-ratio: 3) and (orientation: landscape)" href="/apple-touch-startup-image-2796x1290.png">
|
|
43
|
-
<link rel="apple-touch-startup-image" media="(device-width: 744px) and (device-height: 1133px) and (-webkit-device-pixel-ratio: 2) and (orientation: portrait)" href="/apple-touch-startup-image-1488x2266.png">
|
|
44
|
-
<link rel="apple-touch-startup-image" media="(device-width: 744px) and (device-height: 1133px) and (-webkit-device-pixel-ratio: 2) and (orientation: landscape)" href="/apple-touch-startup-image-2266x1488.png">
|
|
45
|
-
<link rel="apple-touch-startup-image" media="(device-width: 768px) and (device-height: 1024px) and (-webkit-device-pixel-ratio: 2) and (orientation: portrait)" href="/apple-touch-startup-image-1536x2048.png">
|
|
46
|
-
<link rel="apple-touch-startup-image" media="(device-width: 768px) and (device-height: 1024px) and (-webkit-device-pixel-ratio: 2) and (orientation: landscape)" href="/apple-touch-startup-image-2048x1536.png">
|
|
47
|
-
<link rel="apple-touch-startup-image" media="(device-width: 810px) and (device-height: 1080px) and (-webkit-device-pixel-ratio: 2) and (orientation: portrait)" href="/apple-touch-startup-image-1620x2160.png">
|
|
48
|
-
<link rel="apple-touch-startup-image" media="(device-width: 810px) and (device-height: 1080px) and (-webkit-device-pixel-ratio: 2) and (orientation: landscape)" href="/apple-touch-startup-image-2160x1620.png">
|
|
49
|
-
<link rel="apple-touch-startup-image" media="(device-width: 820px) and (device-height: 1080px) and (-webkit-device-pixel-ratio: 2) and (orientation: portrait)" href="/apple-touch-startup-image-1640x2160.png">
|
|
50
|
-
<link rel="apple-touch-startup-image" media="(device-width: 820px) and (device-height: 1080px) and (-webkit-device-pixel-ratio: 2) and (orientation: landscape)" href="/apple-touch-startup-image-2160x1640.png">
|
|
51
|
-
<link rel="apple-touch-startup-image" media="(device-width: 834px) and (device-height: 1194px) and (-webkit-device-pixel-ratio: 2) and (orientation: portrait)" href="/apple-touch-startup-image-1668x2388.png">
|
|
52
|
-
<link rel="apple-touch-startup-image" media="(device-width: 834px) and (device-height: 1194px) and (-webkit-device-pixel-ratio: 2) and (orientation: landscape)" href="/apple-touch-startup-image-2388x1668.png">
|
|
53
|
-
<link rel="apple-touch-startup-image" media="(device-width: 834px) and (device-height: 1112px) and (-webkit-device-pixel-ratio: 2) and (orientation: portrait)" href="/apple-touch-startup-image-1668x2224.png">
|
|
54
|
-
<link rel="apple-touch-startup-image" media="(device-width: 834px) and (device-height: 1112px) and (-webkit-device-pixel-ratio: 2) and (orientation: landscape)" href="/apple-touch-startup-image-2224x1668.png">
|
|
55
|
-
<link rel="apple-touch-startup-image" media="(device-width: 1024px) and (device-height: 1366px) and (-webkit-device-pixel-ratio: 2) and (orientation: portrait)" href="/apple-touch-startup-image-2048x2732.png">
|
|
56
|
-
<link rel="apple-touch-startup-image" media="(device-width: 1024px) and (device-height: 1366px) and (-webkit-device-pixel-ratio: 2) and (orientation: landscape)" href="/apple-touch-startup-image-2732x2048.png">
|
|
57
|
-
<meta name="msapplication-TileColor" content="#fff">
|
|
58
|
-
<meta name="msapplication-TileImage" content="/mstile-144x144.png">
|
|
59
|
-
<meta name="msapplication-config" content="/browserconfig.xml">
|
|
60
|
-
<link rel="yandex-tableau-widget" href="/yandex-browser-manifest.json">`;
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { htmls, loggerFactory } from '../common/SsrCore.js';
|
|
2
|
-
import { Alert } from '../common/Alert.js';
|
|
3
|
-
import { Translate } from '../common/Translate.js';
|
|
4
|
-
import { Worker } from '../common/Worker.js';
|
|
5
|
-
/*imports*/
|
|
6
|
-
|
|
7
|
-
const logger = loggerFactory({ url: '/offline.js' });
|
|
8
|
-
|
|
9
|
-
window.onload = () =>
|
|
10
|
-
Worker.instance({
|
|
11
|
-
render: async () => {
|
|
12
|
-
window.ononline = async () => {
|
|
13
|
-
location.href = '/';
|
|
14
|
-
};
|
|
15
|
-
window.onoffline = async () => {
|
|
16
|
-
htmls(`.page-render`, html`${await Alert.noInternet({ Translate })}`);
|
|
17
|
-
};
|
|
18
|
-
try {
|
|
19
|
-
if (navigator.onLine) {
|
|
20
|
-
const maintenance = await fetch(location.origin + '/favicon.ico');
|
|
21
|
-
if (maintenance.status !== 200) {
|
|
22
|
-
htmls(`.page-render`, html`${await Alert.maintenance({ Translate })}`);
|
|
23
|
-
} else window.ononline();
|
|
24
|
-
}
|
|
25
|
-
throw new Error(`no internet connection`);
|
|
26
|
-
} catch (error) {
|
|
27
|
-
logger.error(error);
|
|
28
|
-
window.onoffline();
|
|
29
|
-
}
|
|
30
|
-
},
|
|
31
|
-
});
|
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
|