From 102f6654a97cb2eee587c2f35865598f9110adb1 Mon Sep 17 00:00:00 2001 From: Christine Dodrill Date: Fri, 30 Oct 2020 20:38:00 -0400 Subject: [PATCH] make wasmcloud a library --- Cargo.toml | 5 ++++- src/lib.rs | 32 ++++++++++++++++++++++++++++++++ src/main.rs | 27 +-------------------------- 3 files changed, 37 insertions(+), 27 deletions(-) create mode 100644 src/lib.rs diff --git a/Cargo.toml b/Cargo.toml index b1dcac3..03a33f6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,7 +10,6 @@ edition = "2018" blake3 = "0.3" chrono = { version = "0.4", features = ["serde"] } color-eyre = "0.5" -diesel = { version = "1", features = ["postgres", "r2d2", "uuidv07", "chrono"] } elfs = "0" hex = "0" hmac = "0.9" @@ -31,6 +30,10 @@ uuid = { version = "0.7", features = ["serde", "v4"] } rocket_upload = { path = "./lib/rocket_upload" } +[dependencies.diesel] +version = "1" +features = ["postgres", "r2d2", "uuidv07", "chrono"] + [dependencies.rocket_contrib] version = "0.4" default-features = false diff --git a/src/lib.rs b/src/lib.rs new file mode 100644 index 0000000..c59d880 --- /dev/null +++ b/src/lib.rs @@ -0,0 +1,32 @@ +#![feature(proc_macro_hygiene, decl_macro)] + +#[macro_use] +extern crate diesel; +#[macro_use] +extern crate rocket; +#[macro_use] +extern crate rocket_contrib; +#[macro_use] +extern crate tracing; + +use diesel::pg::PgConnection; + +pub mod api; +pub mod b2; +pub mod gitea; +pub mod jwt; +pub mod models; +pub mod schema; + +#[database("main_data")] +pub struct MainDatabase(PgConnection); + +pub struct Gitea; + +// Name your user agent after your app? +pub static APP_USER_AGENT: &str = concat!( + env!("CARGO_PKG_NAME"), + "/", + env!("CARGO_PKG_VERSION"), + " +https://tulpa.dev/wasmcloud/wasmcloud", +); diff --git a/src/main.rs b/src/main.rs index b7d1b60..8943787 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,38 +1,13 @@ #![feature(proc_macro_hygiene, decl_macro)] -#[macro_use] -extern crate diesel; #[macro_use] extern crate rocket; -#[macro_use] -extern crate rocket_contrib; -#[macro_use] -extern crate tracing; use color_eyre::eyre::Result; -use diesel::pg::PgConnection; use rocket_contrib::helmet::SpaceHelmet; use rocket_oauth2::OAuth2; -pub mod api; -pub mod b2; -pub mod gitea; -pub mod jwt; -pub mod models; -pub mod schema; - -#[database("main_data")] -pub struct MainDatabase(PgConnection); - -pub struct Gitea; - -// Name your user agent after your app? -pub static APP_USER_AGENT: &str = concat!( - env!("CARGO_PKG_NAME"), - "/", - env!("CARGO_PKG_VERSION"), - " +https://tulpa.dev/wasmcloud/api", -); +use ::wasmcloud::{api, b2, gitea, jwt, Gitea, MainDatabase}; fn main() -> Result<()> { color_eyre::install()?;