mastercontroller 1.3.23 → 1.3.24

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.
Files changed (2) hide show
  1. package/MasterRouter.js +12 -1
  2. package/package.json +1 -1
package/MasterRouter.js CHANGED
@@ -832,7 +832,18 @@ class MasterRouter {
832
832
 
833
833
  // Execute action
834
834
  Promise.resolve(wrappedAction.call(control, requestObject))
835
- .then(() => {
835
+ .then((returnValue) => {
836
+ // Auto-send return value as JSON if controller returned data
837
+ // and no response was sent yet (e.g., overridden returnJson pattern)
838
+ if (returnValue !== undefined && returnValue !== null
839
+ && !requestObject.response.headersSent && !requestObject.response._headerSent) {
840
+ const json = JSON.stringify(returnValue);
841
+ requestObject.response.writeHead(200, {
842
+ 'Content-Type': 'application/json',
843
+ 'Content-Length': Buffer.byteLength(json, 'utf8')
844
+ });
845
+ requestObject.response.end(json);
846
+ }
836
847
  performanceTracker.end(requestId);
837
848
  // MEMORY LEAK FIX: Clean up event listeners
838
849
  _callEmit.removeAllListeners();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mastercontroller",
3
- "version": "1.3.23",
3
+ "version": "1.3.24",
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",