Skip to content

[Refactor] Improve type safety and pagination to GenreService #2

@Sethispr

Description

@Sethispr

The current implementation of GenreService is decent using the service-client pattern and proper context handling. However, to ensure full API condition and improve developer experience, we should add some missing stuff.

  1. Restore Pagination: The Anime/Manga endpoints support page and limit parameters. These should be added to the method signatures.

  2. Introduce Type Safety for Filters: Instead of using raw strings literally just stringing everything so now for filter, we should implement a GenreFilter type with constants (GenresFilterThemes) to prevent runtime errors and improve IDE autocompletion.

// Current
func (s *GenreService) Anime(ctx context.Context, filter string) ([]Genre, error)

// New
func (s *GenreService) Anime(ctx context.Context, page, limit int, filter GenreFilter) ([]Genre, error)

The current version is clean enough, but adding it will make the library way better and user friendly for prod environments where pagination is needed.

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions