advanced-first-web-server-kdybvig

1.0.0 • Public • Published

My First Web Server

A starter repo for the ACA Advanced My First Web Server project.

Part 1.

  • Give your server the ability to respond to a GET request with a path "/users" and return the users array from state.js
  • Give your server the ability to respond to a GET request with a path "/users/1" and return the first user object from the users array from state.js
  • Give your server the ability to respond to a POST request with a path "/users" and just add a hard coded user object to the users array from state.js. .json() the last user in the array to send it back to the client. (if you do another GET request you should see this added)
  • Give your server the ability to respond to a PUT request with a path "/users/1" and just change any key value on the first user object in the users array in state.js. .json() this user to send it back to the client.
  • Give your server the ability to respond to a DELETE request with a path "/users/1" and remove one item from the users array. send() back a messsage "deleted"

Part 2. Use the express built in REST methods to do the same thing as Part 1

  • Give your server the ability to respond to a GET request with a path "/users" and return the users array from state.js
  • Give your server the ability to respond to a GET request with a path "/users/1" and return the first user object from the users array from state.js
  • Give your server the ability to respond to a POST request with a path "/users" and just add a hard coded user object to the users array from state.js. .json() the last user in the array to send it back to the client. (if you do another GET request you should see this added)
  • Give your server the ability to respond to a PUT request with a path "/users/1" and just change any key value on the first user object in the users array in state.js. .json() this user to send it back to the client.
  • Give your server the ability to respond to a DELETE request with a path "/users/1" and remove one item from the users array. send() back a messsage "deleted"

Part 3. Add the body-parser module to your project

  • Give your server the ability to handle a POST request with a path "/users" and add the data from the client to the users array
  • Assign an _id property to the user object that is a number that increments by 1 each time.
  • response.json() the user object to send it back to the client. (if you do another GET request you should see this added)

Part 4. Use path variables

  • Give your server the ability to respond to a GET request with a path /users/:userId and return the user object from the users array that has the _id == userId
  • Give your server the ability to respond to a PUT request with a path /users/:userId and just change any key value on the user object with this _id
  • Give your server the ability to respond to a DELETE request with a path /users/:userId and find the user with this id from the array. give this user object a new key value isActive:false. send() back a messsage "deleted"

Readme

Keywords

none

Package Sidebar

Install

npm i advanced-first-web-server-kdybvig

Weekly Downloads

1

Version

1.0.0

License

ISC

Unpacked Size

6.51 kB

Total Files

4

Last publish

Collaborators

  • kdybvig