Skip to content

[JITERA] Refactor createBook Function and Add Docstrings

chi le requested to merge feat/refactor-createBook-docstrings-1750327781 into main

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

  1. Refactored createBook function:

    • 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.
  2. Added validateBookData function:

    • 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.

Merge request reports