medikoo / medikoo/post-controller-router
Rethink validation/submit design
Open
@medikoo is already working on this.
Since Mar 7, 2016.
- Dominant language
- JavaScript
- Stars
- 1
- Forks
- 0
- PR merge metrics
- No merged PRs in 30d
Description
Related to https://github.com/medikoo/dbjs/issues/58
In current design controller is split into:
validate- is meant to validate the changes and normalize the request input. If it passes it means that request is valid and update can be submitted. Operational errors thrown here are expected to result with400status code, Programmer errors will result with500status code.submit- Takes normalized input fromvalidationand proceeds with submission. If that crashes, the500is the only logical server response.
In new design we may have just
controller- which is meant to validate the changes and either:- Crash (if request data is invalid), operational errors thrown here are expected to result with
400status code, Programmer errors will result with500status code. - Return function, that when called produces submission of data. If that is returned, router after calling
controllerinvokes returned function, if that crashes, the500is the only logical server response. - Return (anything but function), it means that submission was done also by
controllerfunction, and result is propagated to caller (it makesvalidateandsubmitsteps separation optional).
- Crash (if request data is invalid), operational errors thrown here are expected to result with
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.