Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decouple API resources from internal structures #164

Open
1 task done
josecelano opened this issue May 25, 2023 · 1 comment
Open
1 task done

Decouple API resources from internal structures #164

josecelano opened this issue May 25, 2023 · 1 comment
Labels
Code Cleanup / Refactoring Tidying and Making Neat EPIC Contains several subissues
Milestone

Comments

@josecelano
Copy link
Member

josecelano commented May 25, 2023

The API endpoints return internal objects, for example:

The endpoint to get all categories:

http://127.0.0.1:3000/v1/category

returns the struct Category:

pub struct Category {
    pub category_id: i64,
    pub name: String,
    pub num_torrents: i64,
}

That's only one example.

That has some problems:

  • If you change the internal representation, you can break the API unintentionally.
  • You cannot change the API resources and the internal objects independently. For example, it will be harder to implement version 2 for the API.
  • In the future, the API resource could contain different data.
  • It's harder to mock the API responses if those objects have extra logic, ar nested, etcetera.

We could change it progressively or when we implement the API v2.

Subtasks

@josecelano josecelano added the Code Cleanup / Refactoring Tidying and Making Neat label May 25, 2023
@cgbosse cgbosse moved this to Maintenance in Torrust Solution Jan 10, 2024
@cgbosse
Copy link
Member

cgbosse commented Jan 16, 2024

@da2ce7 and @WarmBeer any comments?

@cgbosse cgbosse added this to the v3.0.0 milestone Jan 16, 2024
@josecelano josecelano changed the title Decouple API resources from internal structures Decouple API resources from internal structures (Category) Jan 16, 2024
@josecelano josecelano added the EPIC Contains several subissues label Feb 27, 2024
@josecelano josecelano changed the title Decouple API resources from internal structures (Category) Decouple API resources from internal structures Feb 27, 2024
@josecelano josecelano modified the milestones: v3.0.0, v3.1.0 Feb 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Code Cleanup / Refactoring Tidying and Making Neat EPIC Contains several subissues
Projects
Status: Maintenance
Development

No branches or pull requests

2 participants