{"size": 486, "ext": "js", "max_stars_repo_path": "server/middleware/member.js", "max_stars_repo_name": "Flameuss/Flux-FIn", "max_stars_repo_stars_event_min_datetime": "2021-06-22T23:22:18.000Z", "max_stars_repo_stars_event_max_datetime": "2021-07-13T09:07:18.000Z", "max_issues_repo_path": "server/middleware/member.js", "max_issues_repo_name": "IghorMello/Flux-Fin", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "server/middleware/member.js", "max_forks_repo_name": "IghorMello/Flux-Fin", "max_forks_repo_forks_event_min_datetime": "2021-04-17T21:13:04.000Z", "max_forks_repo_forks_event_max_datetime": "2021-06-14T19:48:50.000Z"}
{"max_stars_count": 3, "max_issues_count": null, "max_forks_count": 5, "avg_line_length": 25.5789473684, "max_line_length": 68, "alphanum_fraction": 0.6358024691}
const Kambam = require('../models/Kambam');

module.exports = async function (req, res, next) {
  const kambam = await Kambam.findById(req.header('kambamId'));

  if (!kambam) {
    return res.status(404).json({ msg: 'Kanbam não encontrado' });
  }

  const members = kambam.members.map((member) => member.user);

  if (members.includes(req.user.id)) {
    next();
  } else {
    res.status(401).json({
      msg: 'Você deve ser membro deste kanbam para fazer alterações'
    });
  }
};