question archive Assignment 4: Implementing Routes to Support Registration and Issues 1
Subject:Computer SciencePrice: Bought3
Assignment 4: Implementing Routes to Support Registration and Issues
1. We'll use express for this assignment so start by installing express in your tissue project. Replace the http module's server with that of express.
2. We know from our studies that we need routes to respond to client requests so let's create some. We'll use the same approach from the lab. In your, project folder, create a new folder called "routes". Create the following js files in this folder:
· issues.js
· users.js
3. Now, let's implement those routes.
In your routing files, implement the following routes:
HTTP
Method
Route
Returns
Details
GET
/issues
Returns all issues as json
PUT
/issues/issues.json
The HTTP
Request body contains the JSON with the data to add a new issue. In your code to handle this route, you should retrieve the issue data and create a new Issue object and store it in your issues
array.
POST
/issues/:issue_id.json
The HTTP
request body contains the
JSON with
the new data for this issue. In your code to handle this route, you should find the issue in your issues array with the corresponding
id and update it accordingly.
DELETE
/issues/:issue_id.json
Removes the issue from
the issue array.
GET
/users
Returns all users as json
PUT
/users/users.json
The HTTP
request body contains the JSON with the data for the new user. In your code to handle this route, you should create a new User object and add it to a
users array.
4. Zip your entire project up in a folder called "assignment_4". Submit the zip folder in the assignment dropbox.
