trails
trails copied to clipboard
Standard and custom responses
Do you plan to implement custom responses feature like in sails?
Or is there already exists a fast way to do that?
I think that it's a useful helper to manage standard responses like 404 errors (when a controller or a model was not found), 401 errors (when data sent to a model does not valid its schema), forbidden responses (403 errors) when a policy was not respect, etc.
Off-topic: 401 should be used for unauthorized requests, not when a model's schema validation fails. See Wiki.
Yes, I was wrong. The 400 error is more suitable.
But how about the feature? Do you know if there will be implemented (or something similar)?
But how about the feature? Do you know if there will be implemented (or something similar)?
I haven't decided, honestly, if this is something that the webserver trailpacks should be forced to include. hapi can use boom to customize responses and errors. For express, you could include express-custom-responses. I want trails to be webserver-agnostic and also lightweight; since solutions exist for many popular webserver modules already, I'm hesitant to create a new trails-y abstraction for this.
I'm open to other ideas. If someone in the community wants to build a "trailpack-custom-responses" module, we would encourage that.
Thanks for your answer. I'm agree with your opinion.
I'm hesitant to create a new trails-y abstraction for this.
Can you expand this idea? Your opinion may be helpful if the community starts to build a trailpack for this feature.