<commit_before>// Module dependencies
var koa = require('koa'),
	co = require('co'),
	path = require('path'),
	commons = require('koa-common'),
	thunkify = require('thunkify'),
	glob = thunkify(require("glob")),
	bodyParser = require('koa-bodyparser'),
	config = require('./config');

exports = module.exports = Gaia;

function Gaia(appDir) {
	if (!(this instanceof Gaia)) return new Gaia(appDir);
	if (!appDir) {
		throw new Error("appDir can't be blank");
	}
	this._appDir = appDir;
	config._initialize(appDir);
	this.config = config;
	this._app = koa();
}

Gaia.prototype.initLog = function() {
	var log = require('./log');
	this.log = log.gaia;
	GLOBAL.Log = log.app;
}

Gaia.prototype.initMiddleware = function *() {
	if (config.application.session) {
		var session = require('koa-sess');
		this._app.keys = config.application.session.keys || ['default-session-keys'];
		this._app.use(session());
	}

	this._app.use(bodyParser());
	if (config.authentification) {
		var auth = config.authentification;
		
		var passport = require('koa-passport');
		yield auth.init(passport, this.database);
		
		this._app.use(passport.initialize());
		this._app.use(passport.session());
		GLOBAL.Passport = this.passport = passport;
	}
	
	if (config.application.views) {
		var views = require('koa-render'),
			viewDir = config.application.views.dir || path.resolve(this._appDir, 'views');
			options = config.application.views.options;

		this._app.use(views(viewDir, options));	
	}

	this._app.use(commons.favicon());
	this._app.use(commons.logger());
	this._app.use(commons.responseTime());
	this._app.use(commons.compress());


	//public
	var publicDir = "public",
		publicPath = "/public";

	if (config.application.public) {
		if (config.application.public.publicDir) publicDir = config.application.public.publicDir;
		if (config.application.public.publicPath) publicPath = config.application.public.publicPath
	}

	app.use(function *(next){<commit_msg>correction<commit_after>// Module dependencies
var koa = require('koa'),
	co = require('co'),
	path = require('path'),
	commons = require('koa-common'),
	thunkify = require('thunkify'),
	glob = thunkify(require("glob")),
	bodyParser = require('koa-bodyparser'),
	config = require('./config');

exports = module.exports = Gaia;

function Gaia(appDir) {
	if (!(this instanceof Gaia)) return new Gaia(appDir);
	if (!appDir) {
		throw new Error("appDir can't be blank");
	}
	this._appDir = appDir;
	config._initialize(appDir);
	this.config = config;
	this._app = koa();
}

Gaia.prototype.initLog = function() {
	var log = require('./log');
	this.log = log.gaia;
	GLOBAL.Log = log.app;
}

Gaia.prototype.initMiddleware = function *() {
	if (config.application.session) {
		var session = require('koa-sess');
		this._app.keys = config.application.session.keys || ['default-session-keys'];
		this._app.use(session());
	}

	this._app.use(bodyParser());
	if (config.authentification) {
		var auth = config.authentification;
		
		var passport = require('koa-passport');
		yield auth.init(passport, this.database);
		
		this._app.use(passport.initialize());
		this._app.use(passport.session());
		GLOBAL.Passport = this.passport = passport;
	}
	
	if (config.application.views) {
		var views = require('koa-render'),
			viewDir = config.application.views.dir || path.resolve(this._appDir, 'views');
			options = config.application.views.options;

		this._app.use(views(viewDir, options));	
	}

	this._app.use(commons.favicon());
	this._app.use(commons.logger());
	this._app.use(commons.responseTime());
	this._app.use(commons.compress());


	//public
	var publicDir = "public",
		publicPath = "/public";

	if (config.application.public) {
		if (config.application.public.publicDir) publicDir = config.application.public.publicDir;
		if (config.application.public.publicPath) publicPath = config.application.public.publicPath
	}

	this._app.use(function *(next){
{'fraction_non_alphanumeric': 0.16919127086007701, 'fraction_numerical': 0.0, 'mean_word_length': 4.597701149425287, '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': '5847408', 'n_tokens_mistral': 1360, 'n_tokens_neox': 1291, 'n_words': 237}