<commit_before>module.exports = function(mongoose, models){
	var User = models.User;
	var Station = models.Station;

	var express = require("express");
	var bodyParser = require("body-parser");
	var jwt = require("jsonwebtoken");

	var secret = "pone";
	var expiry = 60 * 60 * 24;
	var days = 60 * 60 * 24;

	var api = express.Router();

	api.use(bodyParser.json());
	api.use(bodyParser.urlencoded({extended : true}));

	function jwtAuth(req, res, next){
		var token = req.body.token || req.query.token || req.headers['x-access-token'];
		if(token){
			jwt.verify(token, app.get('superSecret'), function(err, decoded) {
				if(err){
					res.status(403).json({
						success: false,
						message: 'Failed to authenticate token.'
					});
					return;
				}else{
					req.decoded = decoded;
					next();
				}
			});
		}else{
			res.status(403).json({
				success : false,
				message : "No token available"
			});
			return;
		}
	}

	api.use(function(req, res, next){
		res.data = {};
		next();
	});

	api.post('/createuser', function(req, res, next){
		User.find({email : req.body.email, username : req.body.username}, function(err, user){
			if(err){
				res.json({
					success : false,
					message : "Internal database error"
				});
			}else if(user){
				res.json({
					success : false,
					message : "User already exists"
				});
			}else{
				var new_user = new User({
					username : req.body.username,
					email : req.body.email,
					password : <PASSWORD>
				});
				new_user.save(function(err){
					if(err){
						res.json({
							success : false,
							message : "Internal database error saving"
						})
					}else{
						var token = jwt.sign(user, secret, {expiresIn : expiry});
						res.json({
							success : true,
							message : "success",
							token : {token : token, expires : expiry / days}
						});
					}
				});
			}
		});
	});

	api.post('/login', function(req, res, next){
		User.findOne({username : req.body.username}, function(err, user){
			if(err){
				res.status(500).json({
					success : false,
					message : "Internal database error"
				});<commit_msg>small fixes<commit_after>module.exports = function(mongoose, models){
	var User = models.User;
	var Station = models.Station;

	var express = require("express");
	var bodyParser = require("body-parser");
	var jwt = require("jsonwebtoken");

	var secret = "pone";
	var expiry = 60 * 60 * 24;
	var days = 60 * 60 * 24;

	var api = express.Router();

	api.use(bodyParser.json());
	api.use(bodyParser.urlencoded({extended : true}));

	function jwtAuth(req, res, next){
		var token = req.body.token || req.query.token || req.headers['x-access-token'];
		if(token){
			jwt.verify(token, app.get('superSecret'), function(err, decoded) {
				if(err){
					res.status(403).json({
						success: false,
						message: 'Failed to authenticate token.'
					});
					return;
				}else{
					req.decoded = decoded;
					next();
				}
			});
		}else{
			res.status(403).json({
				success : false,
				message : "No token available"
			});
			return;
		}
	}

	api.use(function(req, res, next){
		res.data = {};
		next();
	});

	api.post('/createuser', function(req, res, next){
		User.findOne({email : req.body.email, username : req.body.username}, function(err, user){
			if(err){
				res.json({
					success : false,
					message : "Internal database error"
				});
			}else if(user){
				res.json({
					success : false,
					message : "User already exists"
				});
			}else{
				var new_user = new User({
					username : req.body.username,
					email : req.body.email,
					password : <PASSWORD>
				});
				new_user.save(function(err){
					if(err){
						res.json({
							success : false,
							message : "Internal database error saving"
						})
					}else{
						var token = jwt.sign(new_user, secret, {expiresIn : expiry});
						res.json({
							success : true,
							message : "success",
							token : {token : token, expires : expiry / days}
						});
					}
				});
			}
		});
	});

	api.post('/login', function(req, res, next){
		User.findOne({username : req.body.username}, function(err, user){
			if(err){
				res.status(500).json({
					success : false,
					message : "Internal database error"
				});
{'fraction_non_alphanumeric': 0.16567766437218134, 'fraction_numerical': 0.009969143128412059, 'mean_word_length': 2.6771378708551485, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '1701653', 'n_tokens_mistral': 1870, 'n_tokens_neox': 1386, 'n_words': 323}