<commit_before>//Array to store users
var users = [];

exports.printMethodUrl = function(req, res){
  res.send(req.method+' '+req.url);
};

//Creating user method
exports.create = function(req, res){
  var user = req.body.user;
  if(user){
    user.id = parseInt(user.id);
    users.push(user);
    res.send('Created!');
  }
  else{
    res.send('Invalid input, try again');
  }
}

//Reading users array method
exports.read = function(req, res){
  res.send(JSON.stringify(users));
};

//Update user info method
exports.update = function(req, res){
  var user = req.body.user;
  if(user){
    user.id = parseInt(user.id);
    for(var i = 0; i < users.length; i++){
      if(users[i].id===user.id){
        users[i] = user;
        res.send('User updated!');
      }
      else{
        res.send('User not found');
      }  
    }
  }
  else {
    res.send('Invalid input, try again');
  }
};

//Delete user method
exports.delete = function(req, res){
  var user = req.body.user;
  if(user){
    user.id = parseInt(user.id);
    for(var i = 0; i < users.length; i++){
      if(users[i].id===user.id){
        users.splice(i);
        res.send('User deleted!');
      }
      else{
        res.send('User not found');
      }  
    }
  }
  else {
    res.send('Invalid input, try again');
  }
};<commit_msg>Adding HTTP codes and JSON in response<commit_after>//Array to store users
var users = [];

exports.printMethodUrl = function(req, res){
  res.json(req.method+' '+req.url);
};

//Creating user method
exports.create = function(req, res){
  var user = req.body.user;
  if(user){
    user.id = parseInt(user.id);
    users.push(user);
    res.json(200, {message: 'User created!'});
  }
  else{
    res.json(400, {message: 'Invalid input, try again'});
  }
}

//Reading users array method
exports.read = function(req, res){
  res.json(200, JSON.stringify(users));
};

//Update user info method
exports.update = function(req, res){
  var user = req.body.user;
  if(user){
    user.id = parseInt(user.id);
    for(var i = 0; i < users.length; i++){
      if(users[i].id===user.id){
        users[i] = user;
        res.json(200, {message: 'User updated!'});
      }
      else{
        res.json(400, {message: 'User not found'});
      }  
    }
  }
  else {
    res.json(400, {message: 'Invalid input, try again'});
  }
};

//Delete user method
exports.delete = function(req, res){
  var user = req.body.user;
  if(user){
    user.id = parseInt(user.id);
    for(var i = 0; i < users.length; i++){
      if(users[i].id===user.id){
        users.splice(i);
        res.json(200, {message: 'User deleted!'});
      }
      else{
        res.json(400, {message: 'User not found'});
      }  
    }
  }
  else {
    res.json(400, {message: 'Invalid input, try again'});
  }
};
{'fraction_non_alphanumeric': 0.1815229159148322, 'fraction_numerical': 0.011187297004691447, 'mean_word_length': 2.595330739299611, 'pattern_counts': {'":': 0, '<': 7, '<?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': '2304027', 'n_tokens_mistral': 1006, 'n_tokens_neox': 984, 'n_words': 228}