expose pluralkit and the like in web

This commit is contained in:
Cadey Ratio 2020-11-04 12:36:12 -05:00
parent 19ab543438
commit 62489eaff4
3 changed files with 18 additions and 8 deletions

View File

@ -1,5 +1,9 @@
use super::{Error, Result, StringBody};
use crate::{models, paseto, schema, web, MainDatabase};
use crate::{
models, paseto, schema,
web::{PluralKit, SwitchCounter},
MainDatabase,
};
use chrono::prelude::*;
use diesel::prelude::*;
use rocket::State;
@ -82,8 +86,8 @@ pub fn current_front(conn: MainDatabase, tok: paseto::Token) -> Result<Json<Fron
pub fn switch(
conn: MainDatabase,
who: StringBody,
sc: State<web::switchcounter::Client>,
pk: State<web::pluralkit::Client>,
sc: State<SwitchCounter>,
pk: State<PluralKit>,
tok: paseto::Token,
) -> Result<String> {
use schema::{members, switches};

View File

@ -43,11 +43,11 @@ fn main() -> Result<()> {
.attach(MainDatabase::fairing())
.attach(SpaceHelmet::default())
.attach(paseto::ed25519_keypair())
.attach(discord_webhook::Client::fairing())
.attach(mastodon::Client::fairing())
.attach(pluralkit::Client::fairing())
.attach(switchcounter::Client::fairing())
.attach(twitter::Client::fairing())
.attach(DiscordWebhook::fairing())
.attach(Mastodon::fairing())
.attach(PluralKit::fairing())
.attach(SwitchCounter::fairing())
.attach(Twitter::fairing())
.mount("/metrics", prometheus)
.mount("/", routes![botinfo])
.mount(

View File

@ -4,6 +4,12 @@ pub mod pluralkit;
pub mod switchcounter;
pub mod twitter;
pub use discord_webhook::Client as DiscordWebhook;
pub use mastodon::Client as Mastodon;
pub use pluralkit::Client as PluralKit;
pub use switchcounter::Client as SwitchCounter;
pub use twitter::Client as Twitter;
pub type Result<T = ()> = std::result::Result<T, Error>;
#[derive(thiserror::Error, Debug)]