title: Polymorphism nodeJS
body: <p>I develop a restful API with nodeJS.</p>
  
  <pre><code>    exports.postCreature = function (req, res) {
  
      var creature = new Creature({
              name: req.body.name, id_user: req.user._id
          });
  
      creature.save(function (err) {
          if (err)
              res.status(400).send(Error.setError('impossible to save the your creature', err));
          else
              res.status(201).send();
      });
  };
  
  //CODE DUPLICATE 
  exports.createCreature = function(user, callback) {
      console.log('Creature created');
      var creature = new Creature({
          name: user.username, id_user: user._id
      });
  
      creature.save(function (err) {
          if (err)
             callback(err, null);
          else
              callback(null, creature);
      });
  }
  </code></pre>
  
  <p>The two functions execute the same code but not with the same parameters.
  I would like to avoid duplication in my code.</p>
  
  <p>How can do in order to avoid duplication of my code ?</p>