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

Fixed 79 #96

Merged
merged 2 commits into from
Mar 5, 2020
Merged

Fixed 79 #96

merged 2 commits into from
Mar 5, 2020

Conversation

irshadjsr21
Copy link
Contributor

@irshadjsr21 irshadjsr21 commented Mar 5, 2020

Closes #79

Features

  • Abstracted out User password hashing and password check into the User model.
  • Abstracted out signing jwt to jwt.js.
  • createController function was added which takes the actual controller as first parameter and options as the second parameter. It takes care of error handling, validation, inputs according to the options provided. Refer to the createController.js file for more details.
  • Added default error handling to the routes (in file server.js).
  • For known error http-errors module should be used to throw an error that is automatically handled by createController.
  • The createError function in http-errors takes 3 parameters, statusCode, message, data.
  • Example
    throw new createError(401, "Incorrect password", {
            errors: { password: "Incorrect password" },
    });
    
    The third parameter can contain more details about the error which should be stored in errors object. The errors object contains error messages for particular fields (password in this example). If required we can also provide a default key in the errors object.
  • Also created interceptors on the frontend to format the error efficiently.

@rajatmw1999 rajatmw1999 added gssoc20 Issue created during GirlScript Summer of Code 2020 hard labels Mar 5, 2020
@rajatmw1999 rajatmw1999 merged commit 5e3a936 into adavijit:master Mar 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gssoc20 Issue created during GirlScript Summer of Code 2020 hard
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Validator and default error handling missing on backend.
2 participants