<commit_before>'use strict';

/**
 * Module dependencies.
 */
exports.index = function(req, res) {
	res.render('index', {
		user: req.user || null,
		request: req
	});
};

/**
 * Get root point for ReST API
 */
exports.getApiRootPoint = function(req, res) {
	var user 		= req.user,
		apiVersion	= req.apiVersion,
		isAdmin 	= (user && user.roles && user.roles.indexOf('admin') !== -1),
		response	= {};

	// Prepare response in JSON+HAL format.
	switch(apiVersion) {
		case '1':
			response = {
				_links: {
					self: {
						href: '/api/v1/'
					},
					lastApiVersion: {
						href: '/api/v1/'
					},
					curies: [
						{
							name: 'ht',
							href: '/api/v1/docs/{doc}',
							templated: true
						}
					],
					'ht:users': {
						href: '/api/v1/users'
					},
					'ht:me': {
						href: '/api/v1/users/' + user._id
					},
					'ht:groupbuys': {
						href: '/api/v1/groupbuys'
					}
				}
			};
			break;
		default: {
			response = {
				_links: {
					lastApiVersion: {
						href: '/api/v1/'
					}
				}
			};
		}

	}

	res.jsonp(response);
};


exports.versionByNumber = function(req, res, next, apiVersion) {
	req.apiVersion = apiVersion;
	next();
};<commit_msg>Added support in /api/v1 to unsigned users<commit_after>'use strict';

/**
 * Module dependencies.
 */
exports.index = function(req, res) {
	res.render('index', {
		user: req.user || null,
		request: req
	});
};

/**
 * Get root point for ReST API
 */
exports.getApiRootPoint = function(req, res) {
	var user 		= req.user,
		apiVersion	= req.apiVersion,
		isAdmin 	= (user && user.roles && user.roles.indexOf('admin') !== -1),
		response	= {};

	if (user === undefined || user._id === undefined) {
		apiVersion = 'nologin';
	}

	// Prepare response in JSON+HAL format.
	switch(apiVersion) {
		case '1':
			response = {
				_links: {
					self: {
						href: '/api/v1/'
					},
					lastApiVersion: {
						href: '/api/v1/'
					},
					curies: [
						{
							name: 'ht',
							href: '/api/v1/docs/{doc}',
							templated: true
						}
					],
					'ht:users': {
						href: '/api/v1/users'
					},
					'ht:me': {
						href: '/api/v1/users/' + user._id
					},
					'ht:groupbuys': {
						href: '/api/v1/groupbuys'
					}
				}
			};
			break;
		case 'nologin':
			response = {
				_links: {
					self: {
						href: '/api/v1/'
					},
					lastApiVersion: {
						href: '/api/v1/'
					},
					curies: [
						{
							name: 'ht',
							href: '/api/v1/docs/{doc}',
							templated: true
						}
					],
					'ht:login': {
						href: '/api/v1/users/login'
					}
				}
			};

			break;
		default: {
			response = {
				_links: {
					lastApiVersion: {
						href: '/api/v1/'
					}
				}
			};
		}

	}

	res.jsonp(response);
};


exports.versionByNumber = function(req, res, next, apiVersion) {
	req.apiVersion = apiVersion;
	next();
};
{'fraction_non_alphanumeric': 0.184256971408401, 'fraction_numerical': 0.008118602188492764, 'mean_word_length': 1.9007164790174003, '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': '4926590', 'n_tokens_mistral': 1457, 'n_tokens_neox': 1070, 'n_words': 198}