joi-router.js
function makeBodyParser(spec) {
  if (!(spec.validate && spec.validate.type)) return noopMiddleware;

  switch (spec.validate.type) {
    case 'json':
      return wrapError(spec, makeJSONBodyParser(spec));
    case 'form':
      return wrapError(spec, makeFormBodyParser(spec));
    case 'stream':
    case 'multipart':
      return wrapError(spec, makeMultipartParser(spec));
    default:
      throw new Error(`unsupported body type: ${spec.validate.type}`);
  }
}
function makeBodyParser(spec) {
  if (!(spec.validate && spec.validate.type)) return noopMiddleware;

  switch (spec.validate.type) {
    case 'json':
      return wrapError(spec, makeJSONBodyParser(spec));
    case 'form':
      return wrapError(spec, makeFormBodyParser(spec));
    case 'stream':
    case 'multipart':
      return wrapError(spec, makeMultipartParser(spec));
    default:
      throw new Error(`unsupported body type: ${spec.validate.type}`);
  }
}
function makeBodyParser ( spec ) { if ( ! ( spec . validate && spec . validate . type ) ) return noopMiddleware ; switch ( spec . validate . type ) { case 'json' : return wrapError ( spec , makeJSONBodyParser ( spec ) ) ; case 'form' : return wrapError ( spec , makeFormBodyParser ( spec ) ) ; case 'stream' : case 'multipart' : return wrapError ( spec , makeMultipartParser ( spec ) ) ; default : throw new Error ( ` ${ spec . validate . type } ` ) ; } }
Creates body parser middleware.

@param {Object} spec
@return {async function}
@api private
Creates body parser middleware .