qcobjects-cli 2.3.49 → 2.4.21
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/FUNDING.yml +12 -0
- package/.github/ISSUE_TEMPLATE/bug_report.md +38 -0
- package/.github/ISSUE_TEMPLATE/custom.md +10 -0
- package/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
- package/.github/ISSUE_TEMPLATE/issue-template.md +33 -0
- package/.github/workflows/codeql-analysis.yml +71 -0
- package/.github/workflows/npmpublish-beta.yml +38 -0
- package/.github/workflows/npmpublish-lts.yml +38 -0
- package/.github/workflows/npmpublish-main.yml +38 -0
- package/.gitlab-ci.yml +3 -2
- package/VERSION +1 -1
- package/backend/com.qcobjects.backend.microservice.static.js +40 -24
- package/backend/org.qcobjects.backend.php.js +149 -116
- package/{org.quickcorp.qcobjects.cli.commands.jira.client_services.js → com.qcobjects.cli.commands.jira.client_services.js} +29 -22
- package/{org.quickcorp.qcobjects.cli.commands.jira.js → com.qcobjects.cli.commands.jira.js} +77 -60
- package/{org.quickcorp.qcobjects.cli.commands.js → com.qcobjects.cli.commands.js} +3 -3
- package/com.qcobjects.cli.commands.version.js +285 -0
- package/org.qcobjects.common.pipelog.js +55 -0
- package/org.qcobjects.enterprise.commands.js +149 -139
- package/org.quickcorp.qcobjects.api.client_services.js +31 -20
- package/org.quickcorp.qcobjects.cli.js +288 -275
- package/org.quickcorp.qcobjects.collab.server.js +317 -308
- package/org.quickcorp.qcobjects.defaultsettings.js +1 -1
- package/org.quickcorp.qcobjects.main.file.js +100 -79
- package/org.quickcorp.qcobjects.main.http.gae.server.js +265 -234
- package/org.quickcorp.qcobjects.main.http.server.js +156 -147
- package/org.quickcorp.qcobjects.main.http2.server.js +198 -191
- package/package.json +18 -10
- package/qcobjects-cli.js +8 -11
- package/qcobjects-collab.js +8 -6
- package/qcobjects-createcert.js +28 -16
- package/qcobjects-gae-http-server.js +8 -5
- package/qcobjects-http-server.js +7 -5
- package/qcobjects-http2-server.js +8 -5
- package/qcobjects-shell.js +113 -107
- package/org.quickcorp.qcobjects.cli.commands.version.js +0 -267
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* QCObjects CLI 2.
|
|
2
|
+
* QCObjects CLI 2.4.x
|
|
3
3
|
* ________________
|
|
4
4
|
*
|
|
5
5
|
* Author: Jean Machuca <correojean@gmail.com>
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
*
|
|
22
22
|
* Everyone is permitted to copy and distribute verbatim copies of this
|
|
23
23
|
* license document, but changing it is not allowed.
|
|
24
|
-
*/
|
|
24
|
+
*/
|
|
25
25
|
/*eslint no-unused-vars: "off"*/
|
|
26
26
|
/*eslint no-redeclare: "off"*/
|
|
27
27
|
/*eslint no-empty: "off"*/
|
|
@@ -31,50 +31,44 @@
|
|
|
31
31
|
"use strict";
|
|
32
32
|
|
|
33
33
|
const path = require("path");
|
|
34
|
-
const absolutePath = path.resolve(
|
|
34
|
+
const absolutePath = path.resolve(__dirname, "./");
|
|
35
35
|
|
|
36
36
|
const http2 = require("http2");
|
|
37
37
|
const fs = require("fs");
|
|
38
38
|
const mime = require("mime");
|
|
39
|
-
require(absolutePath+"/org.quickcorp.qcobjects.main.file.js");
|
|
39
|
+
require(absolutePath + "/org.quickcorp.qcobjects.main.file.js");
|
|
40
|
+
require(absolutePath + "/org.qcobjects.common.pipelog.js");
|
|
40
41
|
|
|
41
|
-
let ImportMicroservice = function (microservicePackage){
|
|
42
|
-
var standardPath = findPackageNodePath(microservicePackage) || findPackageNodePath(microservicePackage+".js");
|
|
43
|
-
if (standardPath !== null){
|
|
44
|
-
Import
|
|
42
|
+
let ImportMicroservice = function (microservicePackage) {
|
|
43
|
+
var standardPath = findPackageNodePath(microservicePackage) || findPackageNodePath(microservicePackage + ".js");
|
|
44
|
+
if (standardPath !== null) {
|
|
45
|
+
Import(microservicePackage);
|
|
45
46
|
} else {
|
|
46
|
-
Import
|
|
47
|
+
Import(absolutePath + "/backend/" + microservicePackage);
|
|
47
48
|
}
|
|
48
49
|
};
|
|
49
50
|
|
|
50
|
-
Package("org.quickcorp.qcobjects.main.http2.server",[
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
51
|
+
Package("org.quickcorp.qcobjects.main.http2.server", [
|
|
52
|
+
|
|
53
|
+
class HTTP2ServerResponse extends InheritClass {
|
|
54
|
+
constructor({
|
|
55
|
+
headers = {
|
|
56
|
+
":status": 200,
|
|
57
|
+
"content-type": "text/html",
|
|
58
|
+
"cache-control": CONFIG.get("cacheControl", "max-age=31536000")
|
|
59
|
+
},
|
|
60
|
+
body = "",
|
|
61
|
+
request = null,
|
|
62
|
+
fileDispatcher = null,
|
|
63
|
+
stream = null
|
|
64
|
+
}) {
|
|
65
|
+
super(...arguments);
|
|
66
|
+
var self = this;
|
|
67
|
+
self._generateResponse();
|
|
68
|
+
|
|
66
69
|
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
headers:{
|
|
70
|
-
":status": 200,
|
|
71
|
-
"content-type": "text/html",
|
|
72
|
-
"cache-control": CONFIG.get("cacheControl", "max-age=31536000")
|
|
73
|
-
},
|
|
74
|
-
body:"",
|
|
75
|
-
request:null,
|
|
76
|
-
fileDispatcher:null,
|
|
77
|
-
sendFile: function (stream, fileName) {
|
|
70
|
+
|
|
71
|
+
sendFile(stream, fileName) {
|
|
78
72
|
// read and send file content in the stream
|
|
79
73
|
|
|
80
74
|
try {
|
|
@@ -93,14 +87,14 @@ Package("org.quickcorp.qcobjects.main.http2.server",[
|
|
|
93
87
|
});
|
|
94
88
|
stream.end();
|
|
95
89
|
|
|
96
|
-
} catch (e){
|
|
97
|
-
logger.debug("[ERROR] something went wrong when trying to send the response as file "+fileName);
|
|
98
|
-
if (e.errno
|
|
90
|
+
} catch (e) {
|
|
91
|
+
logger.debug("[ERROR] something went wrong when trying to send the response as file " + fileName);
|
|
92
|
+
if (e.errno == -2) {
|
|
99
93
|
const headers = {
|
|
100
94
|
":status": 404,
|
|
101
95
|
"content-type": mime.getType(fileName)
|
|
102
96
|
};
|
|
103
|
-
stream.respond
|
|
97
|
+
stream.respond(headers);
|
|
104
98
|
stream.write("<h1>404 - FILE NOT FOUND</h1>");
|
|
105
99
|
stream.on("close", () => {
|
|
106
100
|
logger.debug("closing file " + fileName);
|
|
@@ -108,22 +102,22 @@ Package("org.quickcorp.qcobjects.main.http2.server",[
|
|
|
108
102
|
stream.end();
|
|
109
103
|
}
|
|
110
104
|
}
|
|
111
|
-
}
|
|
112
|
-
_generateResponse
|
|
105
|
+
}
|
|
106
|
+
_generateResponse() {
|
|
113
107
|
var response = this;
|
|
114
|
-
response.fileDispatcher = New(FileDispatcher,{
|
|
115
|
-
scriptname:response.request.scriptname,
|
|
116
|
-
pathname:response.request.pathname,
|
|
117
|
-
done
|
|
108
|
+
response.fileDispatcher = New(FileDispatcher, {
|
|
109
|
+
scriptname: response.request.scriptname,
|
|
110
|
+
pathname: response.request.pathname,
|
|
111
|
+
done(headers, body, templateURI, isTemplate) {
|
|
118
112
|
response.headers = headers;
|
|
119
113
|
var stream = response.stream;
|
|
120
|
-
if (isTemplate){
|
|
114
|
+
if (isTemplate) {
|
|
121
115
|
response.body = body;
|
|
122
116
|
stream.respond(response.headers);
|
|
123
117
|
stream.write(response.body);
|
|
124
118
|
stream.end();
|
|
125
|
-
} else if (headers[":status"]==200){
|
|
126
|
-
response.sendFile(stream,templateURI);
|
|
119
|
+
} else if (headers[":status"] == 200) {
|
|
120
|
+
response.sendFile(stream, templateURI);
|
|
127
121
|
} else {
|
|
128
122
|
stream.respond(response.headers);
|
|
129
123
|
stream.end();
|
|
@@ -131,81 +125,44 @@ Package("org.quickcorp.qcobjects.main.http2.server",[
|
|
|
131
125
|
}
|
|
132
126
|
});
|
|
133
127
|
|
|
134
|
-
},
|
|
135
|
-
_new_:function (o){
|
|
136
|
-
var self = this;
|
|
137
|
-
self.body = "";
|
|
138
|
-
self.stream = o.stream;
|
|
139
|
-
self._generateResponse();
|
|
140
|
-
|
|
141
128
|
}
|
|
142
|
-
}),
|
|
143
|
-
Class("HTTP2ServerRequest",{
|
|
144
|
-
scriptname:"",
|
|
145
|
-
path:"",
|
|
146
|
-
method:"",
|
|
147
|
-
url:"",
|
|
148
|
-
headers:null,
|
|
149
|
-
flags:null,
|
|
150
|
-
protocol: null,
|
|
151
|
-
slashes: null,
|
|
152
|
-
auth: null,
|
|
153
|
-
host: null,
|
|
154
|
-
port: null,
|
|
155
|
-
hostname: null,
|
|
156
|
-
hash: null,
|
|
157
|
-
search: "",
|
|
158
|
-
query: "",
|
|
159
|
-
pathname: "",
|
|
160
|
-
href: ""
|
|
161
|
-
}),
|
|
162
|
-
Class("HTTP2Server",{
|
|
163
|
-
request:null,
|
|
164
|
-
response:"",
|
|
165
|
-
server:null,
|
|
166
|
-
scriptname:"",
|
|
167
|
-
interceptorInstances:[],
|
|
168
|
-
showIPAddress:function (){
|
|
169
|
-
var _ret_ = "";
|
|
170
|
-
var os = require("os");
|
|
171
|
-
var ifaces = os.networkInterfaces();
|
|
172
|
-
Object.keys(ifaces).forEach(function (iface){
|
|
173
|
-
ifaces[iface].map(function (ipGroup){
|
|
174
|
-
_ret_ += iface +": " + PipeLog.pipe(ipGroup)+"\n";
|
|
175
|
-
});
|
|
176
|
-
});
|
|
177
|
-
return _ret_;
|
|
178
|
-
},
|
|
179
|
-
showPossibleURL: function (){
|
|
180
|
-
var _ret_ = "";
|
|
181
|
-
var os = require("os");
|
|
182
|
-
var ifaces = os.networkInterfaces();
|
|
183
|
-
Object.keys(ifaces).forEach(function (iface){
|
|
184
|
-
ifaces[iface].map(function (ipGroup){
|
|
185
|
-
if (ipGroup["family"].toLowerCase()=="ipv4"){
|
|
186
|
-
_ret_ += "http://"+ipGroup["address"]+":"+CONFIG.get("serverPortHTTP").toString()+"/\n";
|
|
187
|
-
_ret_ += "https://"+ipGroup["address"]+":"+CONFIG.get("serverPortHTTPS").toString()+"/\n";
|
|
188
|
-
}
|
|
189
|
-
});
|
|
190
|
-
});
|
|
191
|
-
return _ret_;
|
|
192
|
-
},
|
|
193
|
-
start:function (){
|
|
194
|
-
var server = this.server;
|
|
195
129
|
|
|
196
|
-
|
|
130
|
+
},
|
|
197
131
|
|
|
198
|
-
|
|
132
|
+
class HTTP2ServerRequest extends InheritClass {
|
|
133
|
+
constructor({
|
|
134
|
+
scriptname = "",
|
|
135
|
+
path = "",
|
|
136
|
+
method = "",
|
|
137
|
+
url = "",
|
|
138
|
+
headers = null,
|
|
139
|
+
flags = null,
|
|
140
|
+
protocol = null,
|
|
141
|
+
slashes = null,
|
|
142
|
+
auth = null,
|
|
143
|
+
host = null,
|
|
144
|
+
port = null,
|
|
145
|
+
hostname = null,
|
|
146
|
+
hash = null,
|
|
147
|
+
search = "",
|
|
148
|
+
query = "",
|
|
149
|
+
pathname = "",
|
|
150
|
+
href = ""
|
|
151
|
+
}) {
|
|
152
|
+
super(...arguments);
|
|
153
|
+
}
|
|
154
|
+
},
|
|
199
155
|
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
156
|
+
class HTTP2Server extends InheritClass {
|
|
157
|
+
constructor({
|
|
158
|
+
request = null,
|
|
159
|
+
response = "",
|
|
160
|
+
server = null,
|
|
161
|
+
scriptname = "",
|
|
162
|
+
interceptorInstances = []
|
|
163
|
+
}) {
|
|
164
|
+
super(...arguments);
|
|
204
165
|
|
|
205
|
-
httpServer.listen(CONFIG.get("serverPortHTTP"));
|
|
206
|
-
server.listen(CONFIG.get("serverPortHTTPS"));
|
|
207
|
-
},
|
|
208
|
-
_new_:function (){
|
|
209
166
|
const welcometo = "Welcome to \n";
|
|
210
167
|
const instructions = "HTTP2Server \n";
|
|
211
168
|
const logo = " .d88888b. .d8888b. .d88888b. 888 d8b 888 \r\nd88P\" \"Y88bd88P Y88bd88P\" \"Y88b888 Y8P 888 \r\n888 888888 888888 888888 888 \r\n888 888888 888 88888888b. 8888 .d88b. .d8888b888888.d8888b \r\n888 888888 888 888888 \"88b \"888d8P Y8bd88P\" 888 88K \r\n888 Y8b 888888 888888 888888 888 88888888888888 888 \"Y8888b. \r\nY88b.Y8b88PY88b d88PY88b. .d88P888 d88P 888Y8b. Y88b. Y88b. X88 \r\n \"Y888888\" \"Y8888P\" \"Y88888P\" 88888P\" 888 \"Y8888 \"Y8888P \"Y888 88888P' \r\n Y8b 888 \r\n d88P \r\n 888P\" ";
|
|
@@ -213,16 +170,16 @@ Package("org.quickcorp.qcobjects.main.http2.server",[
|
|
|
213
170
|
console.log(logo);
|
|
214
171
|
console.log(instructions);
|
|
215
172
|
logger.debug(this.showIPAddress());
|
|
216
|
-
logger.info("Listening on HTTP PORT: "+CONFIG.get("serverPortHTTP").toString());
|
|
217
|
-
logger.info("Listening on HTTPS PORT: "+CONFIG.get("serverPortHTTPS").toString());
|
|
218
|
-
logger.info("Go to: \n"+this.showPossibleURL());
|
|
173
|
+
logger.info("Listening on HTTP PORT: " + CONFIG.get("serverPortHTTP").toString());
|
|
174
|
+
logger.info("Listening on HTTPS PORT: " + CONFIG.get("serverPortHTTPS").toString());
|
|
175
|
+
logger.info("Go to: \n" + this.showPossibleURL());
|
|
219
176
|
|
|
220
177
|
let http2ServerInstance = this;
|
|
221
178
|
http2ServerInstance.server = http2.createSecureServer({
|
|
222
179
|
key: fs.readFileSync(CONFIG.get("private-key-pem")),
|
|
223
180
|
cert: fs.readFileSync(CONFIG.get("private-cert-pem")),
|
|
224
|
-
allowHTTP1:CONFIG.get("allowHTTP1"),
|
|
225
|
-
origins:["https://"+CONFIG.get("domain"),"http://"+CONFIG.get("domain")]
|
|
181
|
+
allowHTTP1: CONFIG.get("allowHTTP1"),
|
|
182
|
+
origins: ["https://" + CONFIG.get("domain"), "http://" + CONFIG.get("domain")]
|
|
226
183
|
});
|
|
227
184
|
var server = http2ServerInstance.server;
|
|
228
185
|
|
|
@@ -230,27 +187,27 @@ Package("org.quickcorp.qcobjects.main.http2.server",[
|
|
|
230
187
|
|
|
231
188
|
server.on("session", (session) => {
|
|
232
189
|
// Set altsvc for origin https://example.org:80
|
|
233
|
-
session.altsvc("h2=\":8000\"", "https://"+CONFIG.get("domain"));
|
|
234
|
-
session.altsvc("https=\":"+CONFIG.get("serverPortHTTPS")+"\"","https://"+CONFIG.get("domain"));
|
|
235
|
-
session.altsvc("http=\":"+CONFIG.get("serverPortHTTP")+"\"","http://"+CONFIG.get("domain"));
|
|
236
|
-
session.origin("https://"+CONFIG.get("domain"),"http://"+CONFIG.get("domain"));
|
|
190
|
+
session.altsvc("h2=\":8000\"", "https://" + CONFIG.get("domain"));
|
|
191
|
+
session.altsvc("https=\":" + CONFIG.get("serverPortHTTPS") + "\"", "https://" + CONFIG.get("domain"));
|
|
192
|
+
session.altsvc("http=\":" + CONFIG.get("serverPortHTTP") + "\"", "http://" + CONFIG.get("domain"));
|
|
193
|
+
session.origin("https://" + CONFIG.get("domain"), "http://" + CONFIG.get("domain"));
|
|
237
194
|
|
|
238
195
|
});
|
|
239
196
|
|
|
240
|
-
if (global.get("backendAvailable")){
|
|
197
|
+
if (global.get("backendAvailable")) {
|
|
241
198
|
logger.info("Loading backend interceptors...");
|
|
242
|
-
let interceptors = CONFIG.get("backend",{}).interceptors;
|
|
243
|
-
if (typeof interceptors !== "undefined"){
|
|
199
|
+
let interceptors = CONFIG.get("backend", {}).interceptors;
|
|
200
|
+
if (typeof interceptors !== "undefined") {
|
|
244
201
|
logger.info("Backend Interceptors Available");
|
|
245
|
-
interceptors.map(interceptor=>{
|
|
246
|
-
ImportMicroservice
|
|
247
|
-
var interceptorClassFactory = ClassFactory(interceptor.microservice+".Interceptor");
|
|
248
|
-
var interceptorInstance = New(interceptorClassFactory,{
|
|
249
|
-
domain:CONFIG.get("domain"),
|
|
250
|
-
basePath:CONFIG.get("basePath"),
|
|
251
|
-
projectPath:CONFIG.get("projectPath"),
|
|
252
|
-
interceptor:interceptor,
|
|
253
|
-
server:server
|
|
202
|
+
interceptors.map(interceptor => {
|
|
203
|
+
ImportMicroservice(interceptor.microservice);
|
|
204
|
+
var interceptorClassFactory = ClassFactory(interceptor.microservice + ".Interceptor");
|
|
205
|
+
var interceptorInstance = New(interceptorClassFactory, {
|
|
206
|
+
domain: CONFIG.get("domain"),
|
|
207
|
+
basePath: CONFIG.get("basePath"),
|
|
208
|
+
projectPath: CONFIG.get("projectPath"),
|
|
209
|
+
interceptor: interceptor,
|
|
210
|
+
server: server
|
|
254
211
|
});
|
|
255
212
|
http2ServerInstance.interceptorInstances.push(interceptorInstance);
|
|
256
213
|
});
|
|
@@ -258,45 +215,45 @@ Package("org.quickcorp.qcobjects.main.http2.server",[
|
|
|
258
215
|
}
|
|
259
216
|
|
|
260
217
|
server.on("stream", (stream, headers, flags) => {
|
|
261
|
-
CONFIG.set("backendTimeout",CONFIG.get("backendTimeout") || 20000);
|
|
218
|
+
CONFIG.set("backendTimeout", CONFIG.get("backendTimeout") || 20000);
|
|
262
219
|
stream.session.setTimeout(CONFIG.get("backendTimeout"));
|
|
263
220
|
stream.session.setMaxListeners(9999999999);
|
|
264
221
|
var timeoutHandler = () => {
|
|
265
222
|
// end the stream on timeout
|
|
266
223
|
try {
|
|
267
|
-
if (!stream.destroyed){
|
|
268
|
-
logger.info("A timeout occurred... "+CONFIG.get("backendTimeout").toString());
|
|
224
|
+
if (!stream.destroyed) {
|
|
225
|
+
logger.info("A timeout occurred... " + CONFIG.get("backendTimeout").toString());
|
|
269
226
|
logger.info("Killing session...");
|
|
270
227
|
stream.respond({
|
|
271
228
|
":status": 500,
|
|
272
229
|
"content-type": "text/html"
|
|
273
230
|
});
|
|
274
|
-
stream.on("error",()=>{});
|
|
231
|
+
stream.on("error", () => {});
|
|
275
232
|
stream.write("<h1>500 - INTERNAL SERVER ERROR (TIMEOUT)</h1>");
|
|
276
233
|
stream.end();
|
|
277
234
|
} else {
|
|
278
235
|
logger.debug("Session was normally finishing...");
|
|
279
236
|
}
|
|
280
|
-
}catch(e){
|
|
237
|
+
} catch (e) {
|
|
281
238
|
logger.debug("An unhandled error occurred during timeout catching...");
|
|
282
239
|
logger.debug(e.message);
|
|
283
240
|
}
|
|
284
241
|
|
|
285
|
-
if (!stream.destroyed){
|
|
286
|
-
stream.session.removeListener("timeout",timeoutHandler);
|
|
242
|
+
if (!stream.destroyed) {
|
|
243
|
+
stream.session.removeListener("timeout", timeoutHandler);
|
|
287
244
|
} else {
|
|
288
|
-
server.removeListener("timeout",timeoutHandler);
|
|
245
|
+
server.removeListener("timeout", timeoutHandler);
|
|
289
246
|
}
|
|
290
247
|
|
|
291
248
|
};
|
|
292
|
-
if (!stream.destroyed){
|
|
293
|
-
stream.session.on("timeout", timeoutHandler
|
|
249
|
+
if (!stream.destroyed) {
|
|
250
|
+
stream.session.on("timeout", timeoutHandler);
|
|
294
251
|
}
|
|
295
252
|
|
|
296
253
|
stream.session.altsvc("h2=\":8000\"", stream.id);
|
|
297
|
-
stream.session.altsvc("https=\":"+CONFIG.get("serverPortHTTPS")+"\"", stream.id);
|
|
298
|
-
stream.session.altsvc("http=\":"+CONFIG.get("serverPortHTTP")+"\"",stream.id);
|
|
299
|
-
let request = Object.assign(New(HTTP2ServerRequest),require("url").parse(headers[":path"]));
|
|
254
|
+
stream.session.altsvc("https=\":" + CONFIG.get("serverPortHTTPS") + "\"", stream.id);
|
|
255
|
+
stream.session.altsvc("http=\":" + CONFIG.get("serverPortHTTP") + "\"", stream.id);
|
|
256
|
+
let request = Object.assign(New(HTTP2ServerRequest), require("url").parse(headers[":path"]));
|
|
300
257
|
request.headers = headers;
|
|
301
258
|
request.flags = flags;
|
|
302
259
|
http2ServerInstance.request = request;
|
|
@@ -304,60 +261,65 @@ Package("org.quickcorp.qcobjects.main.http2.server",[
|
|
|
304
261
|
http2ServerInstance.request.path = headers[":path"];
|
|
305
262
|
|
|
306
263
|
|
|
307
|
-
if (http2ServerInstance.request.pathname.indexOf(".")<0){
|
|
308
|
-
|
|
264
|
+
if (http2ServerInstance.request.pathname.indexOf(".") < 0) {
|
|
265
|
+
http2ServerInstance.request.scriptname = CONFIG.get("documentRootFileIndex");
|
|
309
266
|
} else {
|
|
310
267
|
http2ServerInstance.request.scriptname = http2ServerInstance.request.pathname.split("/").reverse()[0];
|
|
311
268
|
}
|
|
312
|
-
http2ServerInstance.request.pathname = this.request.pathname.substr(0,http2ServerInstance.request.pathname.lastIndexOf("/"));
|
|
269
|
+
http2ServerInstance.request.pathname = this.request.pathname.substr(0, http2ServerInstance.request.pathname.lastIndexOf("/"));
|
|
313
270
|
|
|
314
|
-
logger.debug(PipeLog.pipe(this.request));
|
|
271
|
+
logger.debug((new PipeLog()).pipe(this.request));
|
|
315
272
|
|
|
316
|
-
if (global.get("backendAvailable")){
|
|
273
|
+
if (global.get("backendAvailable")) {
|
|
317
274
|
logger.info("Backend Microservices Available...");
|
|
318
275
|
|
|
319
276
|
logger.info("Loading backend routes...");
|
|
320
|
-
let routes = CONFIG.get("backend",{}).routes;
|
|
321
|
-
let selectedRoute = routes.filter(route=>
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
277
|
+
let routes = CONFIG.get("backend", {}).routes;
|
|
278
|
+
let selectedRoute = routes.filter(route => {
|
|
279
|
+
let standardRoutePath = route.path.replace(/{(.*?)}/g, "(?<$1>.*)");
|
|
280
|
+
return (new RegExp(standardRoutePath, "g")).test(request.path);
|
|
281
|
+
});
|
|
282
|
+
if (selectedRoute.length > 0) {
|
|
283
|
+
selectedRoute.map(route => {
|
|
284
|
+
let standardRoutePath = route.path.replace(/{(.*?)}/g, "(?<$1>.*)"); //allowing {param}
|
|
325
285
|
console.log(standardRoutePath);
|
|
326
|
-
let selectedRouteParams = {
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
286
|
+
let selectedRouteParams = {
|
|
287
|
+
...[...request.path.matchAll((new RegExp(standardRoutePath, "g")))][0]["groups"]
|
|
288
|
+
};
|
|
289
|
+
ImportMicroservice(route.microservice);
|
|
290
|
+
var microServiceClassFactory = ClassFactory(route.microservice + ".Microservice");
|
|
291
|
+
http2ServerInstance.response = New(microServiceClassFactory, {
|
|
292
|
+
domain: CONFIG.get("domain"),
|
|
293
|
+
basePath: CONFIG.get("basePath"),
|
|
294
|
+
projectPath: CONFIG.get("projectPath"),
|
|
295
|
+
route: route,
|
|
296
|
+
routeParams: selectedRouteParams,
|
|
297
|
+
server: server,
|
|
298
|
+
stream: stream,
|
|
299
|
+
request: request
|
|
338
300
|
});
|
|
339
301
|
});
|
|
340
302
|
} else {
|
|
341
|
-
this.response = New(HTTP2ServerResponse,{
|
|
342
|
-
domain:CONFIG.get("domain"),
|
|
343
|
-
basePath:CONFIG.get("basePath"),
|
|
344
|
-
projectPath:CONFIG.get("projectPath"),
|
|
345
|
-
server:server,
|
|
346
|
-
stream:stream,
|
|
347
|
-
request:request
|
|
303
|
+
this.response = New(HTTP2ServerResponse, {
|
|
304
|
+
domain: CONFIG.get("domain"),
|
|
305
|
+
basePath: CONFIG.get("basePath"),
|
|
306
|
+
projectPath: CONFIG.get("projectPath"),
|
|
307
|
+
server: server,
|
|
308
|
+
stream: stream,
|
|
309
|
+
request: request
|
|
348
310
|
});
|
|
349
311
|
}
|
|
350
312
|
|
|
351
313
|
} else {
|
|
352
314
|
// ...
|
|
353
315
|
|
|
354
|
-
this.response = New(HTTP2ServerResponse,{
|
|
355
|
-
domain:CONFIG.get("domain"),
|
|
356
|
-
basePath:CONFIG.get("basePath"),
|
|
357
|
-
projectPath:CONFIG.get("projectPath"),
|
|
358
|
-
server:server,
|
|
359
|
-
stream:stream,
|
|
360
|
-
request:request
|
|
316
|
+
this.response = New(HTTP2ServerResponse, {
|
|
317
|
+
domain: CONFIG.get("domain"),
|
|
318
|
+
basePath: CONFIG.get("basePath"),
|
|
319
|
+
projectPath: CONFIG.get("projectPath"),
|
|
320
|
+
server: server,
|
|
321
|
+
stream: stream,
|
|
322
|
+
request: request
|
|
361
323
|
});
|
|
362
324
|
|
|
363
325
|
}
|
|
@@ -365,5 +327,50 @@ Package("org.quickcorp.qcobjects.main.http2.server",[
|
|
|
365
327
|
});
|
|
366
328
|
|
|
367
329
|
}
|
|
368
|
-
|
|
369
|
-
|
|
330
|
+
|
|
331
|
+
showIPAddress() {
|
|
332
|
+
var _ret_ = "";
|
|
333
|
+
var os = require("os");
|
|
334
|
+
var ifaces = os.networkInterfaces();
|
|
335
|
+
Object.keys(ifaces).forEach(function (iface) {
|
|
336
|
+
ifaces[iface].map(function (ipGroup) {
|
|
337
|
+
_ret_ += iface + ": " + (new PipeLog()).pipe(ipGroup) + "\n";
|
|
338
|
+
});
|
|
339
|
+
});
|
|
340
|
+
return _ret_;
|
|
341
|
+
}
|
|
342
|
+
showPossibleURL() {
|
|
343
|
+
var _ret_ = "";
|
|
344
|
+
var os = require("os");
|
|
345
|
+
var ifaces = os.networkInterfaces();
|
|
346
|
+
Object.keys(ifaces).forEach(function (iface) {
|
|
347
|
+
ifaces[iface].map(function (ipGroup) {
|
|
348
|
+
if (ipGroup["family"].toLowerCase() == "ipv4") {
|
|
349
|
+
_ret_ += "http://" + ipGroup["address"] + ":" + CONFIG.get("serverPortHTTP").toString() + "/\n";
|
|
350
|
+
_ret_ += "https://" + ipGroup["address"] + ":" + CONFIG.get("serverPortHTTPS").toString() + "/\n";
|
|
351
|
+
}
|
|
352
|
+
});
|
|
353
|
+
});
|
|
354
|
+
return _ret_;
|
|
355
|
+
}
|
|
356
|
+
start() {
|
|
357
|
+
var server = this.server;
|
|
358
|
+
|
|
359
|
+
// http2 port is 8443 but normally is used 443 by replacing current https
|
|
360
|
+
|
|
361
|
+
const http = require("http");
|
|
362
|
+
|
|
363
|
+
const httpServer = http.createServer((req, res) => {
|
|
364
|
+
res.writeHead(301, {
|
|
365
|
+
Location: `https://${req.headers.host}${req.url}`
|
|
366
|
+
});
|
|
367
|
+
res.end();
|
|
368
|
+
});
|
|
369
|
+
|
|
370
|
+
httpServer.listen(CONFIG.get("serverPortHTTP"));
|
|
371
|
+
server.listen(CONFIG.get("serverPortHTTPS"));
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
]);
|
package/package.json
CHANGED
|
@@ -1,27 +1,31 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "qcobjects-cli",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.4.21",
|
|
4
4
|
"description": "qcobjects cli command line tool",
|
|
5
5
|
"main": "qcobjects-cli.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"sync": "git add . && git commit -am ",
|
|
8
|
-
"test": "npx eslint **/*.js --fix &&
|
|
9
|
-
"preversion": "npm
|
|
8
|
+
"test": "npx eslint **/*.js --fix && jasmine",
|
|
9
|
+
"preversion": "npm cache verify && npm test",
|
|
10
10
|
"postversion": "git push && git push --tags"
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"commander": "^2.20.3",
|
|
14
14
|
"mime": "^2.4.7",
|
|
15
|
-
"qcobjects": "^2.
|
|
16
|
-
"qcobjects-sdk": "
|
|
15
|
+
"qcobjects": "^2.4.32-beta",
|
|
16
|
+
"qcobjects-sdk": "^2.4.25",
|
|
17
17
|
"yaml": "^1.10.2"
|
|
18
18
|
},
|
|
19
19
|
"devDependencies": {
|
|
20
|
-
"eslint": "^8.
|
|
21
|
-
"eslint-config-qcobjects": "^0.0.
|
|
22
|
-
"jasmine": "^3.
|
|
23
|
-
"qcobjects": "^2.
|
|
24
|
-
"qcobjects-
|
|
20
|
+
"eslint": "^8.35.0",
|
|
21
|
+
"eslint-config-qcobjects": "^0.0.23",
|
|
22
|
+
"jasmine": "^3.99.0",
|
|
23
|
+
"qcobjects": "^2.4.32-beta",
|
|
24
|
+
"qcobjects-sdk": "^2.4.25"
|
|
25
|
+
},
|
|
26
|
+
"peerDependencies": {
|
|
27
|
+
"qcobjects": "^2.4.32-beta",
|
|
28
|
+
"qcobjects-sdk": "^2.4.25"
|
|
25
29
|
},
|
|
26
30
|
"repository": {
|
|
27
31
|
"type": "file",
|
|
@@ -61,5 +65,9 @@
|
|
|
61
65
|
"qcobjects-gae-server": "./qcobjects-gae-http-server.js",
|
|
62
66
|
"qcobjects-http-server": "./qcobjects-http-server.js",
|
|
63
67
|
"qcobjects-collab": "./qcobjects-collab.js"
|
|
68
|
+
},
|
|
69
|
+
"engines": {
|
|
70
|
+
"node": ">=14",
|
|
71
|
+
"npm": ">=9"
|
|
64
72
|
}
|
|
65
73
|
}
|
package/qcobjects-cli.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
/**
|
|
3
|
-
* QCObjects CLI 2.
|
|
3
|
+
* QCObjects CLI 2.4.x
|
|
4
4
|
* ________________
|
|
5
5
|
*
|
|
6
6
|
* Author: Jean Machuca <correojean@gmail.com>
|
|
@@ -65,22 +65,19 @@ require(absolutePath+"/org.quickcorp.qcobjects.cli");
|
|
|
65
65
|
|
|
66
66
|
let switchCommander;
|
|
67
67
|
|
|
68
|
-
|
|
69
|
-
|
|
68
|
+
class Main extends InheritClass {
|
|
69
|
+
constructor (){
|
|
70
|
+
super(...arguments);
|
|
70
71
|
let main = this;
|
|
71
72
|
|
|
72
|
-
switchCommander =
|
|
73
|
+
switchCommander = new SwitchCommander();
|
|
73
74
|
switchCommander.initCommand();
|
|
74
75
|
|
|
75
|
-
/*
|
|
76
|
-
let template = New(AppTemplate,{
|
|
77
|
-
compileAndSave:true
|
|
78
|
-
});
|
|
79
|
-
*/
|
|
80
76
|
logger.debug("initialized");
|
|
81
77
|
|
|
82
78
|
|
|
83
79
|
}
|
|
84
|
-
});
|
|
85
80
|
|
|
86
|
-
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
let __main__ = new Main ();
|
package/qcobjects-collab.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
/**
|
|
3
|
-
* QCObjects CLI 2.
|
|
3
|
+
* QCObjects CLI 2.4.x
|
|
4
4
|
* ________________
|
|
5
5
|
*
|
|
6
6
|
* Author: Jean Machuca <correojean@gmail.com>
|
|
@@ -39,13 +39,15 @@ require(absolutePath+"/org.quickcorp.qcobjects.defaultsettings.js");
|
|
|
39
39
|
|
|
40
40
|
require(absolutePath+"/org.quickcorp.qcobjects.collab.server.js");
|
|
41
41
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
42
|
+
class Main extends InheritClass {
|
|
43
|
+
constructor (){
|
|
44
|
+
super (...arguments);
|
|
45
|
+
const app = new CollabServer();
|
|
45
46
|
app.start();
|
|
46
47
|
|
|
47
48
|
logger.debug("initialized");
|
|
49
|
+
|
|
48
50
|
}
|
|
49
|
-
}
|
|
51
|
+
}
|
|
50
52
|
|
|
51
|
-
let __main__ =
|
|
53
|
+
let __main__ = new Main();
|