Skip to content

[C4GT Community]: Move domain/common to app module #125

@codecakes

Description

@codecakes

Ticket Contents

Description

The project already has implementation for pagination using Open/Closed principle using Blacksheep's Binder class. By subclassing using Binder, pagination can be given a definition:

class PageOptionsBinder(Binder):
    """
    Binds common pagination options for all endpoints implementing pagination of
    results. Collects and validates optional the following query parameters:

    - page, for page number
    - limit, for results per page
    - continuation_id, the last numeric ID that was read
    """

Currently this is consumed by OpenAPI docs as:

def set_binders_docs(docs: OpenAPIHandler):
    """
    This function configures OpenAPI Documentation for custom application binders.
    """

This is an application IO specific logic and as such xcov19/domain/common.py should belong under xcov19/app as it will be utilized by controller routes. By reusing such extensivle reusable stateless logic for pagination and keeping it within the IO services bound module, the code becomes cleaner and easier to understand and does not confuse with the purpose of domain modulle.

Goals

Goals

  • Move xcov19/domain/common.py to xcov19/app/common.py

Expected Outcome

Routes including openapi docs can utilize a centralized utility function for pagination.

Acceptance Criteria

  • Existing and future controller routes can utilize the same pagination binder class.
  • It should not introduce any side-effect or change in existing pagination behaviour.

Implementation Details

This is a refactor and using a modern IDE, moving to a new location should automatically update the imports.

Mockups/Wireframes

No response

Product Name

project-healthcare

Organisation Name

XCoV19

Domain

Healthcare

Tech Skills Needed

Python, RESTful APIs, Flask, Docker

Mentor(s)

@codecakes

Complexity

Medium

Category

Backend, Maintenance

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions