
export const middleware = (req, res, array: any[]): void => {
  let functionIndex = 0;

  const next = (...args) => {
    functionIndex++;

    if (functionIndex === array.length) return null;
    array[functionIndex](...args, next);
  };

  if (functionIndex === 0) array[0](req, res, next);
};
