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

const users = require('./users');
const feedback = require('./feedback');

router.use('/users', users);
router.use('/feedback', feedback);

module.exports = router;
<commit_msg>Add authenticate middleware<commit_after>const express = require('express');
const router = express.Router();
const path = require('path');
const jwt = require('jsonwebtoken');
const properties = require('../config/properties');


const users = require('./users');
const feedback = require('./feedback');


router.use(authenticateMiddleware(false));
router.use('/users', users);
router.use('/feedback', feedback);

function authenticateMiddleware(mustBeAdmin) {
    return function (req, res, next) {
        let accessGranted = false;
        let token = req.body.token || req.query.token || req.headers['x-access-token'];
        if (token) {
            jwt.verify(token, properties.jwt.secret, function(err, decoded) {
                if (err) {
                    res.sendFile(path.resolve('public/index.html'));
                }
                else {
                    if (mustBeAdmin == decoded.admin) {
                        next();
                    }
                }
            });  
        } else {
            res.sendFile(path.resolve('public/index.html'));
        }
    }
}

module.exports = router;

{'fraction_non_alphanumeric': 0.15251798561151078, 'fraction_numerical': 0.0, 'mean_word_length': 2.4688279301745637, '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': '2522169', 'n_tokens_mistral': 381, 'n_tokens_neox': 362, 'n_words': 79}