[JITERA] Refactor createBook Function and Add Docstrings
Created by: chi-jitera
Overview
This pull request refactors the createBook function in the bookService.js file to improve code readability and maintainability. Additionally, docstrings have been added to both the createBook and validateBookData functions to provide clear documentation on their purpose, parameters, return values, and potential errors.
Changes
-
Refactored
createBookfunction:- Added a docstring to describe the function's purpose, parameters, return value, and potential errors.
- The function now validates the book data before attempting to create a new book in the database.
-
Added
validateBookDatafunction:- Introduced a new function to encapsulate the validation logic for book data.
- Added a docstring to explain the validation process and the conditions under which an error will be thrown.
These changes enhance the clarity of the code and provide better documentation for future developers.