<commit_before>module.exports = function (express, Category) {
    'use strict';

    var Router = express.Router();
    var _ = require('lodash');

    // DECLARATION

    Router.get('/:name', getCategoriesByName);

    return Router;

    // IMPLEMENTATION

    function getCategoriesByName(req, res) {
        if (req.isAuthenticated() && req.params.name) {
            Category.find({catName: req.params.name},
                '-_id -__v -catName')
                .populate('leaves', '-_id -__v')
                .exec(function (err, result) {
                    if (err) {
                        console.log(err);
                        res.status(500).end();
                    } else {
                        res.json(result);
                    }
                });
        } else {
            res.status(403).send('forbidden');
        }
    }
};<commit_msg>SG-20 Использовать bluebird/PromisifyAll для mongoose (/api/categories)<commit_after>module.exports = function (express, Category) {
    'use strict';

    var Router = express.Router();
    var _ = require('lodash');

    // DECLARATION

    Router.get('/:name', getCategoriesByName);

    return Router;

    // IMPLEMENTATION

    function getCategoriesByName(req, res) {
        if (!req.isAuthenticated() || !req.params.name) {
            return res.sendStatus(403);
        }

        Category.find({catName: req.params.name},
            '-_id -__v -catName')
            .populate('leaves', '-_id -__v')
            .then(function (result) {
                return res.json(result);
            })
            .catch(function(err){
                console.log(err);
                return res.sendStatus(500);
            });
    }
};
{'fraction_non_alphanumeric': 0.13845258871436883, 'fraction_numerical': 0.008144269924374637, 'mean_word_length': 1.5825825825825826, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7030439', 'n_tokens_mistral': 522, 'n_tokens_neox': 483, 'n_words': 88}