@nodefony/http-bundle
Advanced tools
Comparing version 5.1.0 to 5.1.1
{ | ||
"name": "@nodefony/http-bundle", | ||
"version": "5.1.0", | ||
"version": "5.1.1", | ||
"description": "Nodefony Framework Bundle HTTP ", | ||
@@ -5,0 +5,0 @@ "contributors": [], |
@@ -26,17 +26,17 @@ const request = require("request"); | ||
switch (true) { | ||
case type === "string": | ||
this.baseUrl = url.parse(baseUrl); | ||
if (options) { | ||
this.options = nodefony.extend(true, this.options, options); | ||
} | ||
break; | ||
case type === "object": | ||
if (baseUrl instanceof nodefony.Service) { | ||
this.service = baseUrl; | ||
} else { | ||
this.options = nodefony.extend(true, this.options, baseUrl); | ||
} | ||
break; | ||
default: | ||
throw new nodefony.requestError("Bad argument type", null, service.container); | ||
case type === "string": | ||
this.baseUrl = url.parse(baseUrl); | ||
if (options) { | ||
this.options = nodefony.extend(true, this.options, options); | ||
} | ||
break; | ||
case type === "object": | ||
if (baseUrl instanceof nodefony.Service) { | ||
this.service = baseUrl; | ||
} else { | ||
this.options = nodefony.extend(true, this.options, baseUrl); | ||
} | ||
break; | ||
default: | ||
throw new nodefony.requestError("Bad argument type", null, service.container); | ||
} | ||
@@ -57,38 +57,37 @@ } | ||
switch (true) { | ||
case type === "string": | ||
if (uri === "") { | ||
if (this.baseUrl) { | ||
myurl = url.parse(this.baseUrl); | ||
case type === "string": | ||
if (uri === "") { | ||
if (this.baseUrl) { | ||
myurl = this.baseUrl; | ||
} else { | ||
throw new nodefony.requestError("http request Bad url", null, container); | ||
} | ||
} else { | ||
if (this.baseUrl) { | ||
if (/^\//.test(uri)) { | ||
if (/\/$/.test(this.baseUrl.path)) { | ||
uri = uri.replace(/\/(.*)/, "$1"); | ||
} | ||
myurl = url.parse(`${this.baseUrl.href}${uri}`); | ||
} else { | ||
throw new nodefony.requestError("http request Bad url", null, container); | ||
} | ||
} else { | ||
if (this.baseUrl) { | ||
if (/^\//.test(uri)) { | ||
if (/\/$/.test(this.baseUrl)) { | ||
uri = uri.replace(/\/(.*)/, "$1"); | ||
} | ||
if (/\/$/.test(this.baseUrl.path)) { | ||
myurl = url.parse(`${this.baseUrl.href}${uri}`); | ||
} else { | ||
if (/\/$/.test(this.baseUrl)) { | ||
myurl = url.parse(`${this.baseUrl.href}${uri}`); | ||
} else { | ||
myurl = url.parse(`${this.baseUrl.href}/${uri}`); | ||
} | ||
myurl = url.parse(`${this.baseUrl.href}/${uri}`); | ||
} | ||
} else { | ||
myurl = url.parse(uri); | ||
} | ||
} else { | ||
myurl = url.parse(uri); | ||
} | ||
if (options) { | ||
myoptions = nodefony.extend(true, myoptions, options); | ||
} | ||
myoptions.url = myurl; | ||
break; | ||
case type === "object": | ||
myoptions = nodefony.extend(true, myoptions, uri); | ||
break; | ||
default: | ||
throw new nodefony.requestError("http request Bad argument type", null, container); | ||
} | ||
if (options) { | ||
myoptions = nodefony.extend(true, myoptions, options); | ||
} | ||
myoptions.url = myurl; | ||
break; | ||
case type === "object": | ||
myoptions = nodefony.extend(true, myoptions, uri); | ||
break; | ||
default: | ||
throw new nodefony.requestError("http request Bad argument type", null, container); | ||
} | ||
@@ -95,0 +94,0 @@ this.logger(`${JSON.stringify(myoptions, null," ")}`, "DEBUG"); |
@@ -123,16 +123,16 @@ const Sockjs = require('sockjs'); | ||
switch (type) { | ||
case "HTTP": | ||
case "HTTPS": | ||
let proto = type.toLowerCase(); | ||
if (proto === this.protocol) { | ||
this.createServer(service, proto); | ||
if (type === "HTTP") { | ||
this.websocketServer = this.get("websocketServer"); | ||
} | ||
if (type === "HTTPS") { | ||
this.websocketServer = this.get("websocketServerSecure"); | ||
} | ||
this.fire("onCreateSockServer", this[proto], service); | ||
case "HTTP": | ||
case "HTTPS": | ||
let proto = type.toLowerCase(); | ||
if (proto === this.protocol) { | ||
this.createServer(service, proto); | ||
if (type === "HTTP") { | ||
this.websocketServer = this.get("websocketServer"); | ||
} | ||
break; | ||
if (type === "HTTPS") { | ||
this.websocketServer = this.get("websocketServerSecure"); | ||
} | ||
this.fire("onCreateSockServer", this[proto], service); | ||
} | ||
break; | ||
} | ||
@@ -151,3 +151,3 @@ }); | ||
this.logger("Add sock-js compiler : " + "SOCKJS_" + basename, "DEBUG"); | ||
this.log(config, "DEBUG"); | ||
this.log("dev config : " + config, "DEBUG"); | ||
if (this.compilers[basename].initsockClient) { | ||
@@ -249,14 +249,14 @@ this.removeListener("onConnection", this.compilers[basename].initsockClient); | ||
switch (type) { | ||
case "error": | ||
let myError = null; | ||
if (data.stack) { | ||
myError = data.stack; | ||
} else { | ||
myError = util.inspect(data); | ||
} | ||
return this.sockWrite("errors", [myError]); | ||
case "change": | ||
return this.sockWrite("content-changed"); | ||
default: | ||
return; | ||
case "error": | ||
let myError = null; | ||
if (data.stack) { | ||
myError = data.stack; | ||
} else { | ||
myError = util.inspect(data); | ||
} | ||
return this.sockWrite("errors", [myError]); | ||
case "change": | ||
return this.sockWrite("content-changed"); | ||
default: | ||
return; | ||
} | ||
@@ -295,2 +295,2 @@ } | ||
} | ||
}; | ||
}; |
175338
5155