const predicates = async (req, res) => {
  const { predicates } = req;

  if (req.method === "POST") {
    const { enabled, headers } = req.body;

    predicates.headers = headers;

    if (predicates.enabled !== enabled) {
      predicates.onTogglePredicates();
    }

    predicates.enabled = enabled;
  }

  res.json({
    predicates,
  });
};

module.exports = predicates;
