<commit_before>'use strict';

var swig = require('swig'),
    mongoose = require('mongoose'),
    passport = require('passport'),
    container = require('dependable').container(),
    fs = require('fs'),
    path = require('path'),
    util = require('./util'),
    EventEmitter = require('events').EventEmitter;

var events = new EventEmitter(),
    Mean, modules = [],
    menus, config,
    allMenus = [],
    middleware = {
        before: {},
        after: {}
    },
    aggregated = {
        js: '',
        css: ''
    };

function Meanio() {
    if (this.active) return;
    Mean = this;
    this.events = events;
    this.version = require('../package').version;
}

Meanio.prototype.serve = function(options, callback) {

    if (this.active) return this;

    // Initializing system variables
    var defaultConfig = util.loadConfig();

    var database = mongoose.connect(defaultConfig.db || '', function(err) {
        if (err) {
            console.error('Error:', err.message);
            return console.error('**Could not connect to MongoDB. Please ensure mongod is running and restart MEAN app.**');
        }

        // Register database dependency
        this.register('database', {
            connection: database
        });

        this.config = new Config(function(err, config) {
            // Bootstrap Models, Dependencies, Routes and the app as an express app
            var app = require('./bootstrap')(passport, database);

            // Start the app by listening on <port>, optional hostname
            app.listen(config.port, config.hostname);
            console.log('Mean app started on port ' + config.port + ' (' + process.env.NODE_ENV + ')');

            findModules(function() {
                enableModules();
            });
            aggregate('js', null);

            Mean.name = config.app.name;
            Mean.app = app;
<commit_msg>this not available within a function<commit_after>'use strict';

var swig = require('swig'),
    mongoose = require('mongoose'),
    passport = require('passport'),
    container = require('dependable').container(),
    fs = require('fs'),
    path = require('path'),
    util = require('./util'),
    EventEmitter = require('events').EventEmitter;

var events = new EventEmitter(),
    Mean, modules = [],
    menus, config,
    allMenus = [],
    middleware = {
        before: {},
        after: {}
    },
    aggregated = {
        js: '',
        css: ''
    };

function Meanio() {
    if (this.active) return;
    Mean = this;
    this.events = events;
    this.version = require('../package').version;
}

Meanio.prototype.serve = function(options, callback) {

    if (this.active) return this;

    // Initializing system variables
    var defaultConfig = util.loadConfig();

    var database = mongoose.connect(defaultConfig.db || '', function(err) {
        if (err) {
            console.error('Error:', err.message);
            return console.error('**Could not connect to MongoDB. Please ensure mongod is running and restart MEAN app.**');
        }

        // Register database dependency
        Mean.register('database', {
            connection: database
        });

        Mean.config = new Config(function(err, config) {
            // Bootstrap Models, Dependencies, Routes and the app as an express app
            var app = require('./bootstrap')(passport, database);

            // Start the app by listening on <port>, optional hostname
            app.listen(config.port, config.hostname);
            console.log('Mean app started on port ' + config.port + ' (' + process.env.NODE_ENV + ')');

            findModules(function() {
                enableModules();
            });
            aggregate('js', null);

            Mean.name = config.app.name;
            Mean.app = app;

{'fraction_non_alphanumeric': 0.13907110994489635, 'fraction_numerical': 0.0, 'mean_word_length': 2.230508474576271, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '6735839', 'n_tokens_mistral': 1028, 'n_tokens_neox': 1017, 'n_words': 269}