<commit_before>module.exports = function(projects) {
    'use strict';
    const parse = require('co-body');
    return {
        all: all,
        dirTree: dirTree,
        update: update
    };

    /////////////////

    function* all(next) {
        let user = this.reqctx.user;
        this.body = yield projects.forUser(user);
        yield next;
    }

    function* update(next) {
        let attrs = yield parse(this);
        this.body = yield projects.update(this.params.project_id, attrs);
        yield next;
    }

    function* dirTree(next) {
        let dirID = this.params.directory_id || 'top';
        this.body = yield projects.dirTree(this.params.project_id, dirID);
        yield next;
    }

};
<commit_msg>Is this the 'right' refactoring of projects.js<commit_after>module.exports = function(projects) {
    'use strict';
    const parse = require('co-body');
    return {
        all: all,
        dirTree: dirTree,
        update: update,
        _allProjectsForUser: _allProjectsForUser
    };

    /////////////////

    function* all(next) {
        let user = this.reqctx.user;
        this.body = _allProjectForUser(user);
        yield next;
    }

    function* update(next) {
        let attrs = yield parse(this);
        this.body = yield projects.update(this.params.project_id, attrs);
        yield next;
    }

    function* dirTree(next) {
        let dirID = this.params.directory_id || 'top';
        this.body = yield projects.dirTree(this.params.project_id, dirID);
        yield next;
    }

    function* _allProjectsForUser(user) {
        return yield projects.forUser(user);
    }

};

{'fraction_non_alphanumeric': 0.13394495412844037, 'fraction_numerical': 0.0, 'mean_word_length': 2.069418386491557, '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': '5552834', 'n_tokens_mistral': 498, 'n_tokens_neox': 492, 'n_words': 108}