qcobjects-cli 2.3.50 → 2.4.22

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 (36) hide show
  1. package/.github/FUNDING.yml +12 -0
  2. package/.github/ISSUE_TEMPLATE/bug_report.md +38 -0
  3. package/.github/ISSUE_TEMPLATE/custom.md +10 -0
  4. package/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
  5. package/.github/ISSUE_TEMPLATE/issue-template.md +33 -0
  6. package/.github/workflows/codeql-analysis.yml +71 -0
  7. package/.github/workflows/npmpublish-beta.yml +38 -0
  8. package/.github/workflows/npmpublish-lts.yml +38 -0
  9. package/.github/workflows/npmpublish-main.yml +38 -0
  10. package/.gitlab-ci.yml +3 -2
  11. package/VERSION +1 -1
  12. package/backend/com.qcobjects.backend.microservice.static.js +40 -24
  13. package/backend/org.qcobjects.backend.php.js +149 -116
  14. package/{org.quickcorp.qcobjects.cli.commands.jira.client_services.js → com.qcobjects.cli.commands.jira.client_services.js} +29 -22
  15. package/{org.quickcorp.qcobjects.cli.commands.jira.js → com.qcobjects.cli.commands.jira.js} +77 -60
  16. package/{org.quickcorp.qcobjects.cli.commands.js → com.qcobjects.cli.commands.js} +3 -3
  17. package/com.qcobjects.cli.commands.version.js +285 -0
  18. package/org.qcobjects.common.pipelog.js +55 -0
  19. package/org.qcobjects.enterprise.commands.js +149 -139
  20. package/org.quickcorp.qcobjects.api.client_services.js +31 -20
  21. package/org.quickcorp.qcobjects.cli.js +288 -275
  22. package/org.quickcorp.qcobjects.collab.server.js +317 -308
  23. package/org.quickcorp.qcobjects.defaultsettings.js +1 -1
  24. package/org.quickcorp.qcobjects.main.file.js +100 -79
  25. package/org.quickcorp.qcobjects.main.http.gae.server.js +264 -232
  26. package/org.quickcorp.qcobjects.main.http.server.js +155 -145
  27. package/org.quickcorp.qcobjects.main.http2.server.js +198 -191
  28. package/package.json +18 -10
  29. package/qcobjects-cli.js +8 -11
  30. package/qcobjects-collab.js +8 -6
  31. package/qcobjects-createcert.js +28 -16
  32. package/qcobjects-gae-http-server.js +8 -5
  33. package/qcobjects-http-server.js +7 -5
  34. package/qcobjects-http2-server.js +8 -5
  35. package/qcobjects-shell.js +113 -107
  36. package/org.quickcorp.qcobjects.cli.commands.version.js +0 -267
