npm install
npm start
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 repositoryhttps://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
andusername
on github is:cotne.kekelia@yahoo.com
andtsotnekekelia
- My
Modify /routes/users.js.
-
Add a new
POST
routelocalhost:3000/users/:id
, whereid
is a route parameter [4 points]- Endpoint will also receive JSON object in the body of the request, something like this:
{ "property": "email", "value": "new@address.com" }
-
Endpoint should read local /data/users.js file and if user with provided
id
is found, their respectiveproperty
needs to be updated with providedvalue
, after updating property, user object needs to be returned as an endpoint response, otherwise return error404
[10 points] -
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]
- Note: make sure that you do not lose records of the other users
-
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 code400
[5 points]