'use strict';

var path = process.cwd();
var ClickHandler = require(path + '/app/controllers/clickHandler.server.js');

module.exports = function (app, passport) {

	function isLoggedIn (req, res, next) {
		if (req.isAuthenticated()) {
			return next();
		} else {
			res.redirect('/login');
		}
	}

	var clickHandler = new ClickHandler();

	app.route('/')
		.get(isLoggedIn, function (req, res) {
			res.sendFile(path + '/public/index.html');
		});

	app.route('/login')
		.get(function (req, res) {
			res.sendFile(path + '/public/login.html');
		});

	app.route('/logout')
		.get(function (req, res) {
			req.logout();
			res.redirect('/login');
		});

	app.route('/profile')
		.get(isLoggedIn, function (req, res) {
			res.sendFile(path + '/public/profile.html');
		});

	app.route('/api/:id')
		.get(isLoggedIn, function (req, res) {
			res.json(req.user.github);
		});

	app.route('/auth/github')
		.get(passport.authenticate('github'));

	app.route('/auth/github/callback')
		.get(passport.authenticate('github', {
			successRedirect: '/',
			failureRedirect: '/login'
		}));

	app.route('/api/:id/clicks')
		.get(isLoggedIn, clickHandler.getClicks)
		.post(isLoggedIn, clickHandler.addClick)
		.delete(isLoggedIn, clickHandler.resetClicks);
};

@@ -38,306 +38,42 @@
 ();%0A
-var ClickHandler = require(path + '/app/controllers/clickHandler.server.js');%0A%0Amodule.exports = function (app, passport) %7B%0A%0A%09function isLoggedIn (req, res, next) %7B%0A%09%09if (req.isAuthenticated()) %7B%0A%09%09%09return next();%0A%09%09%7D else %7B%0A%09%09%09res.redirect('/login');%0A%09%09%7D%0A%09%7D%0A%0A%09var clickHandler = new ClickHandler();
+%0Amodule.exports = function (app) %7B
 %0A%0A%09a
@@ -89,36 +89,24 @@
 '/')%0A%09%09.get(
-isLoggedIn, 
 function (re
@@ -170,807 +170,8 @@
 %09%7D);
-%0A%0A%09app.route('/login')%0A%09%09.get(function (req, res) %7B%0A%09%09%09res.sendFile(path + '/public/login.html');%0A%09%09%7D);%0A%0A%09app.route('/logout')%0A%09%09.get(function (req, res) %7B%0A%09%09%09req.logout();%0A%09%09%09res.redirect('/login');%0A%09%09%7D);%0A%0A%09app.route('/profile')%0A%09%09.get(isLoggedIn, function (req, res) %7B%0A%09%09%09res.sendFile(path + '/public/profile.html');%0A%09%09%7D);%0A%0A%09app.route('/api/:id')%0A%09%09.get(isLoggedIn, function (req, res) %7B%0A%09%09%09res.json(req.user.github);%0A%09%09%7D);%0A%0A%09app.route('/auth/github')%0A%09%09.get(passport.authenticate('github'));%0A%0A%09app.route('/auth/github/callback')%0A%09%09.get(passport.authenticate('github', %7B%0A%09%09%09successRedirect: '/',%0A%09%09%09failureRedirect: '/login'%0A%09%09%7D));%0A%0A%09app.route('/api/:id/clicks')%0A%09%09.get(isLoggedIn, clickHandler.getClicks)%0A%09%09.post(isLoggedIn, clickHandler.addClick)%0A%09%09.delete(isLoggedIn, clickHandler.resetClicks);
 %0A%7D;%0A

clean index.js