<commit_before>'use strict';

module.exports = (router, models) => {
  let Question = models.Question;
  let jwtAuth = require(__dirname + '/../lib/jwtAuth.js');

  router.route('/questions')
    .get((req, res) => {
      Question.find({category: req.query.category, difficulty:req.query.difficulty}, (err, questions)=>{
        if(err){
          return res.json({message: err});
        }
        res.status(200).json({message: 'All Questions', data: questions});
      });
    })
    .post(jwtAuth, (req, res) => {
      let newQuestion = new Question(req.body);
      newQuestion.save((err, question)=>{
        if(err){
          return res.json({message: err});
        }
        res.status(200).json({message: 'Created Question', data: question});
      });
    });

  router.route('/questions/:question')
    .get((req, res) => {
      Question.findOne({_id: req.params.question}, (err, question)=>{
        if(err){
          return res.json({message: err});
        }
        res.status(200).json({message: 'Get Question', data: question});
      });
    })
    .put(jwtAuth, (req, res) => {<commit_msg>fixed routes to allow for 'all' as category<commit_after>'use strict';

module.exports = (router, models) => {
  let Question = models.Question;
  let jwtAuth = require(__dirname + '/../lib/jwtAuth.js');

  router.route('/questions')
    .get((req, res) => {
      let params;
      if (req.query.category = 'All') {
        params = {difficulty:req.query.difficulty}
      } else {
        params = {category: req.query.category, difficulty:req.query.difficulty}
      }
      Question.find(params, (err, questions)=>{
        if(err){
          return res.json({message: err});
        }
        res.status(200).json({message: 'All Questions', data: questions});
      });
    })
    .post(jwtAuth, (req, res) => {
      let newQuestion = new Question(req.body);
      newQuestion.save((err, question)=>{
        if(err){
          return res.json({message: err});
        }
        res.status(200).json({message: 'Created Question', data: question});
      });
    });

  router.route('/questions/:question')
    .get((req, res) => {
      Question.findOne({_id: req.params.question}, (err, question)=>{
        if(err){
          return res.json({message: err});
        }
        res.status(200).json({message: 'Get Question', data: question});
      });
    })
    .put(jwtAuth, (req, res) => {
{'fraction_non_alphanumeric': 0.1859983429991715, 'fraction_numerical': 0.007456503728251864, 'mean_word_length': 2.5255474452554743, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 19, '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': '5494595', 'n_tokens_mistral': 769, 'n_tokens_neox': 740, 'n_words': 149}