<commit_before>var express = require('express');
var router = express.Router();

var controller = require('../controllers');
var userController = controller.user;

var testApi = require('../test/api');


/* GET TEST page. */
router.get('/', function (req, res, next) {
    res.render('index', {title: 'Express'});
});


/*---------user------------*/
router.get('/user', userController.helloUser);

router.post('/login', userController.login);



/*--------mail-------------*/




/*--------test-------------*/
router.post('/test', testApi.testMail);



module.exports = router;<commit_msg>对大部分请求进行token验证<commit_after>var express = require('express');
var router = express.Router();

var controller = require('../controllers');
var userController = controller.user;

var testApi = require('../test/api');

/* GET TEST page. */
router.get('/', function (req, res, next) {
    res.render('index', {title: 'Express'});
});

router.post('/login', userController.login);

router.post('/test', testApi.testApi);


// route middleware to verify a token
router.use(function (req, res, next) {

    // check header or url parameters or post parameters for token
    var token = req.body.token || req.query.token || req.headers['x-access-token'];

    // decode token
    if (token) {

        // verifies secret and checks exp
        jwt.verify(token, app.get('superSecret'), function (err, decoded) {
            if (err) {
                return res.reply(1, 'Failed to authenticate token.');
            } else {
                // if everything is good, save to request for use in other routes
                req.decoded = decoded;
                next();
            }
        });

    } else {

        // if there is no token
        // return an error
        return res.reply(403, 'No token provided.');
    }
});

/*---------以下的接口都需要提供token-----------*/


/*---------user------------*/
router.get('/user', userController.helloUser);

router.post('/login', userController.login);



/*--------mail-------------*/




/*--------test-------------*/
router.post('/test', testApi.testApi);




module.exports = router;
{'fraction_non_alphanumeric': 0.22589792060491493, 'fraction_numerical': 0.001890359168241966, 'mean_word_length': 2.1739130434782608, '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': '4590496', 'n_tokens_mistral': 625, 'n_tokens_neox': 593, 'n_words': 155}