@underpostnet/underpost 2.7.91 → 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.
Files changed (50) hide show
  1. package/bin/deploy.js +13 -11
  2. package/bin/file.js +1 -0
  3. package/bin/hwt.js +59 -0
  4. package/bin/index.js +1 -1
  5. package/conf.js +28 -4
  6. package/docker-compose.yml +1 -1
  7. package/package.json +2 -2
  8. package/src/client/components/core/404.js +20 -0
  9. package/src/client/components/core/500.js +20 -0
  10. package/src/client/{ssr/common → components/core}/Alert.js +13 -11
  11. package/src/client/components/core/Docs.js +1 -1
  12. package/src/client/components/core/Modal.js +5 -6
  13. package/src/client/components/core/Translate.js +21 -5
  14. package/src/client/components/core/VanillaJs.js +2 -1
  15. package/src/client/components/core/Worker.js +10 -11
  16. package/src/client/components/default/MenuDefault.js +68 -0
  17. package/src/client/components/default/RoutesDefault.js +2 -0
  18. package/src/client/public/default/plantuml/client-conf.svg +1 -1
  19. package/src/client/public/default/plantuml/client-schema.svg +1 -1
  20. package/src/client/public/default/plantuml/cron-schema.svg +1 -1
  21. package/src/client/public/default/plantuml/server-conf.svg +1 -1
  22. package/src/client/public/default/plantuml/server-schema.svg +1 -1
  23. package/src/client/public/default/plantuml/ssr-conf.svg +1 -1
  24. package/src/client/public/default/plantuml/ssr-schema.svg +1 -1
  25. package/src/client/ssr/Render.js +1 -6
  26. package/src/client/ssr/{components/body → body}/CacheControl.js +1 -1
  27. package/src/client/ssr/mailer/DefaultRecoverEmail.js +21 -0
  28. package/src/client/ssr/mailer/DefaultVerifyEmail.js +17 -0
  29. package/src/client/ssr/offline/NoNetworkConnection.js +65 -0
  30. package/src/client/ssr/pages/Test.js +196 -0
  31. package/src/client/sw/default.sw.js +43 -166
  32. package/src/mailer/EmailRender.js +2 -4
  33. package/src/mailer/MailerProvider.js +4 -1
  34. package/src/server/client-build.js +100 -74
  35. package/src/server/client-formatted.js +2 -4
  36. package/src/server/conf.js +40 -13
  37. package/src/server/proxy.js +0 -2
  38. package/src/server/runtime.js +38 -10
  39. package/src/client/ssr/common/SsrCore.js +0 -91
  40. package/src/client/ssr/common/Translate.js +0 -26
  41. package/src/client/ssr/common/Worker.js +0 -28
  42. package/src/client/ssr/components/head/PwaDefault.js +0 -60
  43. /package/src/client/ssr/{components/body → body}/DefaultSplashScreen.js +0 -0
  44. /package/src/client/ssr/{components/email → email}/DefaultRecoverEmail.js +0 -0
  45. /package/src/client/ssr/{components/email → email}/DefaultVerifyEmail.js +0 -0
  46. /package/src/client/ssr/{components/head → head}/Css.js +0 -0
  47. /package/src/client/ssr/{components/head → head}/DefaultScripts.js +0 -0
  48. /package/src/client/ssr/{components/head → head}/Production.js +0 -0
  49. /package/src/client/ssr/{components/head → head}/Pwa.js +0 -0
  50. /package/src/client/ssr/{components/head → head}/Seo.js +0 -0
@@ -11,7 +11,7 @@ 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';
@@ -19,6 +19,7 @@ import { createProxyMiddleware } from 'http-proxy-middleware';
19
19
  import { createPeerServer } from './peer.js';
20
20
  import { Lampp } from '../runtime/lampp/Lampp.js';
21
21
  import { getDeployId } from './conf.js';
22
+ import { ssrFactory } from './client-formatted.js';
22
23
 
23
24
  dotenv.config();
24
25
 
@@ -58,6 +59,7 @@ export PATH=$PATH:/opt/lampp/bin`,
58
59
  const initPort = parseInt(process.env.PORT) + 1;
59
60
  let currentPort = initPort;
60
61
  const confServer = JSON.parse(fs.readFileSync(`./conf/conf.server.json`, 'utf8'));
62
+ const confSSR = JSON.parse(fs.readFileSync(`./conf/conf.ssr.json`, 'utf8'));
61
63
  const singleReplicaHosts = [];
62
64
  for (const host of Object.keys(confServer)) {
63
65
  if (singleReplicaHosts.length > 0 && !singleReplicaHosts.includes(host)) {
@@ -310,7 +312,7 @@ export PATH=$PATH:/opt/lampp/bin`,
310
312
  app.use(fileUpload());
311
313
 
312
314
  // json formatted response
313
- app.set('json spaces', 2);
315
+ if (process.env.NODE_ENV === 'development') app.set('json spaces', 2);
314
316
 
315
317
  // lang handling middleware
316
318
  app.use(function (req, res, next) {
@@ -365,15 +367,17 @@ export PATH=$PATH:/opt/lampp/bin`,
365
367
 
366
368
  if (db && apis) await DataBaseProvider.load({ apis, host, path, db });
367
369
 
368
- if (mailer)
370
+ if (mailer) {
371
+ const mailerSsrConf = confSSR[getCapVariableName(client)];
369
372
  await MailerProvider.load({
370
373
  id: `${host}${path}`,
371
374
  meta: `mailer-${host}${path}`,
372
375
  host,
373
376
  path,
374
377
  ...mailer,
378
+ templates: mailerSsrConf ? mailerSsrConf.mailer : {},
375
379
  });
376
-
380
+ }
377
381
  if (apis) {
378
382
  const apiPath = `${path === '/' ? '' : path}/${process.env.BASE_API}`;
379
383
  for (const api of apis)
@@ -385,17 +389,41 @@ export PATH=$PATH:/opt/lampp/bin`,
385
389
  app.use(`${apiPath}/${api}`, router);
386
390
  })();
387
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;
388
404
  app.use(function (req, res, next) {
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!');
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
+ }
392
410
  });
393
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;
394
420
  app.use(function (err, req, res, next) {
395
421
  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);
398
- res.status(500).send('Something broke!');
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
+ }
399
427
  });
400
428
 
401
429
  // instance server
@@ -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">`;
File without changes
File without changes
File without changes