feat: subdivide into features

This commit is contained in:
əlemi 2024-04-06 18:03:13 +02:00
parent a624222751
commit 24d547e93a
Signed by: alemi
GPG key ID: A4895B84D311642C
3 changed files with 41 additions and 22 deletions

View file

@ -9,27 +9,34 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies] [dependencies]
axum = "0.7.3" thiserror = "1"
chrono = { version = "0.4.31", features = ["serde"] } rand = "0.8"
clap = { version = "4.5.3", features = ["derive"] } sha256 = "1.5"
paste = "1.0.14" openssl = "0.10" # TODO handle pubkeys with a smaller crate
reqwest = { version = "0.12", features = ["json"] } base64 = "0.22"
sea-orm = { version = "0.12.14", features = ["macros", "sqlx-sqlite", "runtime-tokio-rustls"] } chrono = { version = "0.4", features = ["serde"] }
sea-orm-migration = "0.12.15" uuid = { version = "1.8", features = ["v4"] }
serde = { version = "1.0.193", features = ["derive"] } serde = { version = "1", features = ["derive"] }
serde_json = "1.0.108" serde_json = "1"
thiserror = "1.0.58"
tokio = { version = "1.35.1", features = ["full"] }
tracing = "0.1.40"
tracing-subscriber = "0.3.18"
uuid = { version = "1.8.0", features = ["v4"] }
jrd = "0.1" jrd = "0.1"
apb = { path = "apb", features = ["dict", "fetch", "orm"] } tracing = "0.1"
tracing-subscriber = "0.3"
clap = { version = "4.5", features = ["derive"] }
tokio = { version = "1.35", features = ["full"] } # TODO slim this down
sea-orm = { version = "0.12", features = ["macros", "sqlx-sqlite", "runtime-tokio-rustls"] }
reqwest = { version = "0.12", features = ["json"] }
axum = "0.7"
apb = { path = "apb", features = ["unstructured", "fetch", "orm"] }
# nodeinfo = "0.0.2" # the version on crates.io doesn't re-export necessary types to build the struct!!! # nodeinfo = "0.0.2" # the version on crates.io doesn't re-export necessary types to build the struct!!!
nodeinfo = { git = "https://codeberg.org/thefederationinfo/nodeinfo-rs", rev = "e865094804" } nodeinfo = { git = "https://codeberg.org/thefederationinfo/nodeinfo-rs", rev = "e865094804" }
rand = "0.8.5"
sha256 = "1.5.0"
openssl = "0.10.64"
base64 = "0.22.0"
http-signature-normalization = "0.7.0" http-signature-normalization = "0.7.0"
mastodon-async-entities = "1.1.0" # migrations
sea-orm-migration = { version = "0.12", optional = true }
# mastodon
mastodon-async-entities = { version = "1.1.0", optional = true }
[features]
default = ["faker", "migrations"]
faker = []
migrations = ["dep:sea-orm-migration"]
mastodon = ["dep:mastodon-async-entities"]

View file

@ -1,18 +1,25 @@
pub mod activitypub; pub mod activitypub;
mod model; mod model;
mod migrations;
mod server; mod server;
mod router; mod router;
mod errors; mod errors;
mod auth; mod auth;
mod dispatcher; mod dispatcher;
mod fetcher; mod fetcher;
#[cfg(feature = "migrations")]
mod migrations;
#[cfg(feature = "migrations")]
use sea_orm_migration::MigratorTrait;
#[cfg(feature = "mastodon")]
mod mastodon; mod mastodon;
use clap::{Parser, Subcommand}; use clap::{Parser, Subcommand};
use sea_orm::{ConnectOptions, Database, EntityTrait, IntoActiveModel}; use sea_orm::{ConnectOptions, Database, EntityTrait, IntoActiveModel};
use sea_orm_migration::MigratorTrait;
pub use errors::UpubResult as Result; pub use errors::UpubResult as Result;
@ -43,9 +50,11 @@ enum CliCommand {
/// run fediverse server /// run fediverse server
Serve , Serve ,
#[cfg(feature = "migrations")]
/// apply database migrations /// apply database migrations
Migrate, Migrate,
#[cfg(feature = "faker")]
/// generate fake user, note and activity /// generate fake user, note and activity
Faker{ Faker{
/// how many fake statuses to insert for root user /// how many fake statuses to insert for root user
@ -86,9 +95,11 @@ async fn main() {
CliCommand::Serve => router::serve(db, args.domain) CliCommand::Serve => router::serve(db, args.domain)
.await, .await,
#[cfg(feature = "migrations")]
CliCommand::Migrate => migrations::Migrator::up(&db, None) CliCommand::Migrate => migrations::Migrator::up(&db, None)
.await.expect("error applying migrations"), .await.expect("error applying migrations"),
#[cfg(feature = "faker")]
CliCommand::Faker { count } => model::faker::faker(&db, args.domain, count) CliCommand::Faker { count } => model::faker::faker(&db, args.domain, count)
.await.expect("error creating fake entities"), .await.expect("error creating fake entities"),

View file

@ -12,6 +12,7 @@ pub mod session;
pub mod delivery; pub mod delivery;
pub mod application; pub mod application;
#[cfg(feature = "faker")]
pub mod faker; pub mod faker;
#[derive(Debug, Clone, thiserror::Error)] #[derive(Debug, Clone, thiserror::Error)]