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