{"size": 474, "ext": "js", "max_stars_repo_path": "src/api/middlewares/is-artist.js", "max_stars_repo_name": "maltahan/build-and-secure-restful-api-with-mongodb", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/api/middlewares/is-artist.js", "max_issues_repo_name": "maltahan/build-and-secure-restful-api-with-mongodb", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/api/middlewares/is-artist.js", "max_forks_repo_name": "maltahan/build-and-secure-restful-api-with-mongodb", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 39.5, "max_line_length": 88, "alphanum_fraction": 0.6518987342}
const { ARTIST_ROLE } = require('../middlewares/userRules');

//this function accept as third argument a function, indicates do the next action
const isArtist = (req, res, next) => {
    //console.log(req.user.role + "  " + req.user.firstName + " " + typeof ARTIST_ROLE);
    // to be fixed why ARTIST_ROLE is undefined
    if (req.user.role !== ARTIST_ROLE) {
        return res.json({ err: 'unauthorized, not an artists' });
    }
    next();
};
module.exports = isArtist;