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 +6 -1
- package/MasterRouter.js +6 -1
- package/package.json +1 -1
package/MasterAction.js
CHANGED
|
@@ -109,7 +109,12 @@ class MasterAction{
|
|
|
109
109
|
return;
|
|
110
110
|
}
|
|
111
111
|
|
|
112
|
-
|
|
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
|
-
|
|
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