Compare commits
No commits in common. "19a21b8cdfa9703e6f6cb251cc4524000cf1d637" and "a107d9e283d7e23eec15d1a3a08f14ef94871659" have entirely different histories.
19a21b8cdf
...
a107d9e283
|
|
@ -0,0 +1,34 @@
|
||||||
|
use std::{env, process::Command};
|
||||||
|
|
||||||
|
fn main()
|
||||||
|
{
|
||||||
|
if env::var_os("CARGO_FEATURE_WEB").is_some() {
|
||||||
|
println!("cargo:rerun-if-changed=web");
|
||||||
|
|
||||||
|
let status = Command::new("yarn")
|
||||||
|
.arg("build")
|
||||||
|
.current_dir("web")
|
||||||
|
.status()
|
||||||
|
.expect("Failed to build frontend.");
|
||||||
|
|
||||||
|
if status.code().unwrap() != 0 {
|
||||||
|
panic!("Building frontend failed.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// This currently isn't possible because cargo doc requires a lock on the Cargo.lock file that
|
||||||
|
// can't be provided
|
||||||
|
|
||||||
|
// if env::var_os("CARGO_FEATURE_DOCS").is_some() {
|
||||||
|
// println!("cargo:rerun-if-changed=src");
|
||||||
|
|
||||||
|
// let status = Command::new(env::var("CARGO").unwrap())
|
||||||
|
// .args(["doc", "--no-deps"])
|
||||||
|
// .status()
|
||||||
|
// .expect("Failed to build docs.");
|
||||||
|
|
||||||
|
// if status.code().unwrap() != 0 {
|
||||||
|
// panic!("Failed to build docs.");
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
}
|
||||||
21
src/main.rs
21
src/main.rs
|
|
@ -18,10 +18,6 @@ use rocket::{
|
||||||
serde::json::{json, Value},
|
serde::json::{json, Value},
|
||||||
Build, Orbit, Request, Rocket,
|
Build, Orbit, Request, Rocket,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[cfg(any(feature = "web", feature="docs"))]
|
|
||||||
use rocket::fs;
|
|
||||||
|
|
||||||
use rocket_sync_db_pools::database;
|
use rocket_sync_db_pools::database;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
|
@ -98,7 +94,7 @@ fn rocket() -> _
|
||||||
.merge(Yaml::file("Rb.yaml").nested())
|
.merge(Yaml::file("Rb.yaml").nested())
|
||||||
.merge(Env::prefixed("RB_").global());
|
.merge(Env::prefixed("RB_").global());
|
||||||
|
|
||||||
let mut instance = rocket::custom(figment)
|
rocket::custom(figment)
|
||||||
.attach(RbDbConn::fairing())
|
.attach(RbDbConn::fairing())
|
||||||
.attach(AdHoc::try_on_ignite(
|
.attach(AdHoc::try_on_ignite(
|
||||||
"Run database migrations",
|
"Run database migrations",
|
||||||
|
|
@ -116,18 +112,5 @@ fn rocket() -> _
|
||||||
routes![admin::create_user, admin::get_user_info],
|
routes![admin::create_user, admin::get_user_info],
|
||||||
)
|
)
|
||||||
.mount("/api/sections", routes![sections::create_section])
|
.mount("/api/sections", routes![sections::create_section])
|
||||||
.mount("/api/posts", routes![posts::get, posts::create]);
|
.mount("/api/posts", routes![posts::get, posts::create])
|
||||||
|
|
||||||
// It's weird that this is allowed, but the line on its own isn't
|
|
||||||
#[cfg(feature = "web")]
|
|
||||||
{
|
|
||||||
instance = instance.mount("/", fs::FileServer::new("/var/www/html/web", fs::Options::Index | fs::Options::NormalizeDirs));
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(feature = "docs")]
|
|
||||||
{
|
|
||||||
instance = instance.mount("/docs", fs::FileServer::new("/var/www/html/docs", fs::Options::Index | fs::Options::NormalizeDirs));
|
|
||||||
}
|
|
||||||
|
|
||||||
instance
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Reference in New Issue