@@ -1,5 +1,5 @@
1
1
  /**
2
- * QCObjects CLI 2.3.x
2
+ * QCObjects CLI 2.4.x
3
3
  * ________________
4
4
  *
5
5
  * Author: Jean Machuca <correojean@gmail.com>
@@ -31,39 +31,80 @@
31
31
  "use strict";
32
32
 
33
33
  const path = require("path");
34
- const absolutePath = path.resolve( __dirname, "./" );
34
+ const absolutePath = path.resolve(__dirname, "./");
35
35
 
36
36
  const fs = require("fs");
37
37
  const mime = require("mime");
38
- require(absolutePath+"/org.quickcorp.qcobjects.main.file.js");
38
+ require(absolutePath + "/org.quickcorp.qcobjects.main.file.js");
39
+ require(absolutePath+ "/org.qcobjects.common.pipelog.js");
39
40
 
40
- let ImportMicroservice = function (microservicePackage){
41
- var standardPath = findPackageNodePath(microservicePackage) || findPackageNodePath(microservicePackage+".js");
42
- if (standardPath !== null){
43
- Import (microservicePackage);
41
+ let ImportMicroservice = function (microservicePackage) {
42
+ var standardPath = findPackageNodePath(microservicePackage) || findPackageNodePath(microservicePackage + ".js");
43
+ if (standardPath !== null) {
44
+ Import(microservicePackage);
44
45
  } else {
45
- Import (absolutePath+"/backend/"+microservicePackage);
46
+ Import(absolutePath + "/backend/" + microservicePackage);
46
47
  }
47
48
  };
48
49
 
49
- Package("org.quickcorp.qcobjects.main.http.gae.server",[
50
- Class("BackendMicroservice",Object,{
51
- domain:CONFIG.get("domain"),
52
- basePath:CONFIG.get("basePath"),
53
- body:null,
54
- stream:null,
55
- server:null,
56
- request:null,
57
- cors: function (){
58
- if (this.route.cors){
59
- let {allow_origins,allow_credentials,allow_methods,allow_headers} = this.route.cors;
50
+ Package("org.quickcorp.qcobjects.main.http.gae.server", [
51
+
52
+ class BackendMicroservice extends InheritClass {
53
+
54
+ constructor(o) {
55
+ super(...arguments);
56
+ this.domain = CONFIG.get("domain");
57
+ this.basePath = CONFIG.get("basePath");
58
+ logger.debug("Executing GAE HTTP BackendMicroservice ");
59
+ let microservice = this;
60
+ let server = microservice.server;
61
+ let request = microservice.request;
62
+ this.cors();
63
+ microservice.req.on("data", (data) => {
64
+ // data from POST, GET
65
+ var requestMethod = request.method.toLowerCase();
66
+ var supportedMethods = {
67
+ "post": microservice.post,
68
+ };
69
+ if (supportedMethods.hasOwnProperty.call(supportedMethods, requestMethod)) {
70
+ supportedMethods[requestMethod].call(microservice, data);
71
+ }
72
+ });
73
+
74
+ // data from POST, GET
75
+ var requestMethod = request.method.toLowerCase();
76
+ var supportedMethods = {
77
+ "get": microservice.get,
78
+ "head": microservice.head,
79
+ "put": microservice.put,
80
+ "delete": microservice.delete,
81
+ "connect": microservice.connect,
82
+ "options": microservice.options,
83
+ "trace": microservice.trace,
84
+ "patch": microservice.patch
85
+ };
86
+ if (supportedMethods.hasOwnProperty.call(supportedMethods, requestMethod)) {
87
+ supportedMethods[requestMethod].call(microservice);
88
+ }
89
+
90
+
91
+ }
92
+
93
+ cors() {
94
+ if (this.route.cors) {
95
+ let {
96
+ allow_origins,
97
+ allow_credentials,
98
+ allow_methods,
99
+ allow_headers
100
+ } = this.route.cors;
60
101
  var microservice = this;
61
- if (typeof microservice.headers !== "object"){
102
+ if (typeof microservice.headers !== "object") {
62
103
  microservice.headers = {};
63
104
  }
64
- if (typeof allow_origins !== "undefined"){
105
+ if (typeof allow_origins !== "undefined") {
65
106
  // an example of allow_origins is ['https://example.com','http://www.example.com']
66
- if (allow_origins =="*" || (typeof microservice.request.headers.origin == "undefined") || [...allow_origins].indexOf(microservice.request.headers.origin)!== -1){
107
+ if (allow_origins == "*" || (typeof microservice.request.headers.origin == "undefined") || [...allow_origins].indexOf(microservice.request.headers.origin) !== -1) {
67
108
  // for compatibility with all browsers allways return a wildcard when the origin is allowed
68
109
  microservice.headers["Access-Control-Allow-Origin"] = "*";
69
110
  } else {
@@ -72,120 +113,96 @@ Package("org.quickcorp.qcobjects.main.http.gae.server",[
72
113
  this.body = {};
73
114
  try {
74
115
  this.done();
75
- } catch (e){}
116
+ } catch (e) {}
76
117
  }
77
118
  } else {
78
119
  microservice.headers["Access-Control-Allow-Origin"] = "*";
79
120
  }
80
- if (typeof allow_credentials !== "undefined"){
121
+ if (typeof allow_credentials !== "undefined") {
81
122
  microservice.headers["Access-Control-Allow-Credentials"] = allow_credentials.toString();
82
123
  } else {
83
124
  microservice.headers["Access-Control-Allow-Credentials"] = "true";
84
125
  }
85
- if (typeof allow_methods !== "undefined"){
126
+ if (typeof allow_methods !== "undefined") {
86
127
  microservice.headers["Access-Control-Allow-Methods"] = [...allow_methods].join(",");
87
128
  } else {
88
129
  microservice.headers["Access-Control-Allow-Methods"] = "GET, OPTIONS, POST";
89
130
  }
90
- if (typeof allow_headers !== "undefined"){
131
+ if (typeof allow_headers !== "undefined") {
91
132
  microservice.headers["Access-Control-Allow-Headers"] = [...allow_headers].join(",");
92
133
  } else {
93
134
  microservice.headers["Access-Control-Allow-Headers"] = "*";
94
135
  }
95
136
  }
96
- },
97
- _new_:function (o){
98
- logger.debug("Executing GAE HTTP BackendMicroservice ");
99
- let microservice = this;
100
- let server = microservice.server;
101
- let request = microservice.request;
102
- this.cors();
103
- microservice.req.on("data", (data) => {
104
- // data from POST, GET
105
- var requestMethod = request.method.toLowerCase();
106
- var supportedMethods = {"post":microservice.post,
107
- };
108
- if (supportedMethods.hasOwnProperty.call(supportedMethods,requestMethod)) {
109
- supportedMethods[requestMethod].call(microservice,data);
110
- }
111
- });
112
-
113
- // data from POST, GET
114
- var requestMethod = request.method.toLowerCase();
115
- var supportedMethods = {"get":microservice.get,
116
- "head":microservice.head,
117
- "put":microservice.put,
118
- "delete":microservice.delete,
119
- "connect":microservice.connect,
120
- "options":microservice.options,
121
- "trace":microservice.trace,
122
- "patch":microservice.patch
123
- };
124
- if (supportedMethods.hasOwnProperty.call(supportedMethods,requestMethod)) {
125
- supportedMethods[requestMethod].call(microservice);
126
- }
137
+ }
127
138
 
128
- },
129
- head:function (formData){this.done();},
130
- post:function (formData){this.done();},
131
- put:function (formData){this.done();},
132
- delete:function (formData){this.done();},
133
- connect:function (formData){this.done();},
134
- options:function (formData){this.done();},
135
- trace:function (formData){this.done();},
136
- patch:function (formData){this.done();},
137
- finishWithBody:function (stream){
139
+ head(formData) {
140
+ this.done();
141
+ }
142
+ post(formData) {
143
+ this.done();
144
+ }
145
+ put(formData) {
146
+ this.done();
147
+ }
148
+ delete(formData) {
149
+ this.done();
150
+ }
151
+ connect(formData) {
152
+ this.done();
153
+ }
154
+ options(formData) {
155
+ this.done();
156
+ }
157
+ trace(formData) {
158
+ this.done();
159
+ }
160
+ patch(formData) {
161
+ this.done();
162
+ }
163
+ finishWithBody(stream) {
138
164
  try {
139
165
  stream.write(JSON.stringify(this.body));
140
166
  stream.end();
141
- } catch (e){
142
- logger.debug("Something wrong writing the response for microservice"+e.toString());
167
+ } catch (e) {
168
+ logger.debug("Something wrong writing the response for microservice" + e.toString());
143
169
  }
144
- },
145
- done: function(){
170
+ }
171
+
172
+ done() {
146
173
  var microservice = this;
147
174
  var stream = microservice.stream;
148
175
  try {
149
176
  stream.writeHead(200, microservice.headers);
150
- } catch (e){
177
+ } catch (e) {
151
178
  logger.debug("Something went wront while sending headers in http...");
152
179
  logger.debug(e.toString());
153
180
  }
154
- if (microservice.body != null){
155
- microservice.finishWithBody.call(microservice,stream);
181
+ if (microservice.body != null) {
182
+ microservice.finishWithBody.call(microservice, stream);
156
183
  }
157
184
  }
158
- }),
159
- Class("PipeLog",{
160
- pipe:(o)=>{
161
- var _o = [];
162
- for (var k in o){
163
- if (typeof o[k] !== "undefined"
164
- && o[k] !== null
165
- && typeof o[k] !== "function"){
166
- try {
167
- _o.push(""+k+"="+o[k].toString());
168
- } catch (e){
169
- // error logging, do nothing
170
- }
171
- }
172
- }
173
- return _o.join(" ");
185
+
186
+ },
187
+
188
+ class HTTPServerResponse extends InheritClass {
189
+ constructor(o) {
190
+ super(...arguments);
191
+ var self = this;
192
+ self.body = "";
193
+ self.stream = o.stream;
194
+ self._generateResponse();
195
+ this.headers = {
196
+ ":status": 200,
197
+ "content-type": "text/html"
198
+ };
174
199
  }
175
- }),
176
- Class("HTTPServerResponse",{
177
- headers:{
178
- ":status": 200,
179
- "content-type": "text/html"
180
- },
181
- body:"",
182
- request:null,
183
- fileDispatcher:null,
184
- sendFile: function (stream, fileName) {
200
+
201
+ sendFile(stream, fileName) {
185
202
  // read and send file content in the stream
186
203
 
187
204
  try {
188
- console.log("trying to read "+ fileName);
205
+ console.log("trying to read " + fileName);
189
206
  const fd = fs.openSync(fileName, "r");
190
207
  const stat = fs.fstatSync(fd);
191
208
  const headers = {
@@ -210,17 +227,17 @@ Package("org.quickcorp.qcobjects.main.http.gae.server",[
210
227
  readStream.pipe(stream);
211
228
  });
212
229
 
213
- readStream.on("end",function (){
230
+ readStream.on("end", function () {
214
231
  stream.end();
215
232
  });
216
233
 
217
234
  // This catches any errors that happen while creating the readable stream (usually invalid names)
218
- readStream.on("error", function(err) {
235
+ readStream.on("error", function (err) {
219
236
  stream.end(err);
220
237
  });
221
238
 
222
- } catch (e){
223
- if (e.errno==-2){
239
+ } catch (e) {
240
+ if (e.errno == -2) {
224
241
  const headers = {
225
242
  ":status": 404,
226
243
  "content-type": "text/html"
@@ -232,94 +249,72 @@ Package("org.quickcorp.qcobjects.main.http.gae.server",[
232
249
  stream.end();
233
250
  }
234
251
  }
235
- },
236
- _generateResponse:function (){
252
+ }
253
+
254
+ _generateResponse() {
237
255
  var response = this;
238
- response.fileDispatcher = New(FileDispatcher,{
239
- scriptname:response.request.scriptname,
240
- pathname:response.request.pathname,
241
- done:function (headers,body,templateURI,isTemplate){
256
+ response.fileDispatcher = New(FileDispatcher, {
257
+ scriptname: response.request.scriptname,
258
+ pathname: response.request.pathname,
259
+ done(headers, body, templateURI, isTemplate) {
242
260
  response.headers = headers;
243
261
  var stream = response.stream;
244
- if (isTemplate){
262
+ if (isTemplate) {
245
263
  logger.debug("TEMPLATE");
246
264
  response.body = body;
247
- // stream.respond(response.headers);
265
+ // stream.respond(response.headers);
248
266
  stream.write(response.body);
249
267
  stream.end();
250
- } else if (headers[":status"]==200){
251
- response.sendFile(stream,templateURI);
268
+ } else if (headers[":status"] == 200) {
269
+ response.sendFile(stream, templateURI);
252
270
  } else {
253
271
  logger.debug("NONE ");
254
- // stream.respond(response.headers);
272
+ // stream.respond(response.headers);
255
273
  stream.end();
256
274
  }
257
275
  }
258
276
  });
259
277
 
260
- },
261
- _new_:function (o){
262
- var self = this;
263
- self.body = "";
264
- self.stream = o.stream;
265
- self._generateResponse();
278
+ }
279
+
280
+ },
281
+
282
+ class HTTPServerRequest extends InheritClass {
283
+
284
+ constructor({
285
+ scriptname = "",
286
+ path = "",
287
+ method = "",
288
+ url = "",
289
+ headers = null,
290
+ flags = null,
291
+ protocol = null,
292
+ slashes = null,
293
+ auth = null,
294
+ host = null,
295
+ port = null,
296
+ hostname = null,
297
+ hash = null,
298
+ search = "",
299
+ query = "",
300
+ pathname = "",
301
+ href = ""
302
+ }) {
303
+ super(...arguments);
266
304
 
267
305
  }
268
- }),
269
- Class("HTTPServerRequest",{
270
- scriptname:"",
271
- path:"",
272
- method:"",
273
- url:"",
274
- headers:null,
275
- flags:null,
276
- protocol: null,
277
- slashes: null,
278
- auth: null,
279
- host: null,
280
- port: null,
281
- hostname: null,
282
- hash: null,
283
- search: "",
284
- query: "",
285
- pathname: "",
286
- href: ""
287
- }),
288
- Class("HTTPServer",{
289
- request:null,
290
- response:"",
291
- server:null,
292
- scriptname:"",
293
- interceptorInstances:[],
294
- showIPAddress:function (){
295
- var _ret_ = "";
296
- var os = require("os");
297
- var ifaces = os.networkInterfaces();
298
- Object.keys(ifaces).forEach(function (iface){
299
- ifaces[iface].map(function (ipGroup){
300
- _ret_ += iface +": " + PipeLog.pipe(ipGroup)+"\n";
301
- });
302
- });
303
- return _ret_;
304
- },
305
- showPossibleURL: function (){
306
- var _ret_ = "";
307
- var os = require("os");
308
- var ifaces = os.networkInterfaces();
309
- Object.keys(ifaces).forEach(function (iface){
310
- ifaces[iface].map(function (ipGroup){
311
- if (ipGroup["family"].toLowerCase()=="ipv4"){
312
- _ret_ += "http://"+ipGroup["address"]+":"+CONFIG.get("serverPortHTTP").toString()+"/\n";
313
- }
314
- });
315
- });
316
- return _ret_;
317
- },
318
- start:function (){
319
- var server = this.server;
320
- server.listen(process.env.PORT || CONFIG.get("serverPortHTTP"));
321
- },
322
- _new_:function (){
306
+ },
307
+
308
+ class HTTPServer extends InheritClass {
309
+ constructor({
310
+ request = null,
311
+ response = "",
312
+ server = null,
313
+ scriptname = "",
314
+ interceptorInstances = []
315
+ }) {
316
+ super(...arguments);
317
+
323
318
  let oHTTPServer = this;
324
319
  const welcometo = "Welcome to \n";
325
320
  const instructions = "QCObjects Legacy HTTPServer \n";
@@ -328,8 +323,8 @@ Package("org.quickcorp.qcobjects.main.http.gae.server",[
328
323
  console.log(logo);
329
324
  console.log(instructions);
330
325
  logger.debug(this.showIPAddress());
331
- logger.info("Listening on HTTP PORT: "+CONFIG.get("serverPortHTTP").toString());
332
- logger.info("Go to: \n"+this.showPossibleURL());
326
+ logger.info("Listening on HTTP PORT: " + CONFIG.get("serverPortHTTP").toString());
327
+ logger.info("Go to: \n" + this.showPossibleURL());
333
328
 
334
329
  const http = require("http");
335
330
 
@@ -341,20 +336,20 @@ Package("org.quickcorp.qcobjects.main.http.gae.server",[
341
336
 
342
337
  server.on("error", (err) => console.error(err));
343
338
 
344
- if (global.get("backendAvailable")){
339
+ if (global.get("backendAvailable")) {
345
340
  logger.info("Loading backend interceptors...");
346
- let interceptors = CONFIG.get("backend",{}).interceptors;
347
- if (typeof interceptors !== "undefined"){
341
+ let interceptors = CONFIG.get("backend", {}).interceptors;
342
+ if (typeof interceptors !== "undefined") {
348
343
  logger.info("Backend Interceptors Available");
349
- interceptors.map(interceptor=>{
350
- ImportMicroservice (interceptor.microservice);
351
- var interceptorClassFactory = ClassFactory(interceptor.microservice+".Interceptor");
352
- var interceptorInstance = New(interceptorClassFactory,{
353
- domain:CONFIG.get("domain"),
354
- basePath:CONFIG.get("basePath"),
355
- projectPath:CONFIG.get("projectPath"),
356
- interceptor:interceptor,
357
- server:server
344
+ interceptors.map(interceptor => {
345
+ ImportMicroservice(interceptor.microservice);
346
+ var interceptorClassFactory = ClassFactory(interceptor.microservice + ".Interceptor");
347
+ var interceptorInstance = New(interceptorClassFactory, {
348
+ domain: CONFIG.get("domain"),
349
+ basePath: CONFIG.get("basePath"),
350
+ projectPath: CONFIG.get("projectPath"),
351
+ interceptor: interceptor,
352
+ server: server
358
353
  });
359
354
  oHTTPServer.interceptorInstances.push(interceptorInstance);
360
355
  });
@@ -363,86 +358,91 @@ Package("org.quickcorp.qcobjects.main.http.gae.server",[
363
358
 
364
359
  server.on("request", (req, res) => {
365
360
 
366
- let request = Object.assign(New(HTTPServerRequest),require("url").parse(req.url));
361
+ let request = Object.assign(New(HTTPServerRequest), require("url").parse(req.url));
367
362
  request.headers = req.headers;
368
363
  this.request = request;
369
364
  this.request.method = req.method;
370
365
  this.request.path = req.url;
371
366
  server.setMaxListeners(9999999999);
372
- CONFIG.set("backendTimeout",CONFIG.get("backendTimeout") || 20000);
373
- var timeoutHandler = ()=>{
367
+ CONFIG.set("backendTimeout", CONFIG.get("backendTimeout") || 20000);
368
+ var timeoutHandler = () => {
374
369
  // end the stream on timeout
375
370
  try {
376
- if (!res.destroyed){
371
+ if (!res.destroyed) {
377
372
  logger.info("A timeout occurred..." + CONFIG.get("backendTimeout").toString());
378
373
  logger.info("Killing session...");
379
374
 
380
- res.writeHeader( 500, {
375
+ res.writeHeader(500, {
381
376
  "content-type": "text/html"
382
377
  });
383
- res.on("error",()=>{});
378
+ res.on("error", () => {});
384
379
  res.write("<h1>500 - INTERNAL SERVER ERROR (TIMEOUT)</h1>");
385
380
  res.end();
386
381
  } else {
387
382
  logger.debug("Session was normally finishing...");
388
383
  }
389
- }catch (e){
384
+ } catch (e) {
390
385
  logger.debug("An unhandled error occurred during timeout catching...");
391
386
  logger.debug(e.message);
392
387
  }
393
- server.removeListener("timeout",timeoutHandler);
388
+ server.removeListener("timeout", timeoutHandler);
394
389
 
395
390
  };
396
- if (!res.destroyed){
391
+ if (!res.destroyed) {
397
392
  server.setTimeout(CONFIG.get("backendTimeout"), timeoutHandler);
398
393
  }
399
394
 
400
- if (this.request.pathname.indexOf(".")<0){
401
- this.request.scriptname = CONFIG.get("documentRootFileIndex");
395
+ if (this.request.pathname.indexOf(".") < 0) {
396
+ this.request.scriptname = CONFIG.get("documentRootFileIndex");
402
397
  } else {
403
398
  this.request.scriptname = this.request.pathname.split("/").reverse()[0];
404
399
  }
405
- this.request.pathname = this.request.pathname.substr(0,this.request.pathname.lastIndexOf("/"));
400
+ this.request.pathname = this.request.pathname.substr(0, this.request.pathname.lastIndexOf("/"));
406
401
 
407
- logger.debug(PipeLog.pipe(this.request));
402
+ logger.debug((new PipeLog()).pipe(this.request));
408
403
 
409
- if (global.get("backendAvailable")){
404
+ if (global.get("backendAvailable")) {
410
405
  logger.info("Backend GAE Microservices Available");
411
406
  let routes = CONFIG.get("backend").routes;
412
- let selectedRoute = routes.filter(route=>{let standardRoutePath = route.path.replace(/{(.*?)}/g,"(?<$1>.*)");return (new RegExp(standardRoutePath,"g")).test(request.path);});
413
- if (selectedRoute.length>0){
414
- selectedRoute.map(route=>{
415
- let standardRoutePath = route.path.replace(/{(.*?)}/g,"(?<$1>.*)"); //allowing {param}
416
- let selectedRouteParams = {...[...request.path.matchAll((new RegExp( standardRoutePath ,"g")))][0]["groups"]};
417
- ImportMicroservice (route.microservice);
418
- var microServiceClassFactory = ClassFactory(route.microservice+".Microservice");
419
- this.response = New(microServiceClassFactory,{
420
- domain:CONFIG.get("domain"),
421
- basePath:CONFIG.get("basePath"),
422
- projectPath:CONFIG.get("projectPath"),
423
- route:route,
424
- routeParams:selectedRouteParams,
425
- server:server,
426
- stream:res,
427
- req:req,
428
- request:request
407
+ let selectedRoute = routes.filter(route => {
408
+ let standardRoutePath = route.path.replace(/{(.*?)}/g, "(?<$1>.*)");
409
+ return (new RegExp(standardRoutePath, "g")).test(request.path);
410
+ });
411
+ if (selectedRoute.length > 0) {
412
+ selectedRoute.map(route => {
413
+ let standardRoutePath = route.path.replace(/{(.*?)}/g, "(?<$1>.*)"); //allowing {param}
414
+ let selectedRouteParams = {
415
+ ...[...request.path.matchAll((new RegExp(standardRoutePath, "g")))][0]["groups"]
416
+ };
417
+ ImportMicroservice(route.microservice);
418
+ var microServiceClassFactory = ClassFactory(route.microservice + ".Microservice");
419
+ this.response = New(microServiceClassFactory, {
420
+ domain: CONFIG.get("domain"),
421
+ basePath: CONFIG.get("basePath"),
422
+ projectPath: CONFIG.get("projectPath"),
423
+ route: route,
424
+ routeParams: selectedRouteParams,
425
+ server: server,
426
+ stream: res,
427
+ req: req,
428
+ request: request
429
429
  });
430
430
  });
431
431
  } else {
432
- this.response = New(HTTPServerResponse,{
433
- server:server,
434
- stream:res,
435
- request:this.request
432
+ this.response = New(HTTPServerResponse, {
433
+ server: server,
434
+ stream: res,
435
+ request: this.request
436
436
  });
437
437
  }
438
438
 
439
439
  } else {
440
440
  // ...
441
441
 
442
- this.response = New(HTTPServerResponse,{
443
- server:server,
444
- stream:res,
445
- request:this.request
442
+ this.response = New(HTTPServerResponse, {
443
+ server: server,
444
+ stream: res,
445
+ request: this.request
446
446
  });
447
447
 
448
448
  }
@@ -450,5 +450,37 @@ Package("org.quickcorp.qcobjects.main.http.gae.server",[
450
450
  });
451
451
 
452
452
  }
453
- })
454
- ]);
453
+
454
+ showIPAddress() {
455
+ var _ret_ = "";
456
+ var os = require("os");
457
+ var ifaces = os.networkInterfaces();
458
+ Object.keys(ifaces).forEach(function (iface) {
459
+ ifaces[iface].map(function (ipGroup) {
460
+ _ret_ += iface + ": " + (new PipeLog()).pipe(ipGroup) + "\n";
461
+ });
462
+ });
463
+ return _ret_;
464
+ }
465
+
466
+ showPossibleURL() {
467
+ var _ret_ = "";
468
+ var os = require("os");
469
+ var ifaces = os.networkInterfaces();
470
+ Object.keys(ifaces).forEach(function (iface) {
471
+ ifaces[iface].map(function (ipGroup) {
472
+ if (ipGroup["family"].toLowerCase() == "ipv4") {
473
+ _ret_ += "http://" + ipGroup["address"] + ":" + CONFIG.get("serverPortHTTP").toString() + "/\n";
474
+ }
475
+ });
476
+ });
477
+ return _ret_;
478
+ }
479
+
480
+ start() {
481
+ var server = this.server;
482
+ server.listen(process.env.PORT || CONFIG.get("serverPortHTTP"));
483
+ }
484
+ }
485
+
486
+ ]);