diff --git a/README.md b/README.md index f69f609..9a6ea52 100644 --- a/README.md +++ b/README.md @@ -149,10 +149,44 @@ Your Task is to write a `RESTful` routing chart for the library system's API. Yo You can use this markdown chart: -| HTTP METHOD (_Verb_) | URL (_Nouns_) | CRUD | Response | Notes | -| -------------------- | ------------- | ---- | -------- | ----- | -| | | | | | -| | | | | | +| **HTTP METHOD (Verb)** | **URL (Nouns)** | **CRUD** | **Response** | **Notes on Response** | **Notes** | +|------------------------|----------------------------------|--------------------------------|--------------|----------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| GET | /members | Retrieve all members | 200 | Retrieve all members 200 OK | This is a place where you can get a list of all the people who are members of the library. | +| POST | /members | Create a new member | 201/409 | Create a new member 201 Created, 409 Conflict | You can use this to add a new person to the library. If it works, you'll get a message that says "201 Created". But if there's something wrong with the request, you'll get a "409 Conflict" message instead. | +| GET | /members/:id | Retrieve a single member | 200/404 | Retrieve a single member 200 OK, 404 Not Found | You can use this to find one specific person in the library. If the person you're looking for isn't there, you'll get a "404 Not Found" message. | +| PUT | /members/:id | Update a member | 200/400/404 | Update a member 200 OK, 400 Bad Request, 404 Not Found | If you need to change some information about a person in the library, you can use this. If it works, you'll get a "200 OK" message. But if there's something wrong with the request, you'll get a "400 Bad Request" message. And if the person you're trying to change doesn't exist, you'll get a "404 Not Found" message instead. | +| DELETE | /members/:id | Delete a member | 204/404 | Delete a member 204 No Content, 404 Not Found | If you want to get rid of someone from the library, you can use this. If it works, you won't get a response message. But if the person you're trying to delete doesn't exist, you'll get a "404 Not Found" message. | +| GET | /books | Retrieve all books | 200 | Retrieve all books 200 OK | This is a place where you can get a list of all the books in the library. | +| POST | /books | Create a new book | 201/409 | Create a new book 201 Created, 409 Conflict | You can use this to add a new book to the library. If it works, you'll get a message that says "201 Created". But if there's something wrong with the request, you'll get a "409 Conflict" message instead. | +| GET | /books/:id | Retrieve a single book | 200/404 | Retrieve a single book 200 OK, 404 Not Found | You can use this to find one specific book in the library. If the book you're looking for isn't there, you'll get a "404 Not Found" message. | +| PUT | /books/:id | Update a book | 200/400/404 | Update a book 200 OK, 400 Bad Request, 404 Not Found | If you need to change some information about a book in the library, you can use this. If it works, you'll get a "200 OK" message. But if there's something wrong with the request, you'll get a "400 Bad Request" message. And if the book you're trying to change doesn't exist, you'll get a "404 Not Found" message instead. | +| DELETE | /books/:id | Delete a book | 204/404 | Delete a book 204 No Content, 404 Not Found | If you want to get rid of a book from the library, you can use this. If it works, you won't get a response message. But if the book you're trying to delete doesn't exist, you'll get a "404 Not Found" message. | +| GET | /genres | Retrieve all genres | 200 | Retrieve all genres 200 OK | This is a place where you can get a list of all the different types of genres for books in the library. | +| POST | /genres | Create a new genre | 201/409 | Create a new genre 201 Created, 409 Conflict | You can use this to add a new genre to the library. If it works, you'll get a message that says "201 Created". But if there's something wrong with the request, you'll get a "409 Conflict" message instead. | +| GET | /genres/:id | Retrieve a single genre | 200/404 | Retrieve a single genre 200 OK, 404 Not Found | You can use this to find one specific genre in the library. If the genre you're looking for isn't there, you'll get a "404 Not Found" message. | +| PUT | /genres/:id | Update a genre | 200/400/404 | Update a genre 200 OK, 400 Bad Request, 404 Not Found | If you want to change some information about a genre, you can use this. If it works, you'll get a "200 OK" message. But if there's something wrong with the request, you'll get a "400 Bad Request" message. And if the genre you're trying to change doesn't exist, you'll get a "404 Not Found" message instead. | +| DELETE | /genres/:id | Delete a genre | 204/404 | Delete a genre 204 No Content, 404 Not Found | If you want to get rid of a genre from the library, you can use this. If it works, you won't get a response message. But if the genre you're trying to delete doesn't exist, you'll get a "404 Not Found" message. | +| GET | /books/:id/genres | Retrieve all genres for a book | 200/404 | Retrieve all genres for a book 200 OK, 404 Not Found | If you want to see all the genres for a particular book, you can use GET /books/:id/genres. Just replace :id with the ID number of the book you're interested in. If the book isn't in the library, you'll get a "404 Not Found" error. | +| GET | /genres/:id/books | Retrieve all books for a genre | 200/404 | Retrieve all books for a genre 200 OK, 404 Not Found | If you want to see all the books for a particular genre, you can use GET /genres/:id/books. Just replace :id with the ID number of the genre you're interested in. If the genre isn't in the library, you'll get a "404 Not Found" error. | +| POST | /books/:book_id/genres/:genre_id | Add a book to a genre | 201/404 | Add a book to a genre 201 Created, 404 Not Found | If you want to add a book to a particular genre, you can use POST /books/:book_id/genres/:genre_id. Just replace :book_id with the ID number of the book you want to add, and :genre_id with the ID number of the genre you want to add it to. If the book or genre isn't in the library, you'll get a "404 Not Found" error. | +| DELETE | /books/:book_id/genres/:genre_id | Remove a book from a genre | 204/404 | Remove a book from a genre 204 No Content, 404 Not Found | If you want to remove a book from a particular genre, you can use DELETE /books/:book_id/genres/:genre_id. Just replace :book_id with the ID number of the book you want to remove, and :genre_id with the ID number of the genre you want to remove it from. If the book or genre isn't in the library, you'll get a "404 Not Found" error. | + +200 OK: Indicates that the request was successful and the server is returning the requested data as the response body. + +201 Created: Indicates that the request to create a new resource was successful and the server has created the resource as specified in the request. + +204 No Content: Indicates that the request was successful and that the server has deleted the specified resource, but there is no response body to return. + +400 Bad Request: Indicates that the request was malformed or invalid and the server could not understand it. + +404 Not Found: Indicates that the requested resource was not found on the server. + +https://restapitutorial.com/lessons/httpmethods.html +https://www.rfc-editor.org/rfc/rfc9110.html#name-418-unused + +Process Taken: + +URLs then CRUD then HTTP Method then Responses #### Things to keep in mind