Skip to content

Decouple API resources from internal structures #164

@josecelano

Description

@josecelano

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    Maintenance

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions