Skip to content

Instantly share code, notes, and snippets.

@DominicTremblay
Last active September 7, 2023 18:22
Show Gist options
  • Save DominicTremblay/941afbe1295ec666d3539d448df7c776 to your computer and use it in GitHub Desktop.
Save DominicTremblay/941afbe1295ec666d3539d448df7c776 to your computer and use it in GitHub Desktop.
Creating routes according to REST

REST exercise

  • You are asked to build an API for a photo app.
  • You need to create the routes according to REST for the following actions:
  1. The end-user wants to see a list of photos

GET /photos

  1. The end-user wants to see a particular photo

GET /photos/:id

  1. The end-user wants to upload a new photo

GET /photos/new

POST /photos

  1. The end-user wants to update an existing photo

GET /photos/:id/update

PUT /photos/:id

  1. The end-user wants to see a list of user profiles

GET /users

  1. The end-user wants to see a specific profile

GET /users/:id

  1. The end-user wants to see a list of the photos for a specific profile

GET /users/:id/photos

  1. The end-user wants to see one particular photo of a particular user

GET /users/:userId/photos/:id

You need to write the route with a verb and a path. You don't need to implement the functionality.

For example, to get a list of users, you just need to write GET '/users'. No need to write the code to get the actual users.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment