Skip to content

Commit

Permalink
Merge pull request #100 from 95ulisse/master
Browse files Browse the repository at this point in the history
Make 204 responses pass through the outputFn
  • Loading branch information
florianholzapfel committed Mar 5, 2015
2 parents 563e0a7 + c1e02e8 commit 978be7d
Showing 1 changed file with 13 additions and 17 deletions.
30 changes: 13 additions & 17 deletions lib/express-restify-mongoose.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,19 @@ function getDefaults() {
}

function outputExpress(res, result, statusCode) {
res.status(statusCode || 200).json(result);
if (result !== null) {
res.status(statusCode || 200).json(result);
} else {
res.status(statusCode || 200).end();
}
}

function outputRestify(res, result, statusCode) {
res.send(statusCode || 200, result);
if (result !== null) {
res.send(statusCode || 200, result);
} else {
res.send(statusCode || 200);
}
}

var restify = function(app, model, opts) {
Expand Down Expand Up @@ -658,11 +666,7 @@ var restify = function(app, model, opts) {
onError(createError(400, err), req, res, next);
} else {
// 204 - No Content
if(usingExpress) {
res.status(204).end();
} else {
res.send(204);
}
outputFn(res, null, 204);
next();
}
});
Expand Down Expand Up @@ -727,11 +731,7 @@ var restify = function(app, model, opts) {
}
else {
// 204 - No Content
if(usingExpress) {
res.status(204).end();
} else {
res.send(204);
}
outputFn(res, null, 204);
next();
}
});
Expand All @@ -751,11 +751,7 @@ var restify = function(app, model, opts) {
}
else {
// 204 - No Content
if(usingExpress) {
res.status(204).end();
} else {
res.send(204);
}
outputFn(res, null, 204);
next();
}
});
Expand Down

0 comments on commit 978be7d

Please sign in to comment.