From: Felix Ableitner Date: Tue, 9 Feb 2021 18:26:06 +0000 (+0100) Subject: Move routes into separate crate to speed up compilation X-Git-Url: http://these/git/%7BpictshareAvatarThumbnail%28?a=commitdiff_plain;h=999d9f4d6c9927fd5cfb6c22f0157fc42f776874;p=lemmy.git Move routes into separate crate to speed up compilation --- diff --git a/Cargo.lock b/Cargo.lock index 8553c1f2..2edcca8d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -88,26 +88,6 @@ dependencies = [ "webpki", ] -[[package]] -name = "actix-files" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c51e8a9146c12fce92a6e4c24b8c4d9b05268130bfd8d61bc587e822c32ce689" -dependencies = [ - "actix-service", - "actix-web", - "bitflags", - "bytes 0.5.6", - "derive_more", - "futures-core", - "futures-util", - "log", - "mime", - "mime_guess", - "percent-encoding", - "v_htmlescape", -] - [[package]] name = "actix-http" version = "2.2.0" @@ -662,15 +642,6 @@ dependencies = [ "libc", ] -[[package]] -name = "buf-min" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa17aa1cf56bdd6bb30518767d00e58019d326f3f05d8c3e0730b549d332ea83" -dependencies = [ - "bytes 0.5.6", -] - [[package]] name = "bumpalo" version = "3.6.0" @@ -836,7 +807,7 @@ checksum = "784ad0fbab4f3e9cef09f20e0aea6000ae08d2cb98ac4c0abc53df18803d702f" dependencies = [ "percent-encoding", "time 0.2.25", - "version_check 0.9.2", + "version_check", ] [[package]] @@ -1050,17 +1021,6 @@ dependencies = [ "syn", ] -[[package]] -name = "diesel_json" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2812f0f63b6d3508fb7bfdb872c2dc2321ba938f5e0f4cb9751ec899e8b297c9" -dependencies = [ - "diesel", - "serde 1.0.123", - "serde_json", -] - [[package]] name = "diesel_migrations" version = "1.4.0" @@ -1356,7 +1316,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "501466ecc8a30d1d3b7fc9229b122b2ce8ed6e9d9223f1138d4babb253e51817" dependencies = [ "typenum", - "version_check 0.9.2", + "version_check", ] [[package]] @@ -1771,7 +1731,6 @@ dependencies = [ "http", "http-signature-normalization-actix", "itertools", - "jsonwebtoken", "lazy_static", "lemmy_apub", "lemmy_db_queries", @@ -1851,7 +1810,6 @@ dependencies = [ "bcrypt", "chrono", "diesel", - "diesel_json", "diesel_migrations", "lazy_static", "lemmy_db_schema", @@ -1910,18 +1868,42 @@ dependencies = [ "serde 1.0.123", ] +[[package]] +name = "lemmy_routes" +version = "0.1.0" +dependencies = [ + "actix", + "actix-web", + "actix-web-actors", + "anyhow", + "awc", + "chrono", + "diesel", + "lazy_static", + "lemmy_db_queries", + "lemmy_db_schema", + "lemmy_db_views", + "lemmy_db_views_actor", + "lemmy_structs", + "lemmy_utils", + "lemmy_websocket", + "log", + "rss", + "serde 1.0.123", + "sha2", + "strum", + "url", +] + [[package]] name = "lemmy_server" version = "0.0.1" dependencies = [ "activitystreams", "actix", - "actix-files", "actix-rt", "actix-web", - "actix-web-actors", "anyhow", - "awc", "cargo-husky", "chrono", "clokwerk", @@ -1929,7 +1911,6 @@ dependencies = [ "diesel_migrations", "env_logger", "http-signature-normalization-actix", - "lazy_static", "lemmy_api", "lemmy_apub", "lemmy_db_queries", @@ -1937,16 +1918,15 @@ dependencies = [ "lemmy_db_views", "lemmy_db_views_actor", "lemmy_db_views_moderator", + "lemmy_routes", "lemmy_structs", "lemmy_utils", "lemmy_websocket", "log", "openssl", "reqwest", - "rss", "serde 1.0.123", "serde_json", - "sha2", "strum", "tokio 0.3.7", "url", @@ -1985,6 +1965,7 @@ dependencies = [ "futures", "http", "itertools", + "jsonwebtoken", "lazy_static", "lettre", "log", @@ -2007,6 +1988,8 @@ name = "lemmy_websocket" version = "0.1.0" dependencies = [ "actix", + "actix-web", + "actix-web-actors", "anyhow", "background-jobs", "chrono", @@ -2288,16 +2271,6 @@ dependencies = [ "winapi 0.3.9", ] -[[package]] -name = "nom" -version = "4.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ad2a91a8e869eeb30b9cb3119ae87773a8f4ae617f41b1eb9c154b2905f7bd6" -dependencies = [ - "memchr", - "version_check 0.1.5", -] - [[package]] name = "nom" version = "5.1.2" @@ -2306,7 +2279,7 @@ checksum = "ffb4262d26ed83a1c0a33a38fe2bb15797329c85770da05e6b828ddb782627af" dependencies = [ "lexical-core", "memchr", - "version_check 0.9.2", + "version_check", ] [[package]] @@ -2317,7 +2290,7 @@ checksum = "ab6f70b46d6325aa300f1c7bb3d470127dfc27806d8ea6bf294ee0ce643ce2b1" dependencies = [ "bitvec", "memchr", - "version_check 0.9.2", + "version_check", ] [[package]] @@ -3212,7 +3185,7 @@ version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c66a8cff4fa24853fdf6b51f75c6d7f8206d7c75cab4e467bcd7f25c2b1febe0" dependencies = [ - "version_check 0.9.2", + "version_check", ] [[package]] @@ -3405,7 +3378,7 @@ dependencies = [ "standback", "stdweb", "time-macros", - "version_check 0.9.2", + "version_check", "winapi 0.3.9", ] @@ -3638,7 +3611,7 @@ version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "50f37be617794602aabbeee0be4f259dc1778fabe05e2d67ee8f79326d5cb4f6" dependencies = [ - "version_check 0.9.2", + "version_check", ] [[package]] @@ -3706,50 +3679,12 @@ dependencies = [ "serde 1.0.123", ] -[[package]] -name = "v_escape" -version = "0.15.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3e0ab5fab1db278a9413d2ea794cb66f471f898c5b020c3c394f6447625d9d4" -dependencies = [ - "buf-min", - "v_escape_derive", -] - -[[package]] -name = "v_escape_derive" -version = "0.8.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c860ad1273f4eee7006cee05db20c9e60e5d24cba024a32e1094aa8e574f3668" -dependencies = [ - "nom 4.2.3", - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "v_htmlescape" -version = "0.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f9a8af610ad6f7fc9989c9d2590d9764bc61f294884e9ee93baa58795174572" -dependencies = [ - "cfg-if 1.0.0", - "v_escape", -] - [[package]] name = "vcpkg" version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b00bca6106a5e23f3eee943593759b7fcddb00554332e856d990c893966879fb" -[[package]] -name = "version_check" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "914b1a6776c4c929a602fafd8bc742e06365d4bcbe48c30f9cca5824f70dc9dd" - [[package]] name = "version_check" version = "0.9.2" diff --git a/Cargo.toml b/Cargo.toml index 8df7e804..edec85f6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,6 +18,7 @@ members = [ "crates/db_views_actor", "crates/structs", "crates/websocket", + "crates/routes" ] [dependencies] @@ -31,25 +32,20 @@ lemmy_db_views_moderator = { path = "./crates/db_views_moderator" } lemmy_db_views_actor = { path = "./crates/db_views_actor" } lemmy_structs = { path = "./crates/structs" } lemmy_websocket = { path = "./crates/websocket" } +lemmy_routes = { path = "./crates/routes" } diesel = "1.4.5" diesel_migrations = "1.4.0" chrono = { version = "0.4.19", features = ["serde"] } serde = { version = "1.0.123", features = ["derive"] } actix = "0.10.0" actix-web = { version = "3.3.2", default-features = false, features = ["rustls"] } -actix-files = { version = "0.5.0", default-features = false } -actix-web-actors = { version = "3.0.0", default-features = false } -awc = { version = "2.0.3", default-features = false } log = "0.4.14" env_logger = "0.8.2" strum = "0.20.0" -lazy_static = "1.4.0" -rss = "1.10.0" url = { version = "2.2.0", features = ["serde"] } openssl = "0.10.32" http-signature-normalization-actix = { version = "0.4.1", default-features = false, features = ["sha-2"] } tokio = "0.3.6" -sha2 = "0.9.3" anyhow = "1.0.38" reqwest = { version = "0.10.10", features = ["json"] } activitystreams = "0.7.0-alpha.10" diff --git a/crates/api/Cargo.toml b/crates/api/Cargo.toml index 37968ae9..e3226eb8 100644 --- a/crates/api/Cargo.toml +++ b/crates/api/Cargo.toml @@ -31,7 +31,6 @@ log = "0.4.14" rand = "0.8.3" strum = "0.20.0" strum_macros = "0.20.1" -jsonwebtoken = "7.2.0" lazy_static = "1.4.0" url = { version = "2.2.0", features = ["serde"] } openssl = "0.10.32" diff --git a/crates/api/src/lib.rs b/crates/api/src/lib.rs index 161540d5..5e9e1c16 100644 --- a/crates/api/src/lib.rs +++ b/crates/api/src/lib.rs @@ -1,4 +1,3 @@ -use crate::claims::Claims; use actix_web::{web, web::Data}; use lemmy_db_queries::{ source::{ @@ -20,19 +19,18 @@ use lemmy_db_views_actor::{ community_view::CommunityView, }; use lemmy_structs::{blocking, comment::*, community::*, post::*, site::*, user::*, websocket::*}; -use lemmy_utils::{settings::Settings, APIError, ConnectionId, LemmyError}; +use lemmy_utils::{claims::Claims, settings::Settings, APIError, ConnectionId, LemmyError}; use lemmy_websocket::{serialize_websocket_message, LemmyContext, UserOperation}; use serde::Deserialize; use std::process::Command; use url::Url; -pub mod claims; pub mod comment; pub mod community; pub mod post; +pub mod routes; pub mod site; pub mod user; -pub mod version; pub mod websocket; #[async_trait::async_trait(?Send)] diff --git a/src/routes/api.rs b/crates/api/src/routes.rs similarity index 98% rename from src/routes/api.rs rename to crates/api/src/routes.rs index 1f5a5454..a55dec5f 100644 --- a/src/routes/api.rs +++ b/crates/api/src/routes.rs @@ -1,15 +1,15 @@ +use crate::Perform; use actix_web::{error::ErrorBadRequest, *}; -use lemmy_api::Perform; use lemmy_structs::{comment::*, community::*, post::*, site::*, user::*, websocket::*}; use lemmy_utils::rate_limit::RateLimit; -use lemmy_websocket::LemmyContext; +use lemmy_websocket::{routes::chat_route, LemmyContext}; use serde::Deserialize; pub fn config(cfg: &mut web::ServiceConfig, rate_limit: &RateLimit) { cfg.service( web::scope("/api/v2") // Websockets - .service(web::resource("/ws").to(super::websocket::chat_route)) + .service(web::resource("/ws").to(chat_route)) // Site .service( web::scope("/site") diff --git a/crates/api/src/site.rs b/crates/api/src/site.rs index 96ce50ca..1bdce91a 100644 --- a/crates/api/src/site.rs +++ b/crates/api/src/site.rs @@ -5,7 +5,6 @@ use crate::{ get_user_safe_settings_from_jwt, get_user_safe_settings_from_jwt_opt, is_admin, - version, Perform, }; use actix_web::web::Data; @@ -51,6 +50,7 @@ use lemmy_utils::{ location_info, settings::Settings, utils::{check_slurs, check_slurs_opt}, + version, APIError, ConnectionId, LemmyError, diff --git a/crates/api/src/user.rs b/crates/api/src/user.rs index fe124f23..da2b8f30 100644 --- a/crates/api/src/user.rs +++ b/crates/api/src/user.rs @@ -1,7 +1,6 @@ use crate::{ captcha_espeak_wav_base64, check_optional_url, - claims::Claims, collect_moderated_communities, get_user_from_jwt, get_user_from_jwt_opt, @@ -69,6 +68,7 @@ use lemmy_db_views_actor::{ use lemmy_structs::{blocking, send_email_to_user, user::*}; use lemmy_utils::{ apub::generate_actor_keypair, + claims::Claims, email::send_email, location_info, settings::Settings, @@ -121,7 +121,7 @@ impl Perform for Login { // Return the jwt Ok(LoginResponse { - jwt: Claims::jwt(user, Settings::get().hostname)?, + jwt: Claims::jwt(user.id, Settings::get().hostname)?, }) } } @@ -303,7 +303,7 @@ impl Perform for Register { // Return the jwt Ok(LoginResponse { - jwt: Claims::jwt(inserted_user, Settings::get().hostname)?, + jwt: Claims::jwt(inserted_user.id, Settings::get().hostname)?, }) } } @@ -476,7 +476,7 @@ impl Perform for SaveUserSettings { // Return the jwt Ok(LoginResponse { - jwt: Claims::jwt(updated_user, Settings::get().hostname)?, + jwt: Claims::jwt(updated_user.id, Settings::get().hostname)?, }) } } @@ -1007,7 +1007,7 @@ impl Perform for PasswordChange { // Return the jwt Ok(LoginResponse { - jwt: Claims::jwt(updated_user, Settings::get().hostname)?, + jwt: Claims::jwt(updated_user.id, Settings::get().hostname)?, }) } } diff --git a/crates/apub/src/lib.rs b/crates/apub/src/lib.rs index 0b3fee43..388d57e6 100644 --- a/crates/apub/src/lib.rs +++ b/crates/apub/src/lib.rs @@ -8,6 +8,7 @@ pub mod fetcher; pub mod http; pub mod inbox; pub mod objects; +pub mod routes; use crate::extensions::{ group_extensions::GroupExtension, diff --git a/src/routes/federation.rs b/crates/apub/src/routes.rs similarity index 99% rename from src/routes/federation.rs rename to crates/apub/src/routes.rs index 27f59683..3717a894 100644 --- a/src/routes/federation.rs +++ b/crates/apub/src/routes.rs @@ -1,6 +1,4 @@ -use actix_web::*; -use http_signature_normalization_actix::digest::middleware::VerifyDigest; -use lemmy_apub::{ +use crate::{ http::{ comment::get_apub_comment, community::{ @@ -16,6 +14,8 @@ use lemmy_apub::{ inbox::{community_inbox::community_inbox, shared_inbox::shared_inbox, user_inbox::user_inbox}, APUB_JSON_CONTENT_TYPE, }; +use actix_web::*; +use http_signature_normalization_actix::digest::middleware::VerifyDigest; use lemmy_utils::settings::Settings; use sha2::{Digest, Sha256}; diff --git a/crates/db_queries/Cargo.toml b/crates/db_queries/Cargo.toml index a25b80ff..c396b39a 100644 --- a/crates/db_queries/Cargo.toml +++ b/crates/db_queries/Cargo.toml @@ -23,4 +23,3 @@ url = { version = "2.2.0", features = ["serde"] } lazy_static = "1.4.0" regex = "1.4.3" bcrypt = "0.9.0" -diesel_json = "0.1.1" diff --git a/crates/routes/Cargo.toml b/crates/routes/Cargo.toml new file mode 100644 index 00000000..0c5eac66 --- /dev/null +++ b/crates/routes/Cargo.toml @@ -0,0 +1,27 @@ +[package] +name = "lemmy_routes" +version = "0.1.0" +edition = "2018" + +[dependencies] +lemmy_utils = { path = "../utils" } +lemmy_websocket = { path = "../websocket" } +lemmy_db_queries = { path = "../db_queries" } +lemmy_db_views = { path = "../db_views" } +lemmy_db_views_actor = { path = "../db_views_actor" } +lemmy_db_schema = { path = "../db_schema" } +lemmy_structs = { path = "../structs" } +diesel = "1.4.5" +actix = "0.10.0" +actix-web = { version = "3.3.2", default-features = false, features = ["rustls"] } +actix-web-actors = { version = "3.0.0", default-features = false } +sha2 = "0.9.3" +log = "0.4.14" +anyhow = "1.0.38" +chrono = { version = "0.4.19", features = ["serde"] } +rss = "1.10.0" +serde = { version = "1.0.123", features = ["derive"] } +awc = { version = "2.0.3", default-features = false } +url = { version = "2.2.0", features = ["serde"] } +strum = "0.20.0" +lazy_static = "1.4.0" diff --git a/src/routes/feeds.rs b/crates/routes/src/feeds.rs similarity index 99% rename from src/routes/feeds.rs rename to crates/routes/src/feeds.rs index 86467052..163452a8 100644 --- a/src/routes/feeds.rs +++ b/crates/routes/src/feeds.rs @@ -2,7 +2,6 @@ use actix_web::{error::ErrorBadRequest, *}; use anyhow::anyhow; use chrono::{DateTime, NaiveDateTime, Utc}; use diesel::PgConnection; -use lemmy_api::claims::Claims; use lemmy_db_queries::{ source::{community::Community_, user::User}, ListingType, @@ -16,7 +15,7 @@ use lemmy_db_views::{ }; use lemmy_db_views_actor::user_mention_view::{UserMentionQueryBuilder, UserMentionView}; use lemmy_structs::blocking; -use lemmy_utils::{settings::Settings, utils::markdown_to_html, LemmyError}; +use lemmy_utils::{claims::Claims, settings::Settings, utils::markdown_to_html, LemmyError}; use lemmy_websocket::LemmyContext; use rss::{ extension::dublincore::DublinCoreExtensionBuilder, diff --git a/src/routes/images.rs b/crates/routes/src/images.rs similarity index 97% rename from src/routes/images.rs rename to crates/routes/src/images.rs index c9937ee6..4d7656e1 100644 --- a/src/routes/images.rs +++ b/crates/routes/src/images.rs @@ -1,8 +1,7 @@ use actix::clock::Duration; use actix_web::{body::BodyStream, http::StatusCode, *}; use awc::Client; -use lemmy_api::claims::Claims; -use lemmy_utils::{rate_limit::RateLimit, settings::Settings}; +use lemmy_utils::{claims::Claims, rate_limit::RateLimit, settings::Settings}; use serde::{Deserialize, Serialize}; pub fn config(cfg: &mut web::ServiceConfig, rate_limit: &RateLimit) { diff --git a/src/routes/mod.rs b/crates/routes/src/lib.rs similarity index 56% rename from src/routes/mod.rs rename to crates/routes/src/lib.rs index f3cf8b12..b966b766 100644 --- a/src/routes/mod.rs +++ b/crates/routes/src/lib.rs @@ -1,7 +1,7 @@ -pub mod api; -pub mod federation; +#[macro_use] +extern crate lazy_static; + pub mod feeds; pub mod images; pub mod nodeinfo; pub mod webfinger; -pub mod websocket; diff --git a/src/routes/nodeinfo.rs b/crates/routes/src/nodeinfo.rs similarity index 97% rename from src/routes/nodeinfo.rs rename to crates/routes/src/nodeinfo.rs index e7eb9486..46ef7ce4 100644 --- a/src/routes/nodeinfo.rs +++ b/crates/routes/src/nodeinfo.rs @@ -1,9 +1,8 @@ use actix_web::{body::Body, error::ErrorBadRequest, *}; use anyhow::anyhow; -use lemmy_api::version; use lemmy_db_views::site_view::SiteView; use lemmy_structs::blocking; -use lemmy_utils::{settings::Settings, LemmyError}; +use lemmy_utils::{settings::Settings, version, LemmyError}; use lemmy_websocket::LemmyContext; use serde::{Deserialize, Serialize}; use url::Url; diff --git a/src/routes/webfinger.rs b/crates/routes/src/webfinger.rs similarity index 100% rename from src/routes/webfinger.rs rename to crates/routes/src/webfinger.rs diff --git a/crates/utils/Cargo.toml b/crates/utils/Cargo.toml index 35df3064..c10b7c2c 100644 --- a/crates/utils/Cargo.toml +++ b/crates/utils/Cargo.toml @@ -33,3 +33,4 @@ strum_macros = "0.20.1" futures = "0.3.12" diesel = "1.4.5" http = "0.2.3" +jsonwebtoken = "7.2.0" diff --git a/crates/api/src/claims.rs b/crates/utils/src/claims.rs similarity index 80% rename from crates/api/src/claims.rs rename to crates/utils/src/claims.rs index f99730bd..dff79d85 100644 --- a/crates/api/src/claims.rs +++ b/crates/utils/src/claims.rs @@ -1,6 +1,5 @@ +use crate::settings::Settings; use jsonwebtoken::{decode, encode, DecodingKey, EncodingKey, Header, TokenData, Validation}; -use lemmy_db_schema::source::user::User_; -use lemmy_utils::settings::Settings; use serde::{Deserialize, Serialize}; type Jwt = String; @@ -24,9 +23,9 @@ impl Claims { ) } - pub fn jwt(user: User_, hostname: String) -> Result { + pub fn jwt(user_id: i32, hostname: String) -> Result { let my_claims = Claims { - id: user.id, + id: user_id, iss: hostname, }; encode( diff --git a/crates/utils/src/lib.rs b/crates/utils/src/lib.rs index 2cc29131..6d8265aa 100644 --- a/crates/utils/src/lib.rs +++ b/crates/utils/src/lib.rs @@ -4,6 +4,7 @@ extern crate lazy_static; extern crate strum_macros; pub mod apub; +pub mod claims; pub mod email; pub mod rate_limit; pub mod request; @@ -11,6 +12,7 @@ pub mod settings; #[cfg(test)] mod test; pub mod utils; +pub mod version; use crate::settings::Settings; use http::StatusCode; diff --git a/crates/api/src/version.rs b/crates/utils/src/version.rs similarity index 100% rename from crates/api/src/version.rs rename to crates/utils/src/version.rs diff --git a/crates/websocket/Cargo.toml b/crates/websocket/Cargo.toml index 0329cef1..1cb71ea1 100644 --- a/crates/websocket/Cargo.toml +++ b/crates/websocket/Cargo.toml @@ -26,3 +26,5 @@ tokio = "0.3.6" strum = "0.20.0" strum_macros = "0.20.1" chrono = { version = "0.4.19", features = ["serde"] } +actix-web = { version = "3.3.2", default-features = false, features = ["rustls"] } +actix-web-actors = { version = "3.0.0", default-features = false } diff --git a/crates/websocket/src/lib.rs b/crates/websocket/src/lib.rs index 72e72b52..2144ffef 100644 --- a/crates/websocket/src/lib.rs +++ b/crates/websocket/src/lib.rs @@ -12,6 +12,7 @@ use serde::Serialize; pub mod chat_server; pub mod handlers; pub mod messages; +pub mod routes; pub struct LemmyContext { pub pool: DbPool, diff --git a/src/routes/websocket.rs b/crates/websocket/src/routes.rs similarity index 99% rename from src/routes/websocket.rs rename to crates/websocket/src/routes.rs index 9bfd6ca1..890b7be5 100644 --- a/src/routes/websocket.rs +++ b/crates/websocket/src/routes.rs @@ -1,12 +1,12 @@ -use actix::prelude::*; -use actix_web::*; -use actix_web_actors::ws; -use lemmy_utils::utils::get_ip; -use lemmy_websocket::{ +use crate::{ chat_server::ChatServer, messages::{Connect, Disconnect, StandardMessage, WSMessage}, LemmyContext, }; +use actix::prelude::*; +use actix_web::*; +use actix_web_actors::ws; +use lemmy_utils::utils::get_ip; use log::{debug, error, info}; use std::time::{Duration, Instant}; diff --git a/src/lib.rs b/src/lib.rs index e867a26b..16cddf63 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,6 +1,3 @@ #![recursion_limit = "512"] -#[macro_use] -extern crate lazy_static; pub mod code_migrations; -pub mod routes; pub mod scheduled_tasks; diff --git a/src/main.rs b/src/main.rs index 1f7b36f6..4ebedb4f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -10,7 +10,8 @@ use diesel::{ use lemmy_api::match_websocket_operation; use lemmy_apub::activity_queue::create_activity_queue; use lemmy_db_queries::get_database_url_from_env; -use lemmy_server::{code_migrations::run_advanced_migrations, routes::*, scheduled_tasks}; +use lemmy_routes::{feeds, images, nodeinfo, webfinger}; +use lemmy_server::{code_migrations::run_advanced_migrations, scheduled_tasks}; use lemmy_structs::blocking; use lemmy_utils::{ rate_limit::{rate_limiter::RateLimiter, RateLimit}, @@ -86,8 +87,8 @@ async fn main() -> Result<(), LemmyError> { .wrap(middleware::Logger::default()) .data(context) // The routes - .configure(|cfg| api::config(cfg, &rate_limiter)) - .configure(federation::config) + .configure(|cfg| lemmy_api::routes::config(cfg, &rate_limiter)) + .configure(lemmy_apub::routes::config) .configure(feeds::config) .configure(|cfg| images::config(cfg, &rate_limiter)) .configure(nodeinfo::config)