<commit_before>var orm = require('orm'),
    Book = require('./models/book'),
    User = require('./models/user');

var connection = null;

function setupModels(orm, db) {
    var book  = Book.getModel(orm, db);
    var user = User.getModel(orm, db);
}

exports.init = function (app) {

    app.use(function (req, res, next) {

        if (connection) {
            req.db = connection;
            req.models = connection.models;
            next();
        }

        orm.connect('postgres://michelagopian:@127.0.0.1:5432/books', function (err, db) {
            if (err) {
                throw err;
            }

            connection = db;
            setupModels(orm, db);
            req.db = db;
            req.models = db.models;
            next();
        });
    });
};<commit_msg>Not saving connection in request<commit_after>var orm = require('orm'),
    Book = require('./models/book'),
    User = require('./models/user');

var connection = null;

function setupModels(orm, db) {
    var book  = Book.getModel(orm, db);
    var user = User.getModel(orm, db);
}

exports.init = function (app) {

    app.use(function (req, res, next) {

        if (connection) {
            req.db = connection;
            req.models = connection.models;
            next();
        }

        orm.connect('postgres://michelagopian:@127.0.0.1:5432/books', function (err, db) {
            if (err) {
                throw err;
            }

            setupModels(orm, db);
            req.models = db.models;
            next();
        });
    });
};
{'fraction_non_alphanumeric': 0.15093127809890816, 'fraction_numerical': 0.012845215157353885, 'mean_word_length': 1.7333333333333334, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '2514210', 'n_tokens_mistral': 489, 'n_tokens_neox': 466, 'n_words': 104}