lib/app.js
function handleRequest(req, res, next) {
      setCors.call(this, req, res, verb);
      req.uniqueId = ++uniqueRequestId;
      req.startAt = Date.now();
      if (typeof req.body !== 'object' || !req.body || typeof req.body.type !== 'string' || req.body.type === '') {
        return next(thorin.error('TRANSPORT.INVALID_TYPE', 'Invalid or missing action type', 404));
      }
      let actionType = req.body.type,
        wasFound = true;
      if (!this[actions][actionType] || !this[actions][actionType].defaultHandle) {
        wasFound = false;
      } else {
        req.action = actionType;
      }
      if (!wasFound) {
        for (let i = 0, len = this[actionPatterns].length; i < len; i++) {
          let item = this[actionPatterns][i];
          if (item.match.test(actionType)) {
            wasFound = true;
            req.action = actionType;
            actionType = item.action;
            break;
          }
        }
      }
      if (!wasFound) {
        req._actionType = actionType;
        return handleRequestNotFound.call(this, req, res, next);
      }
      let payload = (typeof req.body.payload === 'object' && req.body.payload ? req.body.payload : {});
      if (typeof req.body.filter === 'object' && req.body.filter) {
        req.filter = req.body.filter;
      }
      if (typeof req.body.meta === 'object' && req.body.meta) {
        req.meta = req.body.meta;
      }
      req.url = req.action;
      req.body = payload;
      req.query = {};
      req.params = {};
      handleIncomingRequest.call(this, actionType, null, req, res, next);
    }
function handleRequest(req, res, next) {
      setCors.call(this, req, res, verb);
      req.uniqueId = ++uniqueRequestId;
      req.startAt = Date.now();
      if (typeof req.body !== 'object' || !req.body || typeof req.body.type !== 'string' || req.body.type === '') {
        return next(thorin.error('TRANSPORT.INVALID_TYPE', 'Invalid or missing action type', 404));
      }
      let actionType = req.body.type,
        wasFound = true;
      if (!this[actions][actionType] || !this[actions][actionType].defaultHandle) {
        wasFound = false;
      } else {
        req.action = actionType;
      }
      if (!wasFound) {
        for (let i = 0, len = this[actionPatterns].length; i < len; i++) {
          let item = this[actionPatterns][i];
          if (item.match.test(actionType)) {
            wasFound = true;
            req.action = actionType;
            actionType = item.action;
            break;
          }
        }
      }
      if (!wasFound) {
        req._actionType = actionType;
        return handleRequestNotFound.call(this, req, res, next);
      }
      let payload = (typeof req.body.payload === 'object' && req.body.payload ? req.body.payload : {});
      if (typeof req.body.filter === 'object' && req.body.filter) {
        req.filter = req.body.filter;
      }
      if (typeof req.body.meta === 'object' && req.body.meta) {
        req.meta = req.body.meta;
      }
      req.url = req.action;
      req.body = payload;
      req.query = {};
      req.params = {};
      handleIncomingRequest.call(this, actionType, null, req, res, next);
    }
function handleRequest ( req , res , next ) { setCors . call ( this , req , res , verb ) ; req . uniqueId = ++ uniqueRequestId ; req . startAt = Date . now ( ) ; if ( typeof req . body !== 'object' || ! req . body || typeof req . body . type !== 'string' || req . body . type === '' ) { return next ( thorin . error ( 'TRANSPORT.INVALID_TYPE' , 'Invalid or missing action type' , 404 ) ) ; } let actionType = req . body . type , wasFound = true ; if ( ! this [ actions ] [ actionType ] || ! this [ actions ] [ actionType ] . defaultHandle ) { wasFound = false ; } else { req . action = actionType ; } if ( ! wasFound ) { for ( let i = 0 , len = this [ actionPatterns ] . length ; i < len ; i ++ ) { let item = this [ actionPatterns ] [ i ] ; if ( item . match . test ( actionType ) ) { wasFound = true ; req . action = actionType ; actionType = item . action ; break ; } } } if ( ! wasFound ) { req . _actionType = actionType ; return handleRequestNotFound . call ( this , req , res , next ) ; } let payload = ( typeof req . body . payload === 'object' && req . body . payload ? req . body . payload : { } ) ; if ( typeof req . body . filter === 'object' && req . body . filter ) { req . filter = req . body . filter ; } if ( typeof req . body . meta === 'object' && req . body . meta ) { req . meta = req . body . meta ; } req . url = req . action ; req . body = payload ; req . query = { } ; req . params = { } ; handleIncomingRequest . call ( this , actionType , null , req , res , next ) ; }
/* Handle the POST method of /dispatch
/ * Handle the POST method of / dispatch