Skip to content

Commit

Permalink
refactor(api): [#143] move API resources mod
Browse files Browse the repository at this point in the history
  • Loading branch information
josecelano committed Jan 13, 2023
1 parent 77ec521 commit 6dd3c48
Show file tree
Hide file tree
Showing 11 changed files with 13 additions and 14 deletions.
1 change: 0 additions & 1 deletion src/api/mod.rs

This file was deleted.

1 change: 1 addition & 0 deletions src/apis/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
pub mod middlewares;
pub mod resources;
pub mod routes;
pub mod server;
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions src/api/resource/torrent.rs → src/apis/resources/torrent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ mod tests {

use aquatic_udp_protocol::{AnnounceEvent, NumberOfBytes};

use crate::api::resource::peer::Peer;
use crate::api::resource::torrent::{ListItem, Torrent};
use crate::apis::resources::peer::Peer;
use crate::apis::resources::torrent::{ListItem, Torrent};
use crate::protocol::clock::DurationSinceUnixEpoch;
use crate::protocol::info_hash::InfoHash;
use crate::tracker::peer;
Expand Down
6 changes: 3 additions & 3 deletions src/apis/routes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ use serde::{de, Deserialize, Deserializer, Serialize};
use serde_json::json;

use super::middlewares::auth::auth;
use crate::api::resource::auth_key::AuthKey;
use crate::api::resource::stats::Stats;
use crate::api::resource::torrent::{ListItem, Torrent};
use crate::apis::resources::auth_key::AuthKey;
use crate::apis::resources::stats::Stats;
use crate::apis::resources::torrent::{ListItem, Torrent};
use crate::protocol::info_hash::InfoHash;
use crate::tracker::auth::KeyId;
use crate::tracker::services::statistics::{get_metrics, TrackerMetrics};
Expand Down
1 change: 0 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
pub mod api;
pub mod apis;
pub mod config;
pub mod databases;
Expand Down
6 changes: 3 additions & 3 deletions tests/api/asserts.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// code-review: should we use macros to return the exact line where the assert fails?

use reqwest::Response;
use torrust_tracker::api::resource::auth_key::AuthKey;
use torrust_tracker::api::resource::stats::Stats;
use torrust_tracker::api::resource::torrent::{ListItem, Torrent};
use torrust_tracker::apis::resources::auth_key::AuthKey;
use torrust_tracker::apis::resources::stats::Stats;
use torrust_tracker::apis::resources::torrent::{ListItem, Torrent};

// Resource responses

Expand Down
8 changes: 4 additions & 4 deletions tests/tracker_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ mod tracker_apis {
mod for_stats_resources {
use std::str::FromStr;

use torrust_tracker::api::resource::stats::Stats;
use torrust_tracker::apis::resources::stats::Stats;
use torrust_tracker::protocol::info_hash::InfoHash;

use crate::api::asserts::{assert_stats, assert_token_not_valid, assert_unauthorized};
Expand Down Expand Up @@ -199,8 +199,8 @@ mod tracker_apis {
mod for_torrent_resources {
use std::str::FromStr;

use torrust_tracker::api::resource::torrent::Torrent;
use torrust_tracker::api::resource::{self, torrent};
use torrust_tracker::apis::resources::torrent::Torrent;
use torrust_tracker::apis::resources::{self, torrent};
use torrust_tracker::protocol::info_hash::InfoHash;

use super::{invalid_infohashes_returning_bad_request, invalid_infohashes_returning_not_found};
Expand Down Expand Up @@ -362,7 +362,7 @@ mod tracker_apis {
seeders: 1,
completed: 0,
leechers: 0,
peers: Some(vec![resource::peer::Peer::from(peer)]),
peers: Some(vec![resources::peer::Peer::from(peer)]),
},
)
.await;
Expand Down

0 comments on commit 6dd3c48

Please sign in to comment.