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

module.exports = function(db){
  router.post('/recipe', function(req, res){
    // post a new recipe and save to database
    var ingredients = req.body.ingredients.split(",");
    if (req.session.user.id == req.body.user_id){
      db.recipes.save({
        name: req.body.name,
        user_id: req.body.user_id,
        display_name: req.body.display_name,
        ingredients: ingredients,
        instructions: req.body.instructions,
        breakfast: req.body.breakfast || false,
        lunch: req.body.lunch || false,
        dinner: req.body.dinner || false,
        dessert: req.body.dessert || false,
        drink: req.body.drink || false
      },
      res.redirect.bind(res, '/')
      );
    }
  });

  router.delete('/recipe', function(req, res){
    // delete the specified recipe from database - should validate user
    db.recipes.findOne({
      id: req.recipe_id
    }, function(err, doc){
      if (!err){
        if (req.user.id == doc.user_id){
          db.recipes.remove({
            id: doc.id,
            user_id: doc.user_id
          }, function(err){
            res.redirect('/');
          });
        }
      }else{
        res.redirect('/');
      }
    })
  });

  router.get('/recipes', function(req, res){
    db.recipes.find(function(err, docs){
      res.render('recipes', {recipes: docs});
    });
  });

  router.get('/recipe/new', function(req, res){
    res.render('new', {user: req.session.user});
  })

  router.get('/recipe/:recipe_id', function(req, res){
    // view the requested recipe - should render view
    db.recipes.findOne({
      id: req.params.recipe_id
    }, function(err, doc){
      if (!err){
        res.render('recipe', doc);
      }else{
        res.redirect('/');
      }
    });
  });

  return router;
}<commit_msg>get the right parameter though :wolf:<commit_after>var express = require('express');
var router = express.Router();

module.exports = function(db){
  router.post('/recipe', function(req, res){
    // post a new recipe and save to database
    var ingredients = req.body.ingredients.split(",");
    if (req.session.user.id == req.body.user_id){
      db.recipes.save({
        name: req.body.name,
        user_id: req.body.user_id,
        display_name: req.body.display_name,
        ingredients: ingredients,
        instructions: req.body.instructions,
        breakfast: req.body.breakfast || false,
        lunch: req.body.lunch || false,
        dinner: req.body.dinner || false,
        dessert: req.body.dessert || false,
        drink: req.body.drink || false
      },
      res.redirect.bind(res, '/')
      );
    }
  });

  router.delete('/recipe', function(req, res){
    // delete the specified recipe from database - should validate user
    db.recipes.findOne({
      id: req.recipe_id
    }, function(err, doc){
      if (!err){
        if (req.user.id == doc.user_id){
          db.recipes.remove({
            id: doc.id,
            user_id: doc.user_id
          }, function(err){
            res.redirect('/');
          });
        }
      }else{
        res.redirect('/');
      }
    })
  });

  router.get('/recipes', function(req, res){
    db.recipes.find(function(err, docs){
      res.render('recipes', {recipes: docs});
    });
  });

  router.get('/recipe/new', function(req, res){
    res.render('new', {user: req.session.user});
  })

  router.get('/recipe/:recipe_id', function(req, res){
    // view the requested recipe - should render view
    console.log(req.params);
    db.recipes.findOne({
      id: new ObjectID(req.params.recipe_id)
    }, function(err, doc){
      if (!err){
        res.render('recipe', doc);
      }else{
        res.redirect('/');
      }
    });
  });

  return router;
}
{'fraction_non_alphanumeric': 0.16522195954820068, 'fraction_numerical': 0.0, 'mean_word_length': 2.2053872053872055, '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': '4356252', 'n_tokens_mistral': 1220, 'n_tokens_neox': 1217, 'n_words': 247}