Express REST API response methods are not recognized
<p>I have this really simple get request that returns json that I am trying to implement. I have followed the tutorials for Express Web Framework REST API,  but for some reason I keep getting the same error</p>

<p>ERROR:</p>

<pre><code>TypeError: res.status is not a function
</code></pre>

<p>or</p>

<pre><code>TypeError: res.json is not a function
</code></pre>

<p>index.js:</p>

<pre><code> var express = require('express');
    var router = express.Router();
    var pg = require('pg');
    var connectionString = 'pg://postgres:postgres@postgres/feed';

/* GET home page. */
router.get('/', function(req, res, next) {
  res.render('index', { title: 'Express' });

});

router.get('/api/leaderboard', function(resp, req){
  var results = [];
   pg.connect(connectionString, function(err, client, done){
       if(err){
         done();
         console.log(err);
         return res.status(500).json({ success: false, data: err});
       }
       var query = client.query("SELECT * FROM log WHERE (logged &gt;= date_trunc('week', CURRENT_TIMESTAMP - interval '1 week') AND logged &lt;= date_trunc('week', CURRENT_TIMESTAMP));");
       var counter = 0;
       var b1 = {};
       var b2 = {};
       var b3 = {};
       var b4 = {};
       b1.energy_sum_week = 0;
       b2.energy_sum_week = 0;
       b3.energy_sum_week = 0;
       b4.energy_sum_week = 0;
       b1.zne_sum_week = 30000;
       b2.zne_sum_week = 30000;
       b3.zne_sum_week = 30000;
       b4.zne_sum_week = 30000;
       query.on('row', function(row){
           //results.push(row);
                  if(row['address'] == 215){
                     b1.energy_sum_week = row['kitchen'] + row['plugload'] + row['lights'] + row['ev'] + row['hvac'] + row['instahot'] - row['solar'];
                   }
                   else if (row['address'] == 1590) {
                     b2.energy_sum_week = row['kitchen'] + row['plugload'] + row['lights'] + row['ev'] + row['hvac'] + row['instahot'] - row['solar'];

                   } else if (row['address'] == 1605) {
                     console.log(row);
                     b3.energy_sum_week = row['kitchen'] + row['plugload'] + row['lights'] + row['ev'] + row['hvac'] + row['instahot'] - row['solar'];

                   } else if (row['address'] == 1715) {
                     b4.energy_sum_week = row['kitchen'] + row['plugload'] + row['lights'] + row['ev'] + row['hvac'] + row['instahot'] - row['solar'];
                   }

       });
       query.on('end', function(){
         done();
         //make zne lower than everything
         results.push(b1);
         results.push(b2);
         results.push(b3);
         results.push(b4);
         resp.json(results);

       });

  });

});


module.exports = router;
</code></pre>

<p>It seems like it can't recognize the response object. Tried a bunch of different things like passing in the request and response's to the query callbacks, and using promises. 
Getting kinda desperate here :/</p>