51 lines
1.2 KiB
Rust
51 lines
1.2 KiB
Rust
// This client code really just serves as the url router for the main website where we describe what the project is about
|
|
#![feature(proc_macro_hygiene, decl_macro, plugin)]
|
|
#[macro_use] extern crate serde_derive;
|
|
#[macro_use] extern crate rocket;
|
|
#[macro_use] extern crate rocket_contrib;
|
|
#[macro_use] extern crate diesel;
|
|
extern crate chrono;
|
|
extern crate dotenv;
|
|
extern crate serde;
|
|
extern crate rand;
|
|
|
|
|
|
use rocket_contrib::serve::StaticFiles;
|
|
use rocket_contrib::templates::Template;
|
|
use dotenv::dotenv;
|
|
use std::env::var;
|
|
|
|
mod website;
|
|
mod schema;
|
|
mod models;
|
|
mod invites;
|
|
mod payload;
|
|
|
|
use invites::*;
|
|
|
|
#[database("freechat")]
|
|
pub struct DBConn(diesel::MysqlConnection);
|
|
|
|
pub fn rocket() -> rocket::Rocket {
|
|
rocket::ignite()
|
|
.mount("/static", StaticFiles::from("/static"))
|
|
.mount("/invite", routes![
|
|
generate_invite, use_invite
|
|
])
|
|
.attach(Template::fairing())
|
|
.attach(DBConn::fairing())
|
|
}
|
|
|
|
fn main() -> Result<(), i32> {
|
|
match dotenv() {
|
|
Ok(_d) => {
|
|
println!("Got .env: {:?}", var("DATABASE_URL").unwrap());
|
|
rocket().launch();
|
|
},
|
|
Err(e) => {
|
|
panic!("`.env` Could not be loaded err: {:?}", e);
|
|
}
|
|
}
|
|
Ok(())
|
|
}
|