title: How are these three JavaScript function arguments use?
body: <p>I've looked up JavaScript functions and arguments but couldn't find anything to help me understand a function like the one below. You can reference the <a href="http://mherman.org/blog/2016/03/13/designing-a-restful-api-with-node-and-postgres/#.WCYyq2srKM9" rel="nofollow noreferrer">original tutorial</a>.</p>
  
  <p>createPuppy has three arguments: req, res and next.</p>
  
  <pre><code>function createPuppy(req, res, next) {
    req.body.age = parseInt(req.body.age);
    db.none('insert into pups(name, breed, age, sex)' +
        'values(${name}, ${breed}, ${age}, ${sex})',
      req.body)
      .then(function () {
        res.status(200)
          .json({
            status: 'success',
            message: 'Inserted one puppy'
          });
      })
      .catch(function (err) {
        return next(err);
      });
  }
  </code></pre>
  
  <p>That function is being called by a router:</p>
  
  <pre><code>var express = require('express');
  var router = express.Router();
  
  var db = require('../queries');
  
  router.get('/api/puppies', db.getAllPuppies);
  router.get('/api/puppies/:id', db.getSinglePuppy);
  router.post('/api/puppies', db.createPuppy);
  router.put('/api/puppies/:id', db.updatePuppy);
  router.delete('/api/puppies/:id', db.removePuppy);
  module.exports = router;
  </code></pre>
  
  <p>When db.createPuppy is called, there wasn't any arguments passed. </p>
  
  <p>How do those three arguments fit into this function?</p>
  
  <p>Update: I'm new to Node, JavaScript, pg-promise and express. So it was a bit overwhelming to narrow down where to dig. I came here to get leads on where to narrow my focus in. Thank you!</p>