Skip to content

Commit 07c8c55

Browse files
committed
refactor: re-organize models/controllers and get started on v3 of the API
1 parent 0bd24c8 commit 07c8c55

85 files changed

Lines changed: 3787 additions & 270 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@ database = { path = "./database" }
1313
shared = { path = "./shared" }
1414

1515
chrono = { workspace = true }
16-
tracing = { workspace = true }
1716
futures = { workspace = true }
17+
sqlx = { workspace = true }
18+
tracing = { workspace = true }
1819

1920
actix-files = "0.6.0-beta.7"
2021
actix-http = "3.2"
@@ -57,6 +58,14 @@ members = ["database", "shared"]
5758
[workspace.dependencies]
5859
chrono = { version = "0.4", features = ["serde"] }
5960
futures = "0.3"
61+
sqlx = { version = "0.7.1", features = [
62+
"runtime-tokio-native-tls",
63+
"mysql",
64+
"macros",
65+
"migrate",
66+
"uuid",
67+
"chrono",
68+
] }
6069
tracing = "0.1.37"
6170

6271
[profile.release]

database/Cargo.toml

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,4 @@ shared = { path = "../shared" }
1212
chrono = { workspace = true }
1313
futures = { workspace = true }
1414
tracing = { workspace = true }
15-
16-
sqlx = { version = "0.7.1", features = [
17-
"runtime-tokio-native-tls",
18-
"mysql",
19-
"macros",
20-
"migrate",
21-
"uuid",
22-
"chrono",
23-
] }
15+
sqlx = { workspace = true }

src/api.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
use actix_web::web;
2+
3+
mod v1;
4+
mod v2;
5+
mod v3;
6+
7+
pub fn configure(cfg: &mut web::ServiceConfig) {
8+
cfg.service(web::scope("/v2").configure(v2::configure_v2));
9+
cfg.service(web::scope("/v3").configure(v3::configure_v3));
10+
cfg.service(web::scope("").configure(v1::configure_v1));
11+
}

src/api/v1.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
mod controllers;
2+
mod models;
3+
4+
pub(super) use controllers::configure as configure_v1;
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
use actix_web::web;
22

3-
pub(in crate::controllers) mod comic;
4-
pub(in crate::controllers) mod item;
5-
pub(in crate::controllers) mod log;
3+
mod comic;
4+
mod item;
5+
mod log;
66

77
pub fn configure(cfg: &mut web::ServiceConfig) {
88
cfg.service(web::scope("/comicdata").configure(comic::configure));
Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
use actix_web::web;
22

3-
use crate::controllers::v2::api::comic::remove_item;
3+
pub(super) mod navigation_data;
44

5-
pub(crate) mod navigation_data;
6-
7-
pub(in crate::controllers) mod add_item;
8-
pub(in crate::controllers) mod all;
9-
pub(in crate::controllers) mod by_id;
10-
pub(in crate::controllers) mod editor_data;
11-
pub(in crate::controllers) mod set_flags;
12-
pub(in crate::controllers) mod set_publish_date;
13-
pub(in crate::controllers) mod set_tagline;
14-
pub(in crate::controllers) mod set_title;
5+
mod add_item;
6+
mod all;
7+
mod by_id;
8+
mod editor_data;
9+
mod remove_item;
10+
mod set_flags;
11+
mod set_publish_date;
12+
mod set_tagline;
13+
mod set_title;
1514

1615
pub fn configure(cfg: &mut web::ServiceConfig) {
1716
cfg.service(web::resource("/").route(web::get().to(all::all)))
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::models::v1::{ComicId, ComicIdInvalidity, Token};
1+
use crate::models::{ComicId, ComicIdInvalidity, Token};
22
use crate::util::{ensure_is_authorized, ensure_is_valid};
33
use actix_web::{error, web, HttpResponse, Result};
44
use actix_web_grants::permissions::AuthDetails;
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::models::v1::{ComicList, Exclusion};
1+
use crate::api::v1::models::{ComicList, Exclusion};
22
use actix_web::{error, web, HttpResponse, Result};
33
use database::models::Comic as DatabaseComic;
44
use database::DbPool;
Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
use crate::controllers::v1::api::comic::editor_data::fetch_editor_data_for_comic;
2-
use crate::controllers::v1::api::comic::navigation_data::{
1+
use crate::api::v1::controllers::comic::editor_data::fetch_editor_data_for_comic;
2+
use crate::api::v1::controllers::comic::navigation_data::{
33
fetch_all_item_navigation_data, fetch_comic_item_navigation_data,
44
};
5-
use crate::models::v1::{
6-
Comic, ComicData, ComicId, Exclusion, False, Inclusion, ItemColor, ItemNavigationData,
7-
ItemType, MissingComic, PresentComic, True, UnhydratedItemNavigationData,
5+
use crate::api::v1::models::{
6+
Comic, ComicData, Exclusion, Inclusion, ItemColor, ItemNavigationData, ItemType, MissingComic,
7+
PresentComic, UnhydratedItemNavigationData,
88
};
9+
use crate::models::{ComicId, False, True};
910
use crate::util::NewsUpdater;
1011
use actix_web::{error, web, HttpResponse, Result};
1112
use actix_web_grants::permissions::{AuthDetails, PermissionsCheck};

0 commit comments

Comments
 (0)