// This wraps the function to crash less and don't serve stack traces to the client
// Takes in an async function and returns a wrapped async function
const expressAsync =
  (func) =>
  (...args) => {
    const next = args[args.length - 1];
    return (async () => await func(...args))().catch(next);
  };

export default expressAsync;
