import { Request, Response, NextFunction } from "express";


/**
 * Handles asyncronous rest calls
 * @param fn function to execute asyncronously
 */
export const asyncHandler =
  (fn: (req: Request, res: Response, next: NextFunction) => Promise<any>) =>
  (req: Request, res: Response, next: NextFunction) => {
    Promise.resolve(fn(req, res, next)).catch(next);
  };
