function wrap(fn, options, ctxFn) {
  async function middlewareWrapper(koaCtx, next) {
    try {
      const ctx = ctxFn(koaCtx);
      await fn(ctx, next);
    } catch (error) {
      // Auth error should trigger failure response
      response.errorResponse(options)(koaCtx, error);
    }
  }

  return middlewareWrapper;
}
//  Catches any errors and returns an error response
Catches any errors and returns an error response
Catches any errors and returns an error response
function wrap(fn, options, ctxFn) {
  async function middlewareWrapper(koaCtx, next) {
    try {
      const ctx = ctxFn(koaCtx);
      await fn(ctx, next);
    } catch (error) {
      response.errorResponse(options)(koaCtx, error);
    }
  }
  return middlewareWrapper;
}
function wrap ( fn , options , ctxFn ) { async function middlewareWrapper ( koaCtx , next ) { try { const ctx = ctxFn ( koaCtx ) ; await fn ( ctx , next ) ; } catch ( error ) { response . errorResponse ( options ) ( koaCtx , error ) ; } } return middlewareWrapper ; }
Catches any errors and returns an error response
Catches any errors and returns an error response
// Auth error should trigger failure response