2020-10-26 16:56:24 +00:00
|
|
|
#![feature(proc_macro_hygiene, decl_macro)]
|
|
|
|
|
|
|
|
#[macro_use]
|
|
|
|
extern crate rocket;
|
|
|
|
|
2020-10-27 15:43:54 +00:00
|
|
|
use color_eyre::eyre::Result;
|
2020-10-28 16:20:00 +00:00
|
|
|
use rocket_contrib::helmet::SpaceHelmet;
|
2020-10-30 15:01:36 +00:00
|
|
|
use rocket_oauth2::OAuth2;
|
2020-10-26 16:56:24 +00:00
|
|
|
|
2020-10-31 00:38:00 +00:00
|
|
|
use ::wasmcloud::{api, b2, gitea, jwt, Gitea, MainDatabase};
|
2020-10-30 18:09:35 +00:00
|
|
|
|
2020-10-27 15:43:54 +00:00
|
|
|
fn main() -> Result<()> {
|
|
|
|
color_eyre::install()?;
|
|
|
|
tracing_subscriber::fmt::init();
|
|
|
|
|
2020-10-28 19:00:57 +00:00
|
|
|
// XXX(Xe): This looks ineffectual, however it forces jwt::SECRET to be
|
|
|
|
// evaluated and will kill the program if JWT_SECRET is not found.
|
2020-10-28 17:23:01 +00:00
|
|
|
let _ = *jwt::SECRET;
|
2020-10-30 18:09:35 +00:00
|
|
|
let _ = *b2::CREDS;
|
2020-10-30 21:18:52 +00:00
|
|
|
let _ = *b2::BUCKET_ID;
|
2020-10-28 17:23:01 +00:00
|
|
|
|
2020-10-26 16:56:24 +00:00
|
|
|
rocket::ignite()
|
2020-10-27 15:43:54 +00:00
|
|
|
.attach(OAuth2::<Gitea>::fairing("gitea"))
|
2020-10-26 16:56:24 +00:00
|
|
|
.attach(MainDatabase::fairing())
|
2020-10-27 15:43:54 +00:00
|
|
|
.attach(SpaceHelmet::default())
|
2020-10-28 18:09:03 +00:00
|
|
|
.mount(
|
|
|
|
"/api",
|
|
|
|
routes![
|
2020-10-30 15:01:36 +00:00
|
|
|
api::handler::create,
|
2020-10-30 14:26:56 +00:00
|
|
|
api::handler::list,
|
|
|
|
api::handler::get,
|
|
|
|
api::handler::delete,
|
2020-10-30 15:57:29 +00:00
|
|
|
api::handler::get_config,
|
|
|
|
api::handler::create_config,
|
2020-10-30 21:18:52 +00:00
|
|
|
api::handler::upload_version,
|
2020-10-30 14:26:56 +00:00
|
|
|
api::user::whoami,
|
|
|
|
api::user::get,
|
|
|
|
api::token::list,
|
|
|
|
api::token::delete,
|
|
|
|
api::token::create,
|
2020-10-28 18:09:03 +00:00
|
|
|
],
|
|
|
|
)
|
2020-10-31 00:18:38 +00:00
|
|
|
.mount("/login/gitea", routes![gitea::login, gitea::callback])
|
2020-10-27 15:43:54 +00:00
|
|
|
.launch();
|
|
|
|
|
|
|
|
Ok(())
|
2020-10-26 16:56:24 +00:00
|
|
|
}
|