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

#164198181 Validates signup parameters #18

Merged
merged 4 commits into from
Mar 8, 2019

Conversation

valenstical
Copy link
Contributor

What does this PR do?
This PR validates registration/signup parameters before sending control over to the user controller.

Description of Task to be completed

  • Install express-validator to handle validation
  • Create middleware to validate each parameter
  • Create middleware to handle validation errors if any
  • Mount middleware created above to the user signup route
  • Write test against implementation
  • Create helper function to send response data
  • Create constant file to hold all re-usable constants

How should this be manually tested

Prerequisite: Postgres

  1. Run the following commands on terminal:
git clone -b feature/164198181/validate-signup --single-branch \
https://github.com/andela/apollo-ah-backend.git

Navigate to the apollo-ah-backend directory
Run cp .env.example .env
npm install
  1. Modify .env file with your db credentials

  2. Run migrations with npm run migrate

  3. Spin up the server by running npm run start:dev on your terminal

  4. Make a POST request to localhost:3000/api/v1/users respectively with Postman.

❗️ Important: Provide user payload when making request, sample below:

{
  "email": "example@email.com",
  "password": "secret"
  "username" "user"
}

NOTE: To run test locally, create .env.test file. Run command: cp .env.example .env.test

Any background context you want to provide

N/A

What are the relevant pivotal tracker stories

#164198181

Screenshots

N/A

-- Template format by @devdbrandy

- install express-validator
- create middleware to validate parameters
- create middleware to handle validation result
- send appropriate validation mesages and status code
[Finishes #164198181]
@valenstical valenstical added the ready This pull request is ready for review label Mar 7, 2019
routes/users.js Show resolved Hide resolved
routes/users.js Show resolved Hide resolved
controllers/users.js Show resolved Hide resolved
@valenstical valenstical added WIP This pull request is a work in progress and removed ready This pull request is ready for review labels Mar 7, 2019
@valenstical valenstical added ready This pull request is ready for review WIP This pull request is a work in progress and removed WIP This pull request is a work in progress ready This pull request is ready for review labels Mar 7, 2019
Copy link
Contributor

@aanchirinah aanchirinah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job done @valenstical , kindly attend to my requested changes

helpers/response.helper.js Outdated Show resolved Hide resolved
@valenstical valenstical added WIP This pull request is a work in progress and removed ready This pull request is ready for review labels Mar 8, 2019
- change file names from kebab case to camel case to follow the expected convention
@valenstical valenstical added ready This pull request is ready for review bug Something isn't working WIP This pull request is a work in progress and removed WIP This pull request is a work in progress ready This pull request is ready for review bug Something isn't working labels Mar 8, 2019
helpers/constants.js Outdated Show resolved Hide resolved
- add jsdoc to expressValidatorFormater for better understanding of the function purpose.
@devdbrandy
Copy link
Contributor

Looks good to me.

@aanchirinah
Copy link
Contributor

LGTM

@aanchirinah aanchirinah merged commit a9612f8 into staging Mar 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready This pull request is ready for review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants