Retrieving All Books - Planning
Last updated
Last updated
Refer back to section for the API endpoint specifications.
From the specification, it seems like this will be a GET
request that will fetch a collection of books. We can refer back to the sections under chapter 3 for guidelines to follow, specifically the sections and .
The following URI should suffice.
GET /api/v1/books
Since this is a GET
request, there won't be any input request or payload from the client.
This is a public URI, so there really is no need for any middleware.
Again, since this is just a simple GET
request, there won't be any validation needed.
From the specifications, it looks like we will need the following book entity in our domain layer.
bookModel
title
description
price
author
datePublished
We will also need some sort of way to query the database to be able to retrieve all the books, getAllBooks()
will be the method we'd call.
bookRepository
getAll()
On top of that, our controller will call a service, in this case, it will be the bookService
which will retrieve all of the books in our database.
bookService
getAllBooks()
This is a rough outline of how we are going to be implementing these functions, we'll take a deeper dive at the implementations in the next section of this chapter.
Judging from the specifications, there doesn't seem to be any events, so we'll leave this blank as well.
We'll be adding in these fields:
title
description
price
author
datePublished
for each of our book listings.
As mentioned previous, we will be .