Skip to content

Commit

Permalink
Updating onsend() override such that it sets res.statusCode() pri…
Browse files Browse the repository at this point in the history
…or to executing serializer
  • Loading branch information
avoidwork committed Jan 4, 2021
1 parent 73e429e commit fdb5c25
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 2 additions & 0 deletions lib/utility.js
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,8 @@ function bootstrap (obj) {
// Setting up router
obj.router.addListener("connect", obj.connect.bind(obj));
obj.router.onsend = (req, res, body = "", status = 200, headers) => {
res.statusCode = status;

if (status !== 204 && status !== 304 && (body === null || typeof body.on !== "function")) {
body = obj.render(req, res, obj.final(req, res, hypermedia(req, res, serialize(req, res, body)))); // eslint-disable-line no-use-before-define
}
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "tenso",
"description": "Tenso is an HTTP REST API framework",
"version": "16.0.5",
"version": "16.0.6",
"homepage": "https://github.com/avoidwork/tenso",
"author": "Jason Mulligan <[email protected]>",
"repository": {
Expand Down

0 comments on commit fdb5c25

Please sign in to comment.