updates, move main.rs to bin/web.rs

Signed-off-by: Christine Dodrill <me@christine.website>
This commit is contained in:
Cadey Ratio 2021-01-10 15:31:54 -05:00
parent b816e73bf3
commit 3384d81832
9 changed files with 468 additions and 556 deletions

981
backend/Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -1,3 +1,4 @@
#![allow(unreachable_code)]
#[macro_use] #[macro_use]
extern crate tracing; extern crate tracing;

View File

@ -11,9 +11,9 @@ use rocket_contrib::helmet::SpaceHelmet;
use rocket_cors::{AllowedHeaders, AllowedOrigins}; use rocket_cors::{AllowedHeaders, AllowedOrigins};
use rocket_prometheus::PrometheusMetrics; use rocket_prometheus::PrometheusMetrics;
use ::mi::{api, frontend, paseto, rocket_trace::*, web::*, MainDatabase, APPLICATION_NAME}; use ::mi::{
api, frontend, paseto, rocket_trace::*, web::*, wellknown, MainDatabase, APPLICATION_NAME,
mod wellknown; };
fn main() -> Result<()> { fn main() -> Result<()> {
color_eyre::install()?; color_eyre::install()?;
@ -27,7 +27,6 @@ fn main() -> Result<()> {
"http://mi.akua", "http://mi.akua",
]); ]);
// You can also deserialize this
let cors = rocket_cors::CorsOptions { let cors = rocket_cors::CorsOptions {
allowed_origins, allowed_origins,
allowed_methods: vec![Method::Get, Method::Post] allowed_methods: vec![Method::Get, Method::Post]

View File

@ -25,6 +25,7 @@ pub mod paseto;
pub mod rocket_trace; pub mod rocket_trace;
pub mod schema; pub mod schema;
pub mod web; pub mod web;
pub mod wellknown;
#[database("main_data")] #[database("main_data")]
pub struct MainDatabase(SqliteConnection); pub struct MainDatabase(SqliteConnection);

View File

@ -1,14 +1,14 @@
#[get("/.within/botinfo")] #[get("/.within/botinfo")]
fn botinfo() -> &'static str { pub fn botinfo() -> &'static str {
include_str!("./botinfo.txt") include_str!("./botinfo.txt")
} }
#[get("/robots.txt")] #[get("/robots.txt")]
fn robots() -> String { pub fn robots() -> String {
include_str!("./robots.txt").into_string() include_str!("./robots.txt").to_string()
} }
#[get("/security.txt")] #[get("/security.txt")]
fn security() -> String { pub fn security() -> String {
include_str!("./security.txt").into_string() include_str!("./security.txt").to_string()
} }

View File

@ -39,7 +39,7 @@ let
${composite}/bin/migrate_database ${composite}/bin/migrate_database
${composite}/bin/bridgy_migrate || true ${composite}/bin/bridgy_migrate || true
export ROCKET_ASSET_PATH=${composite}/public export ROCKET_ASSET_PATH=${composite}/public
exec ${composite}/bin/mi exec ${composite}/bin/web
''; '';
in symlinkJoin { in symlinkJoin {
name = "mi"; name = "mi";

View File

@ -4,7 +4,7 @@ let
pkgs = pkgs =
import sources.nixpkgs { overlays = [ (import sources.nixpkgs-mozilla) ]; }; import sources.nixpkgs { overlays = [ (import sources.nixpkgs-mozilla) ]; };
channel = "nightly"; channel = "nightly";
date = "2020-10-25"; date = "2021-01-10";
targets = [ ]; targets = [ ];
chan = pkgs.rustChannelOfTargets channel date targets; chan = pkgs.rustChannelOfTargets channel date targets;
in chan in chan

View File

@ -17,10 +17,10 @@
"homepage": "", "homepage": "",
"owner": "nmattia", "owner": "nmattia",
"repo": "naersk", "repo": "naersk",
"rev": "d645515b7159c75087b3d51f23a68047c2c09699", "rev": "a76924cbbb17c387e5ae4998a4721d88a3ac95c0",
"sha256": "16hjyf1nkvwhb5nw989qhm3gdlim5wfw515bnvxpix5ff8jfbh9x", "sha256": "09b5g2krf8mfpajgz2bgapkv3dpimg0qx1nfpjafcrsk0fhxmqay",
"type": "tarball", "type": "tarball",
"url": "https://github.com/nmattia/naersk/archive/d645515b7159c75087b3d51f23a68047c2c09699.tar.gz", "url": "https://github.com/nmattia/naersk/archive/a76924cbbb17c387e5ae4998a4721d88a3ac95c0.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz" "url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
}, },
"niv": { "niv": {
@ -29,10 +29,10 @@
"homepage": "https://github.com/nmattia/niv", "homepage": "https://github.com/nmattia/niv",
"owner": "nmattia", "owner": "nmattia",
"repo": "niv", "repo": "niv",
"rev": "20c899271f288d33114760bc298838575fc6c7f9", "rev": "94dadba1a3a6a2f0b8ca2963e49daeec5d4e3098",
"sha256": "07zswk6dhlydihl9g6skmy52grjvqpra8r98f2dmbgwzc1yhjhxq", "sha256": "1y2h9wl7w60maa2m4xw9231xdr325xynzpph8xr4j5vsznygv986",
"type": "tarball", "type": "tarball",
"url": "https://github.com/nmattia/niv/archive/20c899271f288d33114760bc298838575fc6c7f9.tar.gz", "url": "https://github.com/nmattia/niv/archive/94dadba1a3a6a2f0b8ca2963e49daeec5d4e3098.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz" "url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
}, },
"nixpkgs": { "nixpkgs": {

View File

@ -8,14 +8,18 @@ in pkgs.mkShell rec {
buildInputs = with pkgs; [ buildInputs = with pkgs; [
# rust # rust
rust rust
cargo-watch
# system deps
pkgconfig pkgconfig
openssl openssl
cmake cmake
zlib zlib
diesel-cli
sqlite sqlite
libsodium libsodium
cargo-watch
# tools
diesel-cli
# elm # elm
elmPackages.elm elmPackages.elm