<commit_before>// app/routes.js

var ArticleController = require('./controllers/article.js');
var InviteController = require('./controllers/invite.js');

module.exports = function (app, passport) {

	////////// RENDERING //////////

	// render static files
	app.get('/static/*', function (req, res) {
		// var uid = req.params.uid;
		var path = req.params[0] ? req.params[0] : 'index.html';
		res.sendfile(path, {
			root: './static'
		});
	});

	// render index
	app.get('/', function (req, res) {
		if (req.user) {
			res.redirect('/library');
		} else {
			res.render('index.ejs', {
				user: req.user
			});
		}
	});

	// render signup form
	app.get('/signup', function (req, res) {
		res.render('signup.ejs', {
			user: req.user,
			message: req.flash('signupMessage')
		});
	});

	// render signin form
	app.get('/signin', function (req, res) {
		res.render('signin.ejs', {
			user: req.user,
			message: req.flash('signinMessage')
		});
	});

	// render library
	app.get('/library', userIsSignedIn, ArticleController.getArticles, function (req, res) {
		res.render('library.ejs', {
			user: req.user,
			articles: res.locals,
			filter: req.query.filter
		});
	});

	// render add form
	app.get('/add', userIsSignedIn, function (req, res) {
		res.render('add.ejs', {
			user: req.user
		});
	});

	// render read article
	app.get('/read/:article_id', userIsSignedIn, ArticleController.getArticle, function (req, res) {
		res.render('read.ejs', {
			user: req.user,
			article: res.locals
		});
	});

	// render user account
	app.get('/account', userIsSignedIn, InviteController.getAllocatedInvites, function(req, res) {
		res.render('account.ejs', {
			user: req.user,
			invites: res.locals
		});
	});



	////////// PROCESSING //////////

	// process the signin form
	app.post('/signin', passport.authenticate('local-signin', {
		successRedirect: '/library',
		failureRedirect: '/signin',
		failureFlash: true
	}));

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

	// process the signup form
	app.post('/signup', passport.authenticate('local-signup', {
		successRedirect: '/library',
		failureRedirect: '/signup',
		failureFlash: true
	}));

	// process the add form
	app.post('/add', userIsSignedIn, ArticleController.addArticle, function (req, res) {
		res.redirect('/library');
	});

	// process article deletion
	app.delete('/delete/:article_id', userIsSignedIn, ArticleController.deleteArticle, function (req, res) {
		res.json(res.locals);
	});

	// create invite
	app.post('/invites/create', InviteController.addInvite, function (req, res) {
		res.json(res.locals);
	});

	// get unassigned invites
	app.get('/invites/unassigned', InviteController.getUnassignedInvites, function (req, res) {
		res.json(res.locals);
	});

	// get users allocated invites
	app.get('/invites/allocated', userIsSignedIn, InviteController.getAllocatedInvites, function (req, res) {
		res.json(res.locals);
	});
};<commit_msg>add archive and star paths to API route<commit_after>// app/routes.js

var ArticleController = require('./controllers/article.js');
var InviteController = require('./controllers/invite.js');

module.exports = function (app, passport) {

	////////// RENDERING //////////

	// render static files
	app.get('/static/*', function (req, res) {
		// var uid = req.params.uid;
		var path = req.params[0] ? req.params[0] : 'index.html';
		res.sendfile(path, {
			root: './static'
		});
	});

	// render index
	app.get('/', function (req, res) {
		if (req.user) {
			res.redirect('/library');
		} else {
			res.render('index.ejs', {
				user: req.user
			});
		}
	});

	// render signup form
	app.get('/signup', function (req, res) {
		res.render('signup.ejs', {
			user: req.user,
			message: req.flash('signupMessage')
		});
	});

	// render signin form
	app.get('/signin', function (req, res) {
		res.render('signin.ejs', {
			user: req.user,
			message: req.flash('signinMessage')
		});
	});

	// render library
	app.get('/library', userIsSignedIn, ArticleController.getArticles, function (req, res) {
		res.render('library.ejs', {
			user: req.user,
			articles: res.locals,
			filter: req.query.filter
		});
	});

	// render add form
	app.get('/add', userIsSignedIn, function (req, res) {
		res.render('add.ejs', {
			user: req.user
		});
	});

	// render read article
	app.get('/read/:article_id', userIsSignedIn, ArticleController.getArticle, function (req, res) {
		res.render('read.ejs', {
			user: req.user,
			article: res.locals
		});
	});

	// render user account
	app.get('/account', userIsSignedIn, InviteController.getAllocatedInvites, function(req, res) {
		res.render('account.ejs', {
			user: req.user,
			invites: res.locals
		});
	});



	////////// PROCESSING //////////

	// process the signin form
	app.post('/signin', passport.authenticate('local-signin', {
		successRedirect: '/library',
		failureRedirect: '/signin',
		failureFlash: true
	}));

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

	// process the signup form
	app.post('/signup', passport.authenticate('local-signup', {
		successRedirect: '/library',
		failureRedirect: '/signup',
		failureFlash: true
	}));

	// process the add form
	app.post('/add', userIsSignedIn, ArticleController.addArticle, function (req, res) {
		res.redirect('/library');
	});

	// process article deletion
	app.delete('/delete/:article_id', userIsSignedIn, ArticleController.deleteArticle, function (req, res) {
		res.json(res.locals);
	});

	// process article star/unstar
	app.put('/star/:article_id', userIsSignedIn, ArticleController.starArticle, function (req, res) {
		res.json(res.locals);
	});

	// process article achive/unarchive
	app.put('/archive/:article_id', userIsSignedIn, ArticleController.archiveArticle, function (req, res) {
		res.json(res.locals);
	});

	// create invite
	app.post('/invites/create', InviteController.addInvite, function (req, res) {
		res.json(res.locals);
	});

	// get unassigned invites
	app.get('/invites/unassigned', InviteController.getUnassignedInvites, function (req, res) {
		res.json(res.locals);
	});

	// get users allocated invites
	app.get('/invites/allocated', userIsSignedIn, InviteController.getAllocatedInvites, function (req, res) {
		res.json(res.locals);
	});
};
{'fraction_non_alphanumeric': 0.18901377236029762, 'fraction_numerical': 0.0006332119677061897, 'mean_word_length': 3.5322812051649928, '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': '4687017', 'n_tokens_mistral': 2366, 'n_tokens_neox': 2165, 'n_words': 433}