mastercontroller 1.3.27 → 1.3.28

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.
package/MasterAction.js CHANGED
@@ -109,7 +109,12 @@ class MasterAction{
109
109
  return;
110
110
  }
111
111
 
112
- this.__response.writeHead(HTTP_STATUS.OK, {
112
+ // Use status field from data as HTTP status code if it's a valid 4xx/5xx code
113
+ const httpStatus = (data && typeof data.status === 'number' && data.status >= 400 && data.status <= 599)
114
+ ? data.status
115
+ : HTTP_STATUS.OK;
116
+
117
+ this.__response.writeHead(httpStatus, {
113
118
  'Content-Type': 'application/json',
114
119
  'Content-Length': byteSize
115
120
  });
package/MasterRouter.js CHANGED
@@ -853,7 +853,12 @@ class MasterRouter {
853
853
  }
854
854
  return value;
855
855
  });
856
- requestObject.response.writeHead(200, {
856
+ // Use status field from return value as HTTP status code if it's a valid 4xx/5xx code
857
+ const httpStatus = (returnValue && typeof returnValue.status === 'number' && returnValue.status >= 400 && returnValue.status <= 599)
858
+ ? returnValue.status
859
+ : 200;
860
+
861
+ requestObject.response.writeHead(httpStatus, {
857
862
  'Content-Type': 'application/json',
858
863
  'Content-Length': Buffer.byteLength(json, 'utf8')
859
864
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mastercontroller",
3
- "version": "1.3.27",
3
+ "version": "1.3.28",
4
4
  "description": "Fortune 500 ready Node.js MVC framework with enterprise security, monitoring, and horizontal scaling",
5
5
  "main": "MasterControl.js",
6
6
  "license": "MIT",