import healthCheck from './healthcheck';

// eslint-disable-next-line consistent-return
export default async services => async (req, res, next) => {
  if (req.url !== '/_health' || req.method !== 'GET') {
    return next();
  }

  const health = await healthCheck(services);
  res.status(200).send(health);
};

import healthCheck from './healthcheck';

const wrap = fn => (...args) => fn(...args).catch(args[2]);

// eslint-disable-next-line consistent-return
export default services => wrap(async (req, res, next) => {
  if (req.url !== '/_health' || req.method !== 'GET') {
    return next();
  }

  const health = await healthCheck(services);
  res.status(200).send(health);
});

Remove async and add function wrapper
Remove async and add function wrapper

Removed an unnecessary async from a function and add a wrapper for
catching async error
