routing-controllers
Advanced tools
Comparing version 0.7.5 to 0.7.6
@@ -227,4 +227,7 @@ "use strict"; | ||
// set http status code | ||
if (result === undefined && action.undefinedResultCode && action.undefinedResultCode instanceof Function) { | ||
throw new action.undefinedResultCode(options); | ||
if (result === undefined && action.undefinedResultCode) { | ||
if (action.undefinedResultCode instanceof Function) { | ||
throw new action.undefinedResultCode(options); | ||
} | ||
options.response.status(action.undefinedResultCode); | ||
} | ||
@@ -278,3 +281,2 @@ else if (result === null) { | ||
if (action.undefinedResultCode) { | ||
options.response.status(action.undefinedResultCode); | ||
if (action.isJsonTyped) { | ||
@@ -281,0 +283,0 @@ options.response.json(); |
@@ -238,14 +238,2 @@ "use strict"; | ||
result = this.transformResult(result, action, options); | ||
// set http status code | ||
if (result === undefined && action.undefinedResultCode && action.undefinedResultCode instanceof Function) { | ||
throw new action.undefinedResultCode(options); | ||
} | ||
else if (result === null && action.nullResultCode) { | ||
if (action.nullResultCode instanceof Function) { | ||
throw new action.nullResultCode(options); | ||
} | ||
} | ||
else if (action.successHttpCode) { | ||
options.response.status = action.successHttpCode; | ||
} | ||
if (action.redirect) { | ||
@@ -278,13 +266,6 @@ if (typeof result === "string") { | ||
else if (result === undefined) { | ||
if (action.undefinedResultCode) { | ||
options.response.status = action.undefinedResultCode; | ||
if (action.isJsonTyped) { | ||
options.response.json(); | ||
} | ||
else { | ||
options.response.send(); | ||
} | ||
options.next(); | ||
if (action.undefinedResultCode instanceof Function) { | ||
throw new action.undefinedResultCode(options); | ||
} | ||
else { | ||
else if (!action.undefinedResultCode) { | ||
throw new index_1.NotFoundError(); | ||
@@ -294,16 +275,5 @@ } | ||
else if (result === null) { | ||
if (action.isJsonTyped) { | ||
options.response.body = null; | ||
} | ||
else { | ||
options.response.body = null; | ||
} | ||
// Setting `null` as a `response.body` means to koa that there is no content to return | ||
// so we must reset the status codes here. | ||
if (action.nullResultCode) { | ||
options.response.status = action.nullResultCode; | ||
} | ||
else { | ||
options.response.status = 204; | ||
} | ||
if (action.nullResultCode instanceof Function) | ||
throw new action.nullResultCode(options); | ||
options.response.body = null; | ||
} | ||
@@ -321,2 +291,16 @@ else if (result instanceof Uint8Array) { | ||
} | ||
// set http status code | ||
if (result === undefined && action.undefinedResultCode) { | ||
console.log(action.undefinedResultCode); | ||
options.response.status = action.undefinedResultCode; | ||
} | ||
else if (result === null && action.nullResultCode) { | ||
options.response.status = action.nullResultCode; | ||
} | ||
else if (action.successHttpCode) { | ||
options.response.status = action.successHttpCode; | ||
} | ||
else if (options.response.body === null) { | ||
options.response.status = 204; | ||
} | ||
// apply http headers | ||
@@ -335,9 +319,2 @@ Object.keys(action.headers).forEach(function (name) { | ||
if (_this.isDefaultErrorHandlingEnabled) { | ||
// set http status | ||
if (error instanceof index_1.HttpError && error.httpCode) { | ||
options.response.status = error.httpCode; | ||
} | ||
else { | ||
options.response.status = 500; | ||
} | ||
// apply http headers | ||
@@ -356,2 +333,9 @@ if (action) { | ||
} | ||
// set http status | ||
if (error instanceof index_1.HttpError && error.httpCode) { | ||
options.response.status = error.httpCode; | ||
} | ||
else { | ||
options.response.status = 500; | ||
} | ||
return resolve(); | ||
@@ -358,0 +342,0 @@ } |
{ | ||
"name": "routing-controllers", | ||
"private": false, | ||
"version": "0.7.5", | ||
"version": "0.7.6", | ||
"description": "Create structured, declarative and beautifully organized class-based controllers with heavy decorators usage for Express / Koa using TypeScript.", | ||
@@ -6,0 +6,0 @@ "license": "MIT", |
@@ -16,3 +16,3 @@ "use strict"; | ||
} | ||
else if (exported instanceof Object || typeof exported === 'object') { | ||
else if (exported instanceof Object || typeof exported === "object") { | ||
Object.keys(exported).forEach(function (key) { return loadFileClasses(exported[key], allLoaded); }); | ||
@@ -19,0 +19,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
524583
5620