Skip to content

Commit

Permalink
Add bundle-schema option to CLI
Browse files Browse the repository at this point in the history
  • Loading branch information
garryod committed Jan 5, 2024
1 parent fea447b commit 92d3c70
Show file tree
Hide file tree
Showing 8 changed files with 250 additions and 34 deletions.
154 changes: 154 additions & 0 deletions bundler/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion bundler/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@ version = "0.1.0"
edition = "2021"

[dependencies]
anyhow = "1.0.79"
anyhow = { version = "1.0.79" }
axum = { version = "0.7.3" }
axum-extra = { version = "0.9.1", features = ["typed-header"] }
clap = { version = "4.4.12", features = ["derive", "env"] }
clio = { version = "0.3.5", features = ["clap-parse"] }
dotenvy = { version = "0.15.7" }
flate2 = { version = "1.0.28" }
headers = { version = "0.4.0" }
humantime = { version = "2.1.0" }
schemars = { version = "0.8.16" }
serde = { version = "1.0.194", features = ["derive"] }
serde_json = { version = "1.0.110" }
sqlx = { version = "0.7.3", features = [
Expand Down
12 changes: 11 additions & 1 deletion bundler/src/bundle.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
use crate::permissionables::{permissions::Permissions, proposals::Proposals, sessions::Sessions};
use flate2::{write::GzEncoder, Compression};
use schemars::{schema::RootSchema, schema_for};
use serde::Serialize;
use sqlx::MySqlPool;
use std::{
collections::hash_map::DefaultHasher,
collections::{hash_map::DefaultHasher, BTreeMap},
hash::{Hash, Hasher},
};
use tar::Header;
Expand Down Expand Up @@ -148,4 +149,13 @@ where

Ok(bundle_builder.into_inner()?.finish()?)
}

/// Produces a set of schemas associated with the data in the bundle
pub fn schemas() -> BTreeMap<&'static str, RootSchema> {
BTreeMap::from([
("proposals", schema_for!(Proposals)),
("sessions", schema_for!(Sessions)),
("permissions", schema_for!(Permissions)),
])
}
}
Loading

0 comments on commit 92d3c70

Please sign in to comment.