{"size": 679, "ext": "js", "max_stars_repo_path": "marriage-app/services/exceptionService.js", "max_stars_repo_name": "kamilslusarczyk/marriage_in_the_air", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "marriage-app/services/exceptionService.js", "max_issues_repo_name": "kamilslusarczyk/marriage_in_the_air", "max_issues_repo_issues_event_min_datetime": "2017-11-25T09:25:14.000Z", "max_issues_repo_issues_event_max_datetime": "2021-08-13T13:39:02.000Z", "max_forks_repo_path": "marriage-app/services/exceptionService.js", "max_forks_repo_name": "kamilslusarczyk/marriage-in-the-air", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": 8, "max_forks_count": null, "avg_line_length": 20.5757575758, "max_line_length": 53, "alphanum_fraction": 0.500736377}
HandleError = function (err, fn, res) {

    if (err) {
        if (fn)
            fn();

        return res.status(500).json({
            title: "An error occured",
            error: err
        })
    }
};
HandleNullValue = function (entity, res) {
    if (!entity) {
        return res.status(500).json({
            title: "Entity not found",
            error: {
                message: "Entity was not found in db"
            }
        })
    }
};

var MongoosHelper = {
    HandleRequest: function (err, fn, entity, res) {
        return HandleError(err, fn, res) ||
        HandleNullValue(entity, res);
    }
}

module.exports = {
    MongoosHelper: MongoosHelper
}