Comparing version 0.1.0-rc11 to 0.1.0-rc12
@@ -599,2 +599,10 @@ "use strict"; | ||
if (!response.data) { | ||
response.data = {}; | ||
} | ||
// add route info | ||
if (!response.data.__request_route__) { | ||
response.data.__request_route__ = this._getRouteInfo(); | ||
} | ||
if (response instanceof Error && !this.isERROR && !!router.getErrorRoute()) { | ||
@@ -610,3 +618,5 @@ // return new request | ||
// pass exception response over parsed url query as query parameter | ||
// assign to exception | ||
request.parsedUrl.query.exception = response; | ||
// set status codes for new request | ||
@@ -660,5 +670,5 @@ if (response.code) { | ||
} else if (!response) { | ||
throw new error.HttpError(500, {url: this.url}, 'No data to render'); | ||
throw new error.HttpError(500, {}, 'No data to render'); | ||
} else { | ||
throw new error.HttpError(500, {url: this.url}, 'Invalid response type, string or buffer is required!'); | ||
throw new error.HttpError(500, {}, 'Invalid response type, string or buffer is required!'); | ||
} | ||
@@ -778,7 +788,7 @@ | ||
} catch (e) { | ||
throw new error.HttpError(500, {path: controllerToLoad, url: this.url}, 'Missing controller', e); | ||
throw new error.HttpError(500, {path: controllerToLoad}, 'Missing controller', e); | ||
} | ||
if (!Type.assert(Type.FUNCTION, LoadedController)) { | ||
throw new error.HttpError(500, {path: controllerToLoad, url: this.url}, 'Controller must be function type'); | ||
throw new error.HttpError(500, {path: controllerToLoad}, 'Controller must be function type'); | ||
} | ||
@@ -801,8 +811,3 @@ | ||
controllerToLoad: controllerToLoad, | ||
route: { | ||
controller: this.controller, | ||
action: this.action, | ||
module: this.module, | ||
params: this.params | ||
} | ||
route: this._getRouteInfo() | ||
}); | ||
@@ -824,9 +829,3 @@ | ||
hasAction: controller.has(this.action), | ||
route: { | ||
url: this.url, | ||
controller: this.controller, | ||
action: this.action, | ||
module: this.module, | ||
params: this.params | ||
} | ||
route: this._getRouteInfo() | ||
}, 'Missing action in controller'); | ||
@@ -865,7 +864,7 @@ } | ||
} catch (e) { | ||
throw new error.HttpError(500, {path: moduleToLoad, url: this.url}, 'Missing module', e); | ||
throw new error.HttpError(500, {path: moduleToLoad}, 'Missing module', e); | ||
} | ||
if (!Type.assert(Type.FUNCTION, LoadedModule)) { | ||
throw new error.HttpError(500, {path: moduleToLoad, url: this.url}, 'Module must be function type'); | ||
throw new error.HttpError(500, {path: moduleToLoad}, 'Module must be function type'); | ||
} | ||
@@ -876,3 +875,3 @@ | ||
if (!(module instanceof ModuleInterface)) { | ||
throw new error.HttpError(500, {module: module, url: this.url}, 'Module must be instance of ModuleInterface "core/module"'); | ||
throw new error.HttpError(500, {module: module}, 'Module must be instance of ModuleInterface "core/module"'); | ||
} | ||
@@ -908,2 +907,27 @@ | ||
return this._handleController(di.getAlias('controllersPath'), di.getAlias('viewsPath')); | ||
}, | ||
/** | ||
* @since 0.0.1 | ||
* @author Igor Ivanovic | ||
* @method Request#_getRouteInfo | ||
* | ||
* @description | ||
* Return route info for easy debugging | ||
* @return {object} | ||
*/ | ||
_getRouteInfo: function Request__getRouteInfo() { | ||
return { | ||
id: this.id, | ||
url: this.url, | ||
controller: this.controller, | ||
action: this.action, | ||
module: this.module, | ||
params: this.params, | ||
method: this.getMethod(), | ||
requestDomain: this.getRequestDomain(), | ||
remoteAddress: this.getRequestRemoteAddress(), | ||
remotePort: this.getRequestRemotePort(), | ||
localAddress: this.getRequestLocalAddress(), | ||
localPort: this.getRequestLocalPort() | ||
}; | ||
} | ||
@@ -910,0 +934,0 @@ |
@@ -5,3 +5,3 @@ { | ||
"description": "Powerful lightweight mvc framework for nodejs", | ||
"version": "0.1.0-rc11", | ||
"version": "0.1.0-rc12", | ||
"dependencies": { | ||
@@ -8,0 +8,0 @@ "mongoose": "3.8.x", |
155855
5012