underpost 2.8.637 → 2.8.646
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/bin/build.js +1 -1
- package/bin/deploy.js +2 -1
- package/bin/index.js +11 -9
- package/docker-compose.yml +1 -1
- package/package.json +2 -9
- package/src/api/default/default.service.js +1 -1
- package/src/api/user/user.service.js +1 -1
- package/src/cli/cron.js +39 -8
- package/src/cli/deploy.js +64 -11
- package/src/cli/image.js +0 -70
- package/src/cli/repository.js +5 -2
- package/src/client/components/core/Account.js +22 -18
- package/src/client/components/core/CalendarCore.js +13 -85
- package/src/client/components/core/CommonJs.js +2 -1
- package/src/client/components/core/EventsUI.js +2 -2
- package/src/client/components/core/FileExplorer.js +86 -78
- package/src/client/components/core/Modal.js +12 -7
- package/src/client/components/core/Panel.js +14 -56
- package/src/client/components/core/PanelForm.js +13 -24
- package/src/client/components/core/Router.js +3 -1
- package/src/client/components/default/RoutesDefault.js +3 -2
- package/src/client/services/default/default.management.js +45 -38
- package/src/index.js +11 -3
- package/src/server/dns.js +9 -1
- package/src/server/json-schema.js +77 -0
- package/src/server/network.js +7 -122
- package/src/server/peer.js +2 -2
- package/src/server/proxy.js +4 -4
- package/src/server/runtime.js +17 -11
- package/src/server/start.js +116 -0
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { loggerFactory } from '../core/Logger.js';
|
|
2
|
+
import { Modal } from '../core/Modal.js';
|
|
2
3
|
import { getProxyPath, s } from '../core/VanillaJs.js';
|
|
3
4
|
|
|
4
5
|
const logger = loggerFactory(import.meta);
|
|
@@ -10,10 +11,10 @@ const RoutesDefault = () => {
|
|
|
10
11
|
return {
|
|
11
12
|
'/': {
|
|
12
13
|
title: 'Home',
|
|
13
|
-
render: () =>
|
|
14
|
+
render: () => Modal.onHomeRouterEvent(),
|
|
14
15
|
upperCase: false,
|
|
15
16
|
},
|
|
16
|
-
'/home': { title: 'home', render: () =>
|
|
17
|
+
'/home': { title: 'home', render: () => Modal.onHomeRouterEvent() },
|
|
17
18
|
'/settings': { title: 'settings', render: () => s(`.main-btn-settings`).click(), translateTitle: true },
|
|
18
19
|
'/log-in': { title: 'log-in', render: () => s(`.main-btn-log-in`).click(), translateTitle: true },
|
|
19
20
|
'/sign-up': { title: 'sign-up', render: () => s(`.main-btn-sign-up`).click(), translateTitle: true },
|
|
@@ -80,36 +80,40 @@ const DefaultManagement = {
|
|
|
80
80
|
class: `in fll section-mp management-table-btn-mini management-table-btn-remove-${id}-${cellRenderId}`,
|
|
81
81
|
})}`;
|
|
82
82
|
setTimeout(() => {
|
|
83
|
-
EventsUI.onClick(
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
83
|
+
EventsUI.onClick(
|
|
84
|
+
`.management-table-btn-remove-${id}-${cellRenderId}`,
|
|
85
|
+
async () => {
|
|
86
|
+
const confirmResult = await Modal.RenderConfirm({
|
|
87
|
+
html: async () => {
|
|
88
|
+
return html`
|
|
89
|
+
<div class="in section-mp" style="text-align: center">
|
|
90
|
+
${Translate.Render('confirm-delete-item')}
|
|
91
|
+
${Object.keys(params.data).length > 0
|
|
92
|
+
? html`<br />
|
|
93
|
+
"${options.defaultColKeyFocus
|
|
94
|
+
? getValueFromJoinString(params.data, options.defaultColKeyFocus)
|
|
95
|
+
: params.data[Object.keys(params.data)[0]]}"`
|
|
96
|
+
: ''}
|
|
97
|
+
</div>
|
|
98
|
+
`;
|
|
99
|
+
},
|
|
100
|
+
id: `delete-${params.data._id}`,
|
|
101
|
+
});
|
|
102
|
+
if (confirmResult.status !== 'confirm') return;
|
|
103
|
+
let result;
|
|
104
|
+
if (params.data._id) result = await ServiceProvider.delete({ id: params.data._id });
|
|
105
|
+
else result = { status: 'success' };
|
|
104
106
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
107
|
+
NotificationManager.Push({
|
|
108
|
+
html: result.status === 'error' ? result.message : Translate.Render('item-success-delete'),
|
|
109
|
+
status: result.status,
|
|
110
|
+
});
|
|
111
|
+
if (result.status === 'success') {
|
|
112
|
+
AgGrid.grids[gridId].applyTransaction({ remove: [params.data] });
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
{ context: 'modal' },
|
|
116
|
+
);
|
|
113
117
|
});
|
|
114
118
|
}
|
|
115
119
|
|
|
@@ -220,16 +224,19 @@ const DefaultManagement = {
|
|
|
220
224
|
});
|
|
221
225
|
});
|
|
222
226
|
EventsUI.onClick(`.management-table-btn-clean-${id}`, async () => {
|
|
223
|
-
const confirmResult = await Modal.RenderConfirm(
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
<
|
|
228
|
-
|
|
229
|
-
|
|
227
|
+
const confirmResult = await Modal.RenderConfirm(
|
|
228
|
+
{
|
|
229
|
+
html: async () => {
|
|
230
|
+
return html`
|
|
231
|
+
<div class="in section-mp" style="text-align: center;">
|
|
232
|
+
<strong>${Translate.Render('confirm-delete-all-data')}</strong>
|
|
233
|
+
</div>
|
|
234
|
+
`;
|
|
235
|
+
},
|
|
236
|
+
id: `clean-table-${id}`,
|
|
230
237
|
},
|
|
231
|
-
|
|
232
|
-
|
|
238
|
+
{ context: 'modal' },
|
|
239
|
+
);
|
|
233
240
|
if (confirmResult.status === 'cancelled') return;
|
|
234
241
|
const result = await ServiceProvider.delete();
|
|
235
242
|
NotificationManager.Push({
|
package/src/index.js
CHANGED
|
@@ -16,6 +16,7 @@ import UnderpostRepository from './cli/repository.js';
|
|
|
16
16
|
import UnderpostScript from './cli/script.js';
|
|
17
17
|
import UnderpostSecret from './cli/secrets.js';
|
|
18
18
|
import UnderpostTest from './cli/test.js';
|
|
19
|
+
import UnderpostStartUp from './server/start.js';
|
|
19
20
|
|
|
20
21
|
/**
|
|
21
22
|
* Underpost main module methods
|
|
@@ -29,7 +30,7 @@ class Underpost {
|
|
|
29
30
|
* @type {String}
|
|
30
31
|
* @memberof Underpost
|
|
31
32
|
*/
|
|
32
|
-
static version = 'v2.8.
|
|
33
|
+
static version = 'v2.8.646';
|
|
33
34
|
/**
|
|
34
35
|
* Repository cli API
|
|
35
36
|
* @static
|
|
@@ -51,6 +52,13 @@ class Underpost {
|
|
|
51
52
|
* @memberof Underpost
|
|
52
53
|
*/
|
|
53
54
|
static test = UnderpostTest.API;
|
|
55
|
+
/**
|
|
56
|
+
* Underpost Start Up cli API
|
|
57
|
+
* @static
|
|
58
|
+
* @type {UnderpostStartUp.API}
|
|
59
|
+
* @memberof Underpost
|
|
60
|
+
*/
|
|
61
|
+
static start = UnderpostStartUp.API;
|
|
54
62
|
/**
|
|
55
63
|
* Cluster cli API
|
|
56
64
|
* @static
|
|
@@ -104,14 +112,14 @@ class Underpost {
|
|
|
104
112
|
* File Storage cli API
|
|
105
113
|
* @static
|
|
106
114
|
* @type {UnderpostFileStorage.API}
|
|
107
|
-
* @memberof
|
|
115
|
+
* @memberof Underpost
|
|
108
116
|
*/
|
|
109
117
|
static fs = UnderpostFileStorage.API;
|
|
110
118
|
/**
|
|
111
119
|
* Monitor cli API
|
|
112
120
|
* @static
|
|
113
121
|
* @type {UnderpostMonitor.API}
|
|
114
|
-
* @memberof
|
|
122
|
+
* @memberof Underpost
|
|
115
123
|
*/
|
|
116
124
|
static monitor = UnderpostMonitor.API;
|
|
117
125
|
}
|
package/src/server/dns.js
CHANGED
|
@@ -2,7 +2,7 @@ import axios from 'axios';
|
|
|
2
2
|
import dotenv from 'dotenv';
|
|
3
3
|
import fs from 'fs';
|
|
4
4
|
import validator from 'validator';
|
|
5
|
-
import {
|
|
5
|
+
import { publicIp, publicIpv4, publicIpv6 } from 'public-ip';
|
|
6
6
|
import { loggerFactory } from './logger.js';
|
|
7
7
|
import UnderpostRootEnv from '../cli/env.js';
|
|
8
8
|
|
|
@@ -10,6 +10,14 @@ dotenv.config();
|
|
|
10
10
|
|
|
11
11
|
const logger = loggerFactory(import.meta);
|
|
12
12
|
|
|
13
|
+
const ip = {
|
|
14
|
+
public: {
|
|
15
|
+
get: async () => await publicIp(), // => 'fe80::200:f8ff:fe21:67cf'
|
|
16
|
+
ipv4: async () => await publicIpv4(), // => '46.5.21.123'
|
|
17
|
+
ipv6: async () => await publicIpv6(), // => 'fe80::200:f8ff:fe21:67cf'
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
|
|
13
21
|
class Dns {
|
|
14
22
|
static callback = async function (deployList) {
|
|
15
23
|
// Network topology configuration:
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
function isPlainObject(obj) {
|
|
2
|
+
return obj ? typeof obj === 'object' && Object.getPrototypeOf(obj) === Object.prototype : false;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
const supportType = ['string', 'number', 'array', 'object', 'boolean', 'integer'];
|
|
6
|
+
|
|
7
|
+
function getType(type) {
|
|
8
|
+
if (!type) type = 'string';
|
|
9
|
+
if (supportType.indexOf(type) !== -1) {
|
|
10
|
+
return type;
|
|
11
|
+
}
|
|
12
|
+
return typeof type;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function isSchema(object) {
|
|
16
|
+
if (supportType.indexOf(object.type) !== -1) {
|
|
17
|
+
return true;
|
|
18
|
+
}
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function handleSchema(json, schema) {
|
|
23
|
+
Object.assign(schema, json);
|
|
24
|
+
if (schema.type === 'object') {
|
|
25
|
+
delete schema.properties;
|
|
26
|
+
parse(json.properties, schema);
|
|
27
|
+
}
|
|
28
|
+
if (schema.type === 'array') {
|
|
29
|
+
delete schema.items;
|
|
30
|
+
schema.items = {};
|
|
31
|
+
parse(json.items, schema.items);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function handleArray(arr, schema) {
|
|
36
|
+
schema.type = 'array';
|
|
37
|
+
let props = (schema.items = {});
|
|
38
|
+
parse(arr[0], props);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function handleObject(json, schema) {
|
|
42
|
+
if (isSchema(json)) {
|
|
43
|
+
return handleSchema(json, schema);
|
|
44
|
+
}
|
|
45
|
+
schema.type = 'object';
|
|
46
|
+
schema.required = [];
|
|
47
|
+
let props = (schema.properties = {});
|
|
48
|
+
for (let key in json) {
|
|
49
|
+
let item = json[key];
|
|
50
|
+
let curSchema = (props[key] = {});
|
|
51
|
+
if (key[0] === '*') {
|
|
52
|
+
delete props[key];
|
|
53
|
+
key = key.substr(1);
|
|
54
|
+
schema.required.push(key);
|
|
55
|
+
curSchema = props[key] = {};
|
|
56
|
+
}
|
|
57
|
+
parse(item, curSchema);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function parse(json, schema) {
|
|
62
|
+
if (Array.isArray(json)) {
|
|
63
|
+
handleArray(json, schema);
|
|
64
|
+
} else if (isPlainObject(json)) {
|
|
65
|
+
handleObject(json, schema);
|
|
66
|
+
} else {
|
|
67
|
+
schema.type = getType(json);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function ejs(data) {
|
|
72
|
+
let JsonSchema = {};
|
|
73
|
+
parse(data, JsonSchema);
|
|
74
|
+
return JsonSchema;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export { ejs };
|
package/src/server/network.js
CHANGED
|
@@ -1,123 +1,18 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
import { publicIp, publicIpv4, publicIpv6 } from 'public-ip';
|
|
1
|
+
import Underpost from '../index.js';
|
|
4
2
|
import { actionInitLog, loggerFactory } from './logger.js';
|
|
5
|
-
import { DataBaseProvider } from '../db/DataBaseProvider.js';
|
|
6
|
-
import { getDeployId } from './conf.js';
|
|
7
|
-
|
|
8
|
-
// Network Address Translation Management
|
|
9
|
-
|
|
10
|
-
// import dotenv from 'dotenv';
|
|
11
|
-
// dotenv.config();
|
|
12
3
|
|
|
13
4
|
const logger = loggerFactory(import.meta);
|
|
14
5
|
|
|
15
|
-
const ip = {
|
|
16
|
-
public: {
|
|
17
|
-
get: async () => await publicIp(), // => 'fe80::200:f8ff:fe21:67cf'
|
|
18
|
-
ipv4: async () => await publicIpv4(), // => '46.5.21.123'
|
|
19
|
-
ipv6: async () => await publicIpv6(), // => 'fe80::200:f8ff:fe21:67cf'
|
|
20
|
-
},
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
let ipInstance = '';
|
|
24
|
-
const networkRouter = {};
|
|
25
|
-
|
|
26
6
|
const logRuntimeRouter = () => {
|
|
27
7
|
const displayLog = {};
|
|
28
8
|
|
|
29
|
-
for (const host of Object.keys(
|
|
30
|
-
for (const path of Object.keys(
|
|
31
|
-
displayLog[
|
|
9
|
+
for (const host of Object.keys(Underpost.deployNetwork))
|
|
10
|
+
for (const path of Object.keys(Underpost.deployNetwork[host]))
|
|
11
|
+
displayLog[Underpost.deployNetwork[host][path].publicHost] = Underpost.deployNetwork[host][path].local;
|
|
32
12
|
|
|
33
13
|
logger.info('Runtime network', displayLog);
|
|
34
14
|
};
|
|
35
15
|
|
|
36
|
-
const saveRuntimeRouter = async () => {
|
|
37
|
-
try {
|
|
38
|
-
const deployId = process.env.DEFAULT_DEPLOY_ID;
|
|
39
|
-
const host = process.env.DEFAULT_DEPLOY_HOST;
|
|
40
|
-
const path = process.env.DEFAULT_DEPLOY_PATH;
|
|
41
|
-
const confServerPath = `./engine-private/conf/${deployId}/conf.server.json`;
|
|
42
|
-
if (!deployId || !host || !path || !fs.existsSync(confServerPath)) {
|
|
43
|
-
// logger.warn('default deploy instance not found');
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
const confServer = JSON.parse(fs.readFileSync(confServerPath, 'utf8'));
|
|
47
|
-
const { db } = confServer[host][path];
|
|
48
|
-
|
|
49
|
-
let closeConn;
|
|
50
|
-
if (!DataBaseProvider.instance[`${host}${path}`]) {
|
|
51
|
-
await DataBaseProvider.load({ apis: ['instance'], host, path, db });
|
|
52
|
-
closeConn = true;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
/** @type {import('../api/instance/instance.model.js').InstanceModel} */
|
|
56
|
-
const Instance = DataBaseProvider.instance[`${host}${path}`].mongoose.models.Instance;
|
|
57
|
-
|
|
58
|
-
for (const _host of Object.keys(networkRouter)) {
|
|
59
|
-
for (const _path of Object.keys(networkRouter[_host])) {
|
|
60
|
-
const body = {
|
|
61
|
-
host: _host,
|
|
62
|
-
path: _path,
|
|
63
|
-
deployId: getDeployId(),
|
|
64
|
-
client: networkRouter[_host][_path].client,
|
|
65
|
-
runtime: networkRouter[_host][_path].runtime,
|
|
66
|
-
port: networkRouter[_host][_path].port,
|
|
67
|
-
apis: networkRouter[_host][_path].apis,
|
|
68
|
-
};
|
|
69
|
-
const instance = await Instance.findOne({ deployId: body.deployId, host: _host, path: _path });
|
|
70
|
-
if (instance) {
|
|
71
|
-
await Instance.findByIdAndUpdate(instance._id, body);
|
|
72
|
-
} else {
|
|
73
|
-
await new Instance(body).save();
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
if (closeConn) await DataBaseProvider.instance[`${host}${path}`].mongoose.close();
|
|
79
|
-
} catch (error) {
|
|
80
|
-
logger.error(error, error.stack);
|
|
81
|
-
}
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
const netWorkCron = [];
|
|
85
|
-
|
|
86
|
-
const saveRuntimeCron = async () => {
|
|
87
|
-
try {
|
|
88
|
-
const deployId = process.env.DEFAULT_DEPLOY_ID;
|
|
89
|
-
const host = process.env.DEFAULT_DEPLOY_HOST;
|
|
90
|
-
const path = process.env.DEFAULT_DEPLOY_PATH;
|
|
91
|
-
const confServerPath = `./engine-private/conf/${deployId}/conf.server.json`;
|
|
92
|
-
const confServer = JSON.parse(fs.readFileSync(confServerPath, 'utf8'));
|
|
93
|
-
const { db } = confServer[host][path];
|
|
94
|
-
|
|
95
|
-
let closeConn;
|
|
96
|
-
if (!DataBaseProvider.instance[`${host}${path}`]) {
|
|
97
|
-
await DataBaseProvider.load({ apis: ['cron'], host, path, db });
|
|
98
|
-
closeConn = true;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
/** @type {import('../api/cron/cron.model.js').CronModel} */
|
|
102
|
-
const Cron = DataBaseProvider.instance[`${host}${path}`].mongoose.models.Cron;
|
|
103
|
-
|
|
104
|
-
// await Cron.insertMany(netWorkCron);
|
|
105
|
-
|
|
106
|
-
for (const cronInstance of netWorkCron) {
|
|
107
|
-
const cron = await Cron.findOne({ deployId: cronInstance.deployId, jobId: cronInstance.jobId });
|
|
108
|
-
if (cron) {
|
|
109
|
-
await Cron.findByIdAndUpdate(cron._id, cronInstance);
|
|
110
|
-
} else {
|
|
111
|
-
await new Cron(cronInstance).save();
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
if (closeConn) await DataBaseProvider.instance[`${host}${path}`].mongoose.close();
|
|
116
|
-
} catch (error) {
|
|
117
|
-
logger.error(error, error.stack);
|
|
118
|
-
}
|
|
119
|
-
};
|
|
120
|
-
|
|
121
16
|
const listenServerFactory = (logic = async () => {}) => {
|
|
122
17
|
return {
|
|
123
18
|
listen: async (...args) => (
|
|
@@ -150,13 +45,12 @@ const listenPortController = async (server, port, metadata) =>
|
|
|
150
45
|
if (error.length > 0) throw new Error('Listen port controller requires values: ' + error.join(', '));
|
|
151
46
|
|
|
152
47
|
server.listen(port, () => {
|
|
153
|
-
if (!
|
|
154
|
-
|
|
48
|
+
if (!Underpost.deployNetwork[host]) Underpost.deployNetwork[host] = {};
|
|
49
|
+
Underpost.deployNetwork[host][path] = {
|
|
155
50
|
meta,
|
|
156
51
|
client,
|
|
157
52
|
runtime,
|
|
158
53
|
port,
|
|
159
|
-
public: `http://${ipInstance}:${port}${path}`,
|
|
160
54
|
publicHost:
|
|
161
55
|
port === 80
|
|
162
56
|
? `http://${host}${path}`
|
|
@@ -175,13 +69,4 @@ const listenPortController = async (server, port, metadata) =>
|
|
|
175
69
|
}
|
|
176
70
|
});
|
|
177
71
|
|
|
178
|
-
export {
|
|
179
|
-
ip,
|
|
180
|
-
listenPortController,
|
|
181
|
-
networkRouter,
|
|
182
|
-
netWorkCron,
|
|
183
|
-
saveRuntimeRouter,
|
|
184
|
-
logRuntimeRouter,
|
|
185
|
-
listenServerFactory,
|
|
186
|
-
saveRuntimeCron,
|
|
187
|
-
};
|
|
72
|
+
export { listenPortController, logRuntimeRouter, listenServerFactory };
|
package/src/server/peer.js
CHANGED
|
@@ -2,7 +2,7 @@ import { PeerServer } from 'peer';
|
|
|
2
2
|
import dotenv from 'dotenv';
|
|
3
3
|
import { loggerFactory } from './logger.js';
|
|
4
4
|
import fs from 'fs-extra';
|
|
5
|
-
import
|
|
5
|
+
import UnderpostStartUp from './start.js';
|
|
6
6
|
|
|
7
7
|
dotenv.config();
|
|
8
8
|
|
|
@@ -25,7 +25,7 @@ const createPeerServer = async ({ port, devPort, origins, host, path }) => {
|
|
|
25
25
|
// cert: fs.readFileSync(''),
|
|
26
26
|
// ca: fs.readFileSync(''),
|
|
27
27
|
};
|
|
28
|
-
const peerServer = listenServerFactory(() => PeerServer(options));
|
|
28
|
+
const peerServer = UnderpostStartUp.API.listenServerFactory(() => PeerServer(options));
|
|
29
29
|
|
|
30
30
|
return { options, peerServer, meta: import.meta };
|
|
31
31
|
};
|
package/src/server/proxy.js
CHANGED
|
@@ -5,9 +5,9 @@ import dotenv from 'dotenv';
|
|
|
5
5
|
|
|
6
6
|
import { createProxyMiddleware } from 'http-proxy-middleware';
|
|
7
7
|
import { loggerFactory, loggerMiddleware } from './logger.js';
|
|
8
|
-
import { listenPortController } from './network.js';
|
|
9
8
|
import { createSslServer, sslRedirectMiddleware } from './ssl.js';
|
|
10
9
|
import { buildPortProxyRouter, buildProxyRouter, maintenanceMiddleware } from './conf.js';
|
|
10
|
+
import UnderpostStartUp from './start.js';
|
|
11
11
|
|
|
12
12
|
dotenv.config();
|
|
13
13
|
|
|
@@ -71,11 +71,11 @@ const buildProxy = async () => {
|
|
|
71
71
|
switch (port) {
|
|
72
72
|
case 443:
|
|
73
73
|
const { ServerSSL } = await createSslServer(app, hosts);
|
|
74
|
-
await listenPortController(ServerSSL, port, runningData);
|
|
74
|
+
await UnderpostStartUp.API.listenPortController(ServerSSL, port, runningData);
|
|
75
75
|
break;
|
|
76
76
|
|
|
77
77
|
default:
|
|
78
|
-
await listenPortController(app, port, runningData);
|
|
78
|
+
await UnderpostStartUp.API.listenPortController(app, port, runningData);
|
|
79
79
|
|
|
80
80
|
break;
|
|
81
81
|
}
|
|
@@ -83,7 +83,7 @@ const buildProxy = async () => {
|
|
|
83
83
|
break;
|
|
84
84
|
|
|
85
85
|
default:
|
|
86
|
-
await listenPortController(app, port, runningData);
|
|
86
|
+
await UnderpostStartUp.API.listenPortController(app, port, runningData);
|
|
87
87
|
|
|
88
88
|
break;
|
|
89
89
|
}
|
package/src/server/runtime.js
CHANGED
|
@@ -9,7 +9,7 @@ import compression from 'compression';
|
|
|
9
9
|
|
|
10
10
|
import { createServer } from 'http';
|
|
11
11
|
import { getRootDirectory } from './process.js';
|
|
12
|
-
import
|
|
12
|
+
import UnderpostStartUp from './start.js';
|
|
13
13
|
import { loggerFactory, loggerMiddleware } from './logger.js';
|
|
14
14
|
import { getCapVariableName, newInstance } from '../client/components/core/CommonJs.js';
|
|
15
15
|
import { Xampp } from '../runtime/xampp/Xampp.js';
|
|
@@ -41,7 +41,6 @@ const buildRuntime = async () => {
|
|
|
41
41
|
// logger.info('promCounterOption', promCounterOption);
|
|
42
42
|
|
|
43
43
|
const requestCounter = new promClient.Counter(promCounterOption);
|
|
44
|
-
const ipInstance = ''; // await ip.public.ipv4();
|
|
45
44
|
const initPort = parseInt(process.env.PORT) + 1;
|
|
46
45
|
let currentPort = initPort;
|
|
47
46
|
const confServer = JSON.parse(fs.readFileSync(`./conf/conf.server.json`, 'utf8'));
|
|
@@ -183,7 +182,11 @@ const buildRuntime = async () => {
|
|
|
183
182
|
// RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC]
|
|
184
183
|
// RewriteRule ^ https://%1%{REQUEST_URI} [L,NE,R=301]
|
|
185
184
|
|
|
186
|
-
await listenPortController(
|
|
185
|
+
await UnderpostStartUp.API.listenPortController(
|
|
186
|
+
UnderpostStartUp.API.listenServerFactory(),
|
|
187
|
+
port,
|
|
188
|
+
runningData,
|
|
189
|
+
);
|
|
187
190
|
break;
|
|
188
191
|
case 'xampp':
|
|
189
192
|
if (!Xampp.enabled()) continue;
|
|
@@ -230,7 +233,11 @@ const buildRuntime = async () => {
|
|
|
230
233
|
// if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') {
|
|
231
234
|
// $_SERVER['HTTPS'] = 'on';
|
|
232
235
|
// }
|
|
233
|
-
await listenPortController(
|
|
236
|
+
await UnderpostStartUp.API.listenPortController(
|
|
237
|
+
UnderpostStartUp.API.listenServerFactory(),
|
|
238
|
+
port,
|
|
239
|
+
runningData,
|
|
240
|
+
);
|
|
234
241
|
break;
|
|
235
242
|
case 'nodejs':
|
|
236
243
|
const app = express();
|
|
@@ -283,7 +290,7 @@ const buildRuntime = async () => {
|
|
|
283
290
|
currentPort += 2;
|
|
284
291
|
const staticPort = newInstance(currentPort);
|
|
285
292
|
|
|
286
|
-
await listenPortController(app, staticPort, runningData);
|
|
293
|
+
await UnderpostStartUp.API.listenPortController(app, staticPort, runningData);
|
|
287
294
|
currentPort++;
|
|
288
295
|
continue;
|
|
289
296
|
}
|
|
@@ -334,7 +341,7 @@ const buildRuntime = async () => {
|
|
|
334
341
|
// }),
|
|
335
342
|
// );
|
|
336
343
|
|
|
337
|
-
await listenPortController(app, port, runningData);
|
|
344
|
+
await UnderpostStartUp.API.listenPortController(app, port, runningData);
|
|
338
345
|
break;
|
|
339
346
|
}
|
|
340
347
|
|
|
@@ -442,7 +449,7 @@ const buildRuntime = async () => {
|
|
|
442
449
|
port,
|
|
443
450
|
origins,
|
|
444
451
|
});
|
|
445
|
-
await listenPortController(listenServerFactory(), port, {
|
|
452
|
+
await UnderpostStartUp.API.listenPortController(UnderpostStartUp.API.listenServerFactory(), port, {
|
|
446
453
|
runtime: 'nodejs',
|
|
447
454
|
client: null,
|
|
448
455
|
host,
|
|
@@ -462,7 +469,7 @@ const buildRuntime = async () => {
|
|
|
462
469
|
path,
|
|
463
470
|
});
|
|
464
471
|
|
|
465
|
-
await listenPortController(peerServer, peerPort, {
|
|
472
|
+
await UnderpostStartUp.API.listenPortController(peerServer, peerPort, {
|
|
466
473
|
runtime: 'nodejs',
|
|
467
474
|
client: null,
|
|
468
475
|
host,
|
|
@@ -471,7 +478,7 @@ const buildRuntime = async () => {
|
|
|
471
478
|
});
|
|
472
479
|
}
|
|
473
480
|
|
|
474
|
-
await listenPortController(server, port, runningData);
|
|
481
|
+
await UnderpostStartUp.API.listenPortController(server, port, runningData);
|
|
475
482
|
|
|
476
483
|
break;
|
|
477
484
|
default:
|
|
@@ -484,8 +491,7 @@ const buildRuntime = async () => {
|
|
|
484
491
|
if (Xampp.enabled() && Xampp.router) Xampp.initService();
|
|
485
492
|
if (Lampp.enabled() && Lampp.router) Lampp.initService();
|
|
486
493
|
|
|
487
|
-
|
|
488
|
-
logRuntimeRouter();
|
|
494
|
+
UnderpostStartUp.API.logRuntimeRouter();
|
|
489
495
|
};
|
|
490
496
|
|
|
491
497
|
export { buildRuntime };
|