Split into bin and lib, so we can have extra binaries that use the lib

This commit is contained in:
Mike Dilger 2024-02-21 12:10:10 +13:00
parent 1674b2f646
commit d7f8ed3f60
33 changed files with 120 additions and 58 deletions

25
Cargo.lock generated
View File

@ -144,6 +144,31 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "chorus"
version = "1.0.6"
dependencies = [
"chorus-lib",
"dashmap",
"env_logger",
"futures",
"heed",
"hyper",
"hyper-tungstenite",
"lazy_static",
"log",
"mmap-append",
"ron",
"rustls-pemfile",
"secp256k1",
"serde",
"tempfile",
"textnonce",
"tokio",
"tokio-rustls",
"url",
]
[[package]]
name = "chorus-lib"
version = "1.0.6"
dependencies = [
"dashmap",
"env_logger",

View File

@ -1,30 +1,6 @@
[package]
name = "chorus"
version = "1.0.6"
description = "A personal relay for nostr"
authors = ["Mike Dilger <mike@mikedilger.com>"]
license = "MIT"
repository = "https://github.com/mikedilger/chorus"
edition = "2021"
[dependencies]
dashmap = "5.5"
env_logger = "0.10"
futures = "0.3"
heed = { git = "https://github.com/meilisearch/heed", rev = "64fd6fec293c0dee94855b8267557ce03e7ce5d8" }
hyper = { version = "0.14", features = [ "http1", "server", "runtime", "stream" ] }
hyper-tungstenite = "0.11"
lazy_static = "1.4"
log = "0.4"
mmap-append = { git = "https://github.com/mikedilger/mmap-append", rev = "0d20e193e7f13a442865a4a40a5da9a120e87411" }
ron = "0.8"
rustls-pemfile = "1.0"
secp256k1 = { version = "0.28", features = [ "hashes", "global-context", "rand-std" ] }
serde = { version = "1.0", features = ["derive"] }
textnonce = "1"
tokio = { version = "1", features = [ "full" ] }
tokio-rustls = "0.24"
url = "2.5"
[dev-dependencies]
tempfile = "3"
[workspace]
members = [
"chorus-lib",
"chorus-bin",
]
resolver = "2"

31
chorus-bin/Cargo.toml Normal file
View File

@ -0,0 +1,31 @@
[package]
name = "chorus"
version = "1.0.6"
description = "A personal relay for nostr"
authors = ["Mike Dilger <mike@mikedilger.com>"]
license = "MIT"
repository = "https://github.com/mikedilger/chorus"
edition = "2021"
[dependencies]
chorus-lib = { path = "../chorus-lib" }
dashmap = "5.5"
env_logger = "0.10"
futures = "0.3"
heed = { git = "https://github.com/meilisearch/heed", rev = "64fd6fec293c0dee94855b8267557ce03e7ce5d8" }
hyper = { version = "0.14", features = [ "http1", "server", "runtime", "stream" ] }
hyper-tungstenite = "0.11"
lazy_static = "1.4"
log = "0.4"
mmap-append = { git = "https://github.com/mikedilger/mmap-append", rev = "0d20e193e7f13a442865a4a40a5da9a120e87411" }
ron = "0.8"
rustls-pemfile = "1.0"
secp256k1 = { version = "0.28", features = [ "hashes", "global-context", "rand-std" ] }
serde = { version = "1.0", features = ["derive"] }
textnonce = "1"
tokio = { version = "1", features = [ "full" ] }
tokio-rustls = "0.24"
url = "2.5"
[dev-dependencies]
tempfile = "3"

View File

@ -1,6 +1,6 @@
use crate::config::Config;
use crate::ip::{Ban, IpData};
use crate::store::Store;
use chorus_lib::config::Config;
use chorus_lib::ip::{Ban, IpData};
use chorus_lib::store::Store;
use dashmap::DashMap;
use hyper::server::conn::Http;
use lazy_static::lazy_static;

View File

@ -1,24 +1,16 @@
include!("macros.rs");
pub mod config;
pub mod error;
pub mod globals;
pub mod ip;
pub mod nostr;
pub mod reply;
pub mod store;
pub mod tls;
pub mod types;
pub mod web;
use crate::config::{Config, FriendlyConfig};
use crate::error::{ChorusError, Error};
use crate::globals::{Globals, GLOBALS};
use crate::ip::Ban;
use crate::reply::NostrReply;
use crate::store::Store;
use crate::tls::MaybeTlsStream;
use crate::types::{OwnedFilter, Pubkey, Time};
use chorus_lib::config::{Config, FriendlyConfig};
use chorus_lib::error::{ChorusError, Error};
use chorus_lib::ip::Ban;
use chorus_lib::reply::NostrReply;
use chorus_lib::store::Store;
use chorus_lib::types::{OwnedFilter, Pubkey, Time};
use futures::{sink::SinkExt, stream::StreamExt};
use hyper::service::Service;
use hyper::upgrade::Upgraded;

View File

@ -1,10 +1,10 @@
use crate::error::{ChorusError, Error};
use crate::globals::GLOBALS;
use crate::reply::{NostrReply, NostrReplyPrefix};
use crate::types::parse::json_escape::json_unescape;
use crate::types::parse::json_parse::*;
use crate::types::{Event, Filter, Kind, OwnedFilter, Pubkey, Time};
use crate::WebSocketService;
use chorus_lib::error::{ChorusError, Error};
use chorus_lib::reply::{NostrReply, NostrReplyPrefix};
use chorus_lib::types::parse::json_escape::json_unescape;
use chorus_lib::types::parse::json_parse::*;
use chorus_lib::types::{Event, Filter, Kind, OwnedFilter, Pubkey, Time};
use futures::SinkExt;
use hyper_tungstenite::tungstenite::Message;
use url::Url;

View File

@ -1,5 +1,5 @@
use crate::config::Config;
use crate::error::{ChorusError, Error};
use chorus_lib::config::Config;
use chorus_lib::error::{ChorusError, Error};
use rustls::{Certificate, PrivateKey};
use std::fs::File;
use std::io::BufReader;

View File

@ -1,6 +1,6 @@
use crate::config::Config;
use crate::error::Error;
use crate::globals::GLOBALS;
use chorus_lib::config::Config;
use chorus_lib::error::Error;
use hyper::{Body, Request, Response, StatusCode};
use std::net::SocketAddr;

30
chorus-lib/Cargo.toml Normal file
View File

@ -0,0 +1,30 @@
[package]
name = "chorus-lib"
version = "1.0.6"
description = "A personal relay for nostr"
authors = ["Mike Dilger <mike@mikedilger.com>"]
license = "MIT"
repository = "https://github.com/mikedilger/chorus"
edition = "2021"
[dependencies]
dashmap = "5.5"
env_logger = "0.10"
futures = "0.3"
heed = { git = "https://github.com/meilisearch/heed", rev = "64fd6fec293c0dee94855b8267557ce03e7ce5d8" }
hyper = { version = "0.14", features = [ "http1", "server", "runtime", "stream" ] }
hyper-tungstenite = "0.11"
lazy_static = "1.4"
log = "0.4"
mmap-append = { git = "https://github.com/mikedilger/mmap-append", rev = "0d20e193e7f13a442865a4a40a5da9a120e87411" }
ron = "0.8"
rustls-pemfile = "1.0"
secp256k1 = { version = "0.28", features = [ "hashes", "global-context", "rand-std" ] }
serde = { version = "1.0", features = ["derive"] }
textnonce = "1"
tokio = { version = "1", features = [ "full" ] }
tokio-rustls = "0.24"
url = "2.5"
[dev-dependencies]
tempfile = "3"

8
chorus-lib/src/lib.rs Normal file
View File

@ -0,0 +1,8 @@
include!("macros.rs");
pub mod config;
pub mod error;
pub mod ip;
pub mod reply;
pub mod store;
pub mod types;

View File

@ -1,4 +1,4 @@
use crate::Error;
use crate::error::Error;
use serde::{Deserialize, Serialize};
use std::fmt;

View File

@ -1,4 +1,4 @@
use crate::Error;
use crate::error::Error;
use std::fmt;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]