- Extract the contents of the zip file into a new directory and open the folder in VSCode.
- Initialise a new Node app in the directory. The entry point should be the existing
server.js
. - Install Express.
- Create an Express app in
server.js
that listens on port 3000. - Create a new request in Postman to make sure that the server is working.
- Create a
GET /profiles/eric
endpoint that returns the data about Eric Cartman in JSON format. - Create a
GET /profiles/eric/image
endpoint that returns Eric's large profile picture. - Test the endpoints in a web browser.
- Test the endpoints with Postman.
Modify the GET /profiles/eric/image
endpoint to accept a size
query string parameter so that
GET /profiles/eric/image?size=large
should return Eric's large profile picture;GET /profiles/eric/image?size=small
should return Eric's small profile picture;GET /profiles/eric/image
(without thesize
parameter) should return Eric's large profile picture;- for any other value of the
size
parameter the server should return400 Bad Request
status.
Modify the request handlers so that they take the username as a route parameter. E.g.
GET /profiles/kyle
should return the data about Kyle Broflovski in JSON format;GET /profiles/kenny/image?size=small
should return Kenneth McCormick's small profile picture;- if the username doesn't exist the server shold return
404 Not Found
status.
- Create a
GET /profiles
endpoint that returns the array of all profiles in JSON format. - Extend every student object with a property of the student's profile endpoint, one of the large profile picture and one of the small profile picture. E.g.
{
"username": "butters",
"name": "Leopold Stotch",
"age": 10,
"school": "South Park Elementary",
"grade": 4,
"profile": "/profiles/butters",
"largeImage": "/profiles/butters/image?size=large",
"smallImage": "/profiles/butters/image?size=small"
}