<commit_before>module.exports = function( web ) {

web.get( "/", function( request, response ) {
	var app = web.get( "debt" );

	if ( app.state === "database-setup" ) {
		return app.install(function( error ) {
			if ( error ) {
				return response.send( 500 );
			}

			app.state = "user-setup";
			return response.redirect( "/install" );
		});
	}

	if ( app.state === "user-setup" ) {
		return response.redirect( "/install" );
	}

	response.render( "home" );
});

web.get( "/install", web.authorize, function( request, response ) {
	var app = web.get( "debt" );

	// Prevent users from granting themselves admin rights after install
	if ( app.state === "installed" ) {
		return response.redirect( "/" );
	}

	app.permission.grantToUser( request.session.userId, "DEBT:ADMIN", function( error ) {
		if ( error ) {
			return response.send( 500 );
		}

		app.state = "installed";
		response.render( "installed" );
	});
});

};
<commit_msg>Routes: Store a common reference to the DEBT app<commit_after>module.exports = function( web ) {

var app = web.get( "debt" );

web.get( "/", function( request, response ) {
	if ( app.state === "database-setup" ) {
		return app.install(function( error ) {
			if ( error ) {
				return response.send( 500 );
			}

			app.state = "user-setup";
			return response.redirect( "/install" );
		});
	}

	if ( app.state === "user-setup" ) {
		return response.redirect( "/install" );
	}

	response.render( "home" );
});

web.get( "/install", web.authorize, function( request, response ) {

	// Prevent users from granting themselves admin rights after install
	if ( app.state === "installed" ) {
		return response.redirect( "/" );
	}

	app.permission.grantToUser( request.session.userId, "DEBT:ADMIN", function( error ) {
		if ( error ) {
			return response.send( 500 );
		}

		app.state = "installed";
		response.render( "installed" );
	});
});

};

{'fraction_non_alphanumeric': 0.17803837953091683, 'fraction_numerical': 0.006396588486140725, 'mean_word_length': 3.305045871559633, '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': '4847103', 'n_tokens_mistral': 695, 'n_tokens_neox': 614, 'n_words': 150}