medikoo / medikoo/post-controller-router

Rethink validation/submit design

Open
#2 0 comments 0 reactions 1 assignee View on GitHub

@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 with 400 status code, Programmer errors will result with 500 status code.
  • submit - Takes normalized input from validation and proceeds with submission. If that crashes, the 500 is 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 400 status code, Programmer errors will result with 500 status code.
    • Return function, that when called produces submission of data. If that is returned, router after calling controller invokes returned function, if that crashes, the 500 is the only logical server response.
    • Return (anything but function), it means that submission was done also by controller function, and result is propagated to caller (it makes validate and submit steps separation optional).

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.