tsotnekekelia / wad20-exam3-c

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

WAD 2020 Resit Exam: Project C

Project setup

npm install

Compiles for development

npm start

Setup

You will need to import this repository to you GitHub account, to do that please follow these steps:

  • Go to Github import page
    • Note: you have to be logged in to your GitHub account
  • In the first field "Your old repository’s clone URL" enter URL of this repository https://github.com/tsotnekekelia/wad20-exam3-c
  • In the next field give it a name
  • Make it Private
  • And begin to import, it should take few seconds
  • Add me as a collaborator to your new repository, click here to learn how
    • My email and username on github is: cotne.kekelia@yahoo.com and tsotnekekelia

Tasks

Modify /routes/users.js.

  1. Add a new POST route localhost:3000/users/:id, where id is a route parameter [4 points]

    1. Endpoint will also receive JSON object in the body of the request, something like this:
        {
            "property": "email",
            "value": "new@address.com"   
        }
    
  2. Endpoint should read local /data/users.js file and if user with provided id is found, their respective property needs to be updated with provided value, after updating property, user object needs to be returned as an endpoint response, otherwise return error 404 [10 points]

  3. In case user is found, after updating users' property, persist changes by writing updated users array in to the /data/users.js file [6 points]

    1. Note: make sure that you do not lose records of the other users
  4. Only certain properties can be changed for the user, so validate that sent property is one of these: firstname, lastname, email, avatar, occupation. in case validation fails return response with status code 400 [5 points]

About


Languages

Language:JavaScript 92.7%Language:HTML 4.5%Language:CSS 2.8%