Comparing version 0.1.0-beta-26 to 0.1.0-beta-27
@@ -51,2 +51,3 @@ "use strict"; | ||
this.body = ''; | ||
this.isERROR = false; | ||
// body and isForwarded can be overriden | ||
@@ -60,3 +61,2 @@ core.extend(this, config); | ||
this.isPromiseChainStopped = false; | ||
this.isERROR = false; | ||
this.isRendered = false; | ||
@@ -415,2 +415,7 @@ this.id = this._uuid(); | ||
var request; | ||
// stop current chain!!! | ||
this.stopPromiseChain(); | ||
if (response instanceof Error && !this.isERROR && !!router.getErrorRoute()) { | ||
@@ -422,5 +427,15 @@ if (response.code) { | ||
} | ||
this.isERROR = true; | ||
this.module = null; // refresh module state because we are returning route | ||
return this._resolveRoute([router.getErrorRoute(), response]); | ||
// return new request | ||
request = new Request({ | ||
request: this.request, | ||
response: this.response, | ||
isForwarded: true, | ||
body: this.body, | ||
isERROR: true | ||
}, router.getErrorRoute()); | ||
// pass exception response over parsed url query as query parameter | ||
request.parsedUrl.query.exception = response; | ||
// return parsed request | ||
return request.parse(); | ||
} else if (response.trace) { | ||
@@ -427,0 +442,0 @@ this.addHeader('Content-Type', 'text/plain'); |
@@ -130,2 +130,18 @@ "use strict"; | ||
* @author Igor Ivanovic | ||
* @method DI#refereshNodeModuleCache | ||
* | ||
* @description | ||
* Reset file cache | ||
*/ | ||
refereshNodeModuleCache: function DI_refereshNodeModuleCache(file) { | ||
var path = this.getFilePath(file), | ||
key = require.resolve(path + '.js'); | ||
// because all modules in node are cached while executing tests we want to delete cached version | ||
delete require.cache[key]; | ||
return path; | ||
}, | ||
/** | ||
* @since 0.0.1 | ||
* @author Igor Ivanovic | ||
* @method DI#mockLoad | ||
@@ -147,8 +163,4 @@ * | ||
if (Type.isString(file)) { | ||
// get file | ||
path = this.getFilePath(file); | ||
// because all modules in node are cached while executing tests we want to delete cached version | ||
delete require.cache[require.resolve(path + '.js')]; | ||
// do require | ||
return require(path); | ||
return require(this.refereshNodeModuleCache(file)); | ||
@@ -155,0 +167,0 @@ } else if (Type.isFunction(file)) { |
@@ -5,3 +5,3 @@ { | ||
"description": "Powerful lightweight mvc framework for nodejs", | ||
"version": "0.1.0-beta-26", | ||
"version": "0.1.0-beta-27", | ||
"dependencies" : { | ||
@@ -8,0 +8,0 @@ "mongoose": "3.8.x", |
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
124628
4008