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

Accept Boolean as body in send() #1461

Closed
revnode opened this issue Aug 24, 2017 · 2 comments
Closed

Accept Boolean as body in send() #1461

revnode opened this issue Aug 24, 2017 · 2 comments

Comments

@revnode
Copy link

revnode commented Aug 24, 2017

  • [ x ] Used appropriate template for the issue type
  • [ x ] Searched both open and closed issues for duplicates of this issue
  • [ x ] Title adequately and concisely reflects the feature or the bug

Bug Report

Restify Version

5.x

Node.js Version

Any

Expected behaviour

Under for 4.x, you can respond with res.json(200, true). This sets body to true. This is no longer possible under 5.x

Related: #1406

Actual behaviour

Body has no content.

Repro case

res.json(200, true)

Cause

./lib/response.js on line 272 checks for the type and filters out anything that isn't an object or a string.

Are you willing and able to fix this?

Already did. Ready to make a PR once this is given the green light.

https://github.com/revnode/node-restify/commit/8c598eeb8a5315f5758f330791991eb198b1e53b

@DonutEspresso
Copy link
Member

Thank you for the issue report and for digging into the issue! Apologies for the regression from 4.x @retrohacker any thoughts on just relaxing the restriction for body in that function? If we include number and boolean it might as well just be open to any possible value?

@retrohacker
Copy link
Member

Hey @revnode,

Thank you for taking the time to open this issue, follow our template, and for linking to a proposed implementation ❤️

I'm 👍 on relaxing the constraints for body, this seems ideal. Since we support custom formatters, anything could be a potentially valid body.

number is a special case in that there is a previous argument that is a number: statusCode. I'd err on the side of keeping the order of the args, in the case where you want to specify a number for body, you must always specify statusCode to disambiguate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants