title: Express middleware to configure response
body: <p>I want to create a middleware that automatically formats my output and returns it in a format that looks like </p>
  
  <pre><code>{
     "successful": "true",
     "message": "Successfully created",
     "data": {
           "name": "Joe",
           "year": 1
      }
  }
  </code></pre>
  
  <p>Currently I'm just returning a json of the data itself (name, year, etc.)</p>
  
  <p>I want to add the "successful", "message", etc.</p>
  
  <p>Here's some snippets of my code below:</p>
  
  <p><strong>routes/student.js</strong></p>
  
  <pre><code>var student_controller = require('../controllers/studentController');
  router.get('/list', student_controller.student_list);
  </code></pre>
  
  <p><strong>controllers/student.js</strong></p>
  
  <pre><code>var Student = require('../models/student');
  
  exports.student_list = function(req, res, next) {
      Student.find()
          .exec(function(err, list_students) {
              if (err) {return next(err);}
              res.json(list_students);
          });
  };
  </code></pre>
  
  <p><strong>app.js</strong></p>
  
  <pre><code>var studentRouter = require('./routes/student');
  app.use('/student', studentRouter);
  </code></pre>
  
  <p>How do I make this middleware, and in which file(s) should I be calling it?</p>