import {info as logInfo, error as logError} from 'npmlog';

export default (handler) => {
  return async (request, response, next) => {
    logInfo('server', request.method + ' ' + request.url);
    try {
      const responseDescription = await handler(request) || {};
      objectToResponse(responseDescription, response);
      next();
    } catch (error) {
      logError('server', error);
      next(error);
    }
  };
};

function objectToResponse(responseDescription, response) {
  response.send(responseDescription.data ? responseDescription.data : '');
}

import {info as logInfo, error as logError} from 'npmlog';

export default (handler) => {
  return async (request, response, next) => {
    logInfo('server', request.method + ' ' + request.url);
    try {
      const responseInfo = await handler(request);
      objectToResponse(responseInfo, response);
      next();
    } catch (error) {
      logError('server', error);
      throw error;
    }
  };
};

function objectToResponse(responseInfo, response) {
  response.send(responseInfo.data ? responseInfo.data : null);
}

--- 
+++ 
@@ -4,16 +4,16 @@
   return async (request, response, next) => {
     logInfo('server', request.method + ' ' + request.url);
     try {
-      const responseInfo = await handler(request);
-      objectToResponse(responseInfo, response);
+      const responseDescription = await handler(request) || {};
+      objectToResponse(responseDescription, response);
       next();
     } catch (error) {
       logError('server', error);
-      throw error;
+      next(error);
     }
   };
 };
 
-function objectToResponse(responseInfo, response) {
-  response.send(responseInfo.data ? responseInfo.data : null);
+function objectToResponse(responseDescription, response) {
+  response.send(responseDescription.data ? responseDescription.data : '');
 }
Enable returning nothing in an endpoint

- this is the same as returning {}
