Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the values passed to the callback function for fail(). This fixes #257 #258

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions template/node12/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@ class FunctionContext {
}

fail(value) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Think of this example, it will return a HTTP 200, and I don't think that's what you wanted.

  return context
    .fail(result)

The code should probably stay the same as it is, but then change the middleware closure, with something like this:

            return res.status(fnContext.status() || 500)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you share a handler example that we can use for an end to end test?

return context
    .fail("Not OK")

Should give 500 and "Not OK"

return context
    .succeed("OK")

Gives 200 and "OK"

return context.status(401)
    .fail("Not authorized")

Gives 401 - Not authorized

let message;
let err;
this.cbCalled++;
this.cb(value, message);
this.cb(err, value);
}
}

Expand Down
4 changes: 2 additions & 2 deletions template/node14/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@ class FunctionContext {
}

fail(value) {
let message;
let err;
this.cbCalled++;
this.cb(value, message);
this.cb(err, value);
}
}

Expand Down