2020-11-02 18:06:50 +00:00
|
|
|
#![feature(proc_macro_hygiene, decl_macro)]
|
|
|
|
|
|
|
|
#[macro_use]
|
|
|
|
extern crate rocket;
|
|
|
|
#[macro_use]
|
|
|
|
extern crate tracing;
|
2020-09-13 16:07:06 +00:00
|
|
|
|
2020-09-13 15:23:53 +00:00
|
|
|
use color_eyre::eyre::Result;
|
2020-11-02 18:06:50 +00:00
|
|
|
use rocket_contrib::helmet::SpaceHelmet;
|
|
|
|
use rocket_prometheus::PrometheusMetrics;
|
2020-09-13 15:23:53 +00:00
|
|
|
|
2020-11-04 16:03:04 +00:00
|
|
|
use ::mi::{api, paseto, web::*, MainDatabase, APPLICATION_NAME};
|
2020-11-02 18:06:50 +00:00
|
|
|
|
2020-11-03 15:26:51 +00:00
|
|
|
#[get("/.within/botinfo")]
|
|
|
|
fn botinfo() -> &'static str {
|
|
|
|
r#"Hello, if you are reading this, you have found this URL in your
|
|
|
|
access logs. If this program is doing something you don't want it to do,
|
|
|
|
please contact me at me@christine.website.
|
|
|
|
|
|
|
|
This service is intended to act as a POSSE[1] syndication server for
|
|
|
|
various services to various other services.
|
|
|
|
|
|
|
|
Every effort is being taken to ensure that the data going through this
|
|
|
|
server is my own.
|
|
|
|
|
|
|
|
I'm sorry if this causes you any inconvenience.
|
|
|
|
|
|
|
|
[1]: https://indieweb.org/POSSE
|
|
|
|
|
|
|
|
Be well, Creator."#
|
|
|
|
}
|
|
|
|
|
2020-11-02 18:06:50 +00:00
|
|
|
fn main() -> Result<()> {
|
2020-09-13 15:23:53 +00:00
|
|
|
let _ = kankyo::init();
|
|
|
|
color_eyre::install()?;
|
2020-11-02 18:06:50 +00:00
|
|
|
tracing_subscriber::fmt::init();
|
|
|
|
|
|
|
|
info!("{} starting up", APPLICATION_NAME);
|
|
|
|
|
|
|
|
let prometheus = PrometheusMetrics::with_registry(prometheus::default_registry().clone());
|
|
|
|
rocket::ignite()
|
|
|
|
.attach(prometheus.clone())
|
|
|
|
.attach(MainDatabase::fairing())
|
|
|
|
.attach(SpaceHelmet::default())
|
2020-11-03 19:55:03 +00:00
|
|
|
.attach(paseto::ed25519_keypair())
|
2020-11-04 16:03:04 +00:00
|
|
|
.attach(discord_webhook::Client::fairing())
|
|
|
|
.attach(mastodon::Client::fairing())
|
|
|
|
.attach(pluralkit::Client::fairing())
|
|
|
|
.attach(switchcounter::Client::fairing())
|
|
|
|
.attach(twitter::Client::fairing())
|
2020-11-02 18:06:50 +00:00
|
|
|
.mount("/metrics", prometheus)
|
2020-11-03 19:55:03 +00:00
|
|
|
.mount("/", routes![botinfo])
|
2020-11-02 18:06:50 +00:00
|
|
|
.mount(
|
2020-11-03 19:55:03 +00:00
|
|
|
"/api",
|
2020-11-02 18:06:50 +00:00
|
|
|
routes![
|
2020-11-04 14:32:22 +00:00
|
|
|
api::switch::current_front,
|
|
|
|
api::switch::get,
|
|
|
|
api::switch::list,
|
|
|
|
api::switch::switch,
|
2020-11-04 17:18:17 +00:00
|
|
|
api::webmention::accept,
|
|
|
|
api::webmention::get,
|
2020-11-02 18:06:50 +00:00
|
|
|
api::get_members,
|
2020-11-04 15:24:26 +00:00
|
|
|
api::token_info,
|
|
|
|
api::tweet,
|
2020-11-04 15:54:21 +00:00
|
|
|
api::toot,
|
2020-11-02 18:06:50 +00:00
|
|
|
],
|
|
|
|
)
|
|
|
|
.launch();
|
2020-09-13 15:23:53 +00:00
|
|
|
|
|
|
|
Ok(())
|
|
|
|
}
|