BookDo7starsTS / bookdo7stars_be

0 stars 0 forks source link

router naming #11

Open younghyunlee22 opened 2 weeks ago

younghyunlee22 commented 2 weeks ago

I noticed that we are currently using singular nouns for APIs managing user and book collections. I suggest using plural nouns for APIs that handle collections of resources. This indicates that the endpoint deals with multiple items or a collection, rather than a single item.

e.g.: app.use('/users', userController); app.use('/books', bookController);

I would appreciate your input!

MayHyeyeonKim commented 2 weeks ago

Oh! Your suggestion sounds great to me. I looked up RESTful API conventions and also asked my BF, CG.

https://blog.dreamfactory.com/best-practices-for-naming-rest-api-endpoints#:~:text=Using%20nouns%20for%20naming%20URIs,your%20URIs%20with%20plural%20nouns.

Screenshot 2024-08-30 at 11 02 12 AM
hunjoonrhee commented 2 weeks ago

Then, in my opinion, we should split the BookController into two controllers: booksController and bookController.

booksController then stands for the plural, i.e. books, and bookController stands for a book.

getAllBooks -> booksController (axios.get('/books'))

getBookById-> bookController (axios.get('/book/:bookId'))

Is that what you meant? we can discuss it :)