"use strict";
const defaultHandler = (handlers) => async (req, res) => {
  const handler = (await handlers[req.method])?.default;
  if (!handler) {
    return res.status(405).json({ message: `Method Not Allowed (Allow: ${Object.keys(handlers).join(",")})` });
  }
  try {
    await handler(req, res);
    return;
  } catch (error) {
    console.error(error);
    return res.status(500).json({ message: "Something went wrong" });
  }
};
exports.defaultHandler = defaultHandler;
