luin / express-promise

❤️ Middleware for easy rendering of async Query results.
MIT License
316 stars 19 forks source link

HTTP status codes? (take 2) #16

Open zsszatmari opened 9 years ago

zsszatmari commented 9 years ago

Hi!

I would expect the following to return a http status code:

const express = require('express');
const app = express();
const Q = require('q');

app.use(require('express-promise')());

app.get('/index.html', function(req, res){

    res.send(Q(new Error(401)));
});

const port = Number(process.env.PORT || 3000);
app.listen(port, function () {
    console.log("Listening on " + port);
});

Instead I get '{}' as response body and 200 OK as status code. In fact, I see no way I see no way to return http status code as promise result. Is there an easy way I've overlooked? Thank You!