mirror of
https://github.com/Blah-IM/blahrs.git
synced 2025-05-01 00:31:09 +00:00
Reorganize workspace layout and split out blahd
This commit is contained in:
parent
370722731b
commit
668b873b07
10 changed files with 89 additions and 66 deletions
49
Cargo.lock
generated
49
Cargo.lock
generated
|
@ -224,28 +224,16 @@ name = "blah"
|
|||
version = "0.0.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"axum",
|
||||
"bitflags",
|
||||
"bitflags_serde_shim",
|
||||
"clap",
|
||||
"ed25519-dalek",
|
||||
"futures-util",
|
||||
"hex",
|
||||
"html-escape",
|
||||
"humantime",
|
||||
"rand_core",
|
||||
"rusqlite",
|
||||
"sd-notify",
|
||||
"serde",
|
||||
"serde-aux",
|
||||
"serde-constant",
|
||||
"serde_json",
|
||||
"syn",
|
||||
"tokio",
|
||||
"tokio-stream",
|
||||
"tower-http",
|
||||
"tracing",
|
||||
"tracing-subscriber",
|
||||
"uuid",
|
||||
]
|
||||
|
||||
|
@ -254,7 +242,6 @@ name = "blahctl"
|
|||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"bitflags",
|
||||
"blah",
|
||||
"clap",
|
||||
"ed25519-dalek",
|
||||
|
@ -263,6 +250,30 @@ dependencies = [
|
|||
"reqwest",
|
||||
"rusqlite",
|
||||
"tokio",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "blahd"
|
||||
version = "0.0.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"axum",
|
||||
"blah",
|
||||
"clap",
|
||||
"ed25519-dalek",
|
||||
"futures-util",
|
||||
"hex",
|
||||
"humantime",
|
||||
"rusqlite",
|
||||
"sd-notify",
|
||||
"serde",
|
||||
"serde-aux",
|
||||
"serde_json",
|
||||
"tokio",
|
||||
"tokio-stream",
|
||||
"tower-http",
|
||||
"tracing",
|
||||
"tracing-subscriber",
|
||||
"uuid",
|
||||
]
|
||||
|
||||
|
@ -462,7 +473,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "115531babc129696a58c64a4fef0a8bf9e9698629fb97e9e40767d235cfbcd53"
|
||||
dependencies = [
|
||||
"pkcs8",
|
||||
"serde",
|
||||
"signature",
|
||||
]
|
||||
|
||||
|
@ -477,7 +487,6 @@ dependencies = [
|
|||
"rand_core",
|
||||
"serde",
|
||||
"sha2",
|
||||
"signature",
|
||||
"subtle",
|
||||
"zeroize",
|
||||
]
|
||||
|
@ -1414,15 +1423,6 @@ dependencies = [
|
|||
"serde_json",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde-constant"
|
||||
version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "301d0de95fe56444b1ea1ee62363452b756fe715fb4eab505be16b906599b47e"
|
||||
dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_derive"
|
||||
version = "1.0.209"
|
||||
|
@ -1500,7 +1500,6 @@ version = "2.2.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de"
|
||||
dependencies = [
|
||||
"digest",
|
||||
"rand_core",
|
||||
]
|
||||
|
||||
|
|
47
Cargo.toml
47
Cargo.toml
|
@ -1,36 +1,29 @@
|
|||
[workspace]
|
||||
resolver = "2"
|
||||
members = [
|
||||
".",
|
||||
"blahctl",
|
||||
"blahd",
|
||||
]
|
||||
default-members = ["blahd"]
|
||||
|
||||
[package]
|
||||
name = "blah"
|
||||
version = "0.0.0"
|
||||
edition = "2021"
|
||||
|
||||
# TODO: Shrink dependencies.
|
||||
[dependencies]
|
||||
anyhow = "1.0.86"
|
||||
axum = { version = "0.7.5", features = ["tokio"] }
|
||||
bitflags = "2.6.0"
|
||||
bitflags_serde_shim = "0.2.5"
|
||||
clap = { version = "4.5.16", features = ["derive"] }
|
||||
ed25519-dalek = { version = "2.1.1", features = ["digest", "serde"] }
|
||||
futures-util = "0.3.30"
|
||||
hex = { version = "0.4.3", features = ["serde"] }
|
||||
html-escape = "0.2.13"
|
||||
humantime = "2.1.0"
|
||||
rand_core = "0.6.4"
|
||||
rusqlite = { version = "0.32.1", features = ["uuid"] }
|
||||
sd-notify = "0.4.2"
|
||||
serde = { version = "1.0.209", features = ["derive"] }
|
||||
serde-aux = "4.5.0"
|
||||
serde-constant = "0.1.0"
|
||||
serde_json = "1.0.127"
|
||||
tokio = { version = "1.39.3", features = ["macros", "rt-multi-thread", "sync"] }
|
||||
tokio-stream = { version = "0.1.15", features = ["sync"] }
|
||||
tower-http = { version = "0.5.2", features = ["cors", "limit"] }
|
||||
tracing = "0.1.40"
|
||||
tracing-subscriber = "0.3.18"
|
||||
uuid = { version = "1.10.0", features = ["serde", "v4"] }
|
||||
anyhow = "1"
|
||||
bitflags = "2"
|
||||
bitflags_serde_shim = "0.2"
|
||||
ed25519-dalek = "2.1"
|
||||
hex = { version = "0.4", features = ["serde"] }
|
||||
html-escape = "0.2"
|
||||
rand_core = "0.6"
|
||||
rusqlite = { version = "0.32", optional = true }
|
||||
serde = { version = "1", features = ["derive"] }
|
||||
serde_json = "1"
|
||||
uuid = { version = "1", features = ["serde"] }
|
||||
|
||||
[dev-dependencies]
|
||||
syn = { version = "2.0.76", features = ["full", "visit"] }
|
||||
|
||||
[workspace]
|
||||
members = [ "./blahctl" ]
|
||||
|
|
|
@ -4,14 +4,13 @@ version = "0.1.0"
|
|||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
anyhow = "1.0.86"
|
||||
bitflags = "2.6.0"
|
||||
blah.path = ".."
|
||||
clap = { version = "4.5.16", features = ["derive"] }
|
||||
ed25519-dalek = { version = "2.1.1", features = ["pkcs8", "pem", "rand_core"] }
|
||||
anyhow = "1"
|
||||
clap = { version = "4", features = ["derive"] }
|
||||
ed25519-dalek = { version = "2", features = ["pkcs8", "pem", "rand_core"] }
|
||||
hex = "0.4"
|
||||
rand = "0.8.5"
|
||||
reqwest = { version = "0.12.7", features = ["json"] }
|
||||
rusqlite = "0.32.1"
|
||||
tokio = { version = "1.39.3", features = ["rt", "macros"] }
|
||||
uuid = "1.10.0"
|
||||
rand = "0.8"
|
||||
reqwest = { version = "0.12", features = ["json"] }
|
||||
rusqlite = "0.32"
|
||||
tokio = { version = "1", features = ["rt", "macros"] }
|
||||
|
||||
blah = { path = "..", features = ["rusqlite"] }
|
||||
|
|
|
@ -3,11 +3,12 @@ use std::path::{Path, PathBuf};
|
|||
use std::{fs, io};
|
||||
|
||||
use anyhow::{Context, Result};
|
||||
use bitflags::Flags;
|
||||
use blah::bitflags;
|
||||
use blah::types::{
|
||||
ChatPayload, CreateRoomPayload, MemberPermission, RichText, RoomAttrs, RoomMember,
|
||||
RoomMemberList, ServerPermission, UserKey, WithSig,
|
||||
};
|
||||
use blah::uuid::Uuid;
|
||||
use ed25519_dalek::pkcs8::spki::der::pem::LineEnding;
|
||||
use ed25519_dalek::pkcs8::{DecodePrivateKey, DecodePublicKey, EncodePrivateKey, EncodePublicKey};
|
||||
use ed25519_dalek::{SigningKey, VerifyingKey, PUBLIC_KEY_LENGTH};
|
||||
|
@ -15,7 +16,6 @@ use rand::rngs::OsRng;
|
|||
use reqwest::Url;
|
||||
use rusqlite::{named_params, Connection};
|
||||
use tokio::runtime::Runtime;
|
||||
use uuid::Uuid;
|
||||
|
||||
/// NB. Sync with docs of [`User::url`].
|
||||
const KEY_URL_SUBPATH: &str = "/.well-known/blah/key";
|
||||
|
@ -66,7 +66,7 @@ enum DbCommand {
|
|||
},
|
||||
}
|
||||
|
||||
fn flag_parser<T: Flags>(s: &str) -> clap::error::Result<T> {
|
||||
fn flag_parser<T: bitflags::Flags>(s: &str) -> clap::error::Result<T> {
|
||||
bitflags::parser::from_str_strict(s)
|
||||
.map_err(|_| clap::Error::new(clap::error::ErrorKind::InvalidValue))
|
||||
}
|
||||
|
@ -142,7 +142,7 @@ impl User {
|
|||
}
|
||||
}
|
||||
|
||||
static INIT_SQL: &str = include_str!("../../init.sql");
|
||||
static INIT_SQL: &str = include_str!("../../blahd/init.sql");
|
||||
|
||||
fn main() -> Result<()> {
|
||||
let cli = <Cli as clap::Parser>::parse();
|
||||
|
|
26
blahd/Cargo.toml
Normal file
26
blahd/Cargo.toml
Normal file
|
@ -0,0 +1,26 @@
|
|||
[package]
|
||||
name = "blahd"
|
||||
version = "0.0.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
anyhow = "1"
|
||||
axum = { version = "0.7", features = ["tokio"] }
|
||||
clap = { version = "4", features = ["derive"] }
|
||||
ed25519-dalek = "2"
|
||||
futures-util = "0.3"
|
||||
hex = { version = "0.4", features = ["serde"] }
|
||||
humantime = "2"
|
||||
rusqlite = { version = "0.32", features = ["uuid"] }
|
||||
sd-notify = "0.4"
|
||||
serde = { version = "1", features = ["derive"] }
|
||||
serde-aux = "4"
|
||||
serde_json = "1"
|
||||
tokio = { version = "1", features = ["macros", "rt-multi-thread", "sync"] }
|
||||
tokio-stream = { version = "0.1", features = ["sync"] }
|
||||
tower-http = { version = "0.5", features = ["cors", "limit"] }
|
||||
tracing = "0.1"
|
||||
tracing-subscriber = "0.3"
|
||||
uuid = { version = "1", features = ["v4"] }
|
||||
|
||||
blah = { path = "..", features = ["rusqlite"] }
|
|
@ -1 +1,6 @@
|
|||
// Re-export of public dependencies.
|
||||
pub use bitflags;
|
||||
pub use ed25519_dalek;
|
||||
pub use uuid;
|
||||
|
||||
pub mod types;
|
||||
|
|
|
@ -367,6 +367,7 @@ impl_serde_for_bitflags!(ServerPermission);
|
|||
impl_serde_for_bitflags!(MemberPermission);
|
||||
impl_serde_for_bitflags!(RoomAttrs);
|
||||
|
||||
#[cfg(feature = "rusqlite")]
|
||||
mod sql_impl {
|
||||
use rusqlite::types::{FromSql, FromSqlError, FromSqlResult, ToSqlOutput, ValueRef};
|
||||
use rusqlite::{Result, ToSql};
|
||||
|
|
Loading…
Add table
Reference in a new issue