Skip to content

Commit

Permalink
Changing connect() such that it doesn't decorate res.send(), remo…
Browse files Browse the repository at this point in the history
…ving the bind on `error()` for the router method
  • Loading branch information
avoidwork committed Dec 4, 2018
1 parent 4295c38 commit 379f081
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 5 deletions.
3 changes: 1 addition & 2 deletions lib/tenso.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,13 +213,12 @@ class Tenso extends Base {
.replace("%{User-agent}i", req.headers["user-agent"] || "-");
}

connect (req, res) {
connect (req) {
req.timer = precise().start();
req.protect = false;
req.protectAsync = false;
req.unprotect = false;
req.server = this;
res.json = (arg, status = 200, headers = {"content-type": "application/json"}) => res.send(arg, status, headers);
}

drop () {
Expand Down
2 changes: 1 addition & 1 deletion lib/utility.js
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ function bootstrap (obj) {

// Setting up router
obj.router.onconnect = obj.connect.bind(obj);
obj.router.onerror = obj.error.bind(obj);
obj.router.onerror = obj.error;
obj.router.onfinish = obj.finish.bind(obj);
obj.router.onsend = obj.send.bind(obj);

Expand Down
2 changes: 1 addition & 1 deletion 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": "Tensō is an HTTP/HTTP2 REST API framework",
"version": "9.1.12",
"version": "9.1.13",
"homepage": "http://avoidwork.github.io/tenso",
"author": "Jason Mulligan <[email protected]>",
"repository": {
Expand Down

0 comments on commit 379f081

Please sign in to comment.