2021-07-18 00:32:57 +00:00
|
|
|
#![feature(proc_macro_hygiene, decl_macro)]
|
|
|
|
|
|
|
|
#[macro_use]
|
|
|
|
extern crate log;
|
|
|
|
#[macro_use]
|
|
|
|
extern crate rocket;
|
|
|
|
#[macro_use]
|
|
|
|
extern crate rocket_contrib;
|
2021-07-18 17:16:00 +00:00
|
|
|
use rocket_contrib::serve::StaticFiles;
|
2021-07-17 23:41:41 +00:00
|
|
|
|
2021-07-17 11:57:40 +00:00
|
|
|
use rocket::fairing::AdHoc;
|
2021-07-17 18:45:52 +00:00
|
|
|
|
2021-07-17 15:40:05 +00:00
|
|
|
mod auth;
|
2021-07-17 23:41:41 +00:00
|
|
|
mod chat;
|
2021-07-18 00:32:57 +00:00
|
|
|
mod file_io;
|
|
|
|
mod message;
|
|
|
|
mod user;
|
2021-07-16 14:55:07 +00:00
|
|
|
|
2021-07-18 00:32:57 +00:00
|
|
|
fn main() {
|
2021-07-17 18:45:52 +00:00
|
|
|
env_logger::init();
|
|
|
|
info!("Started up rocket");
|
2021-07-17 11:57:40 +00:00
|
|
|
let cors_fairing = AdHoc::on_response("CORS", |_, res| {
|
2021-07-22 18:23:59 +00:00
|
|
|
res.set_raw_header("Access-Control-Allow-Origin", "http://localhost:8000");
|
2021-07-17 11:57:40 +00:00
|
|
|
});
|
2021-07-17 18:45:52 +00:00
|
|
|
info!("Built CORS fairing");
|
2021-07-17 11:57:40 +00:00
|
|
|
|
2021-07-18 00:32:57 +00:00
|
|
|
rocket::ignite()
|
2021-07-17 11:57:40 +00:00
|
|
|
.mount(
|
2021-07-18 17:16:00 +00:00
|
|
|
"/api",
|
2021-07-18 00:32:57 +00:00
|
|
|
routes![
|
|
|
|
auth::get_user,
|
|
|
|
auth::register_user,
|
2021-07-23 13:48:57 +00:00
|
|
|
auth::login,
|
2021-07-18 15:37:11 +00:00
|
|
|
chat::send_message,
|
2021-07-18 20:36:23 +00:00
|
|
|
chat::fetch_messages,
|
2021-07-22 17:01:30 +00:00
|
|
|
auth::change_info,
|
2021-07-22 18:23:59 +00:00
|
|
|
auth::check_token,
|
2021-07-23 11:55:24 +00:00
|
|
|
auth::logout,
|
|
|
|
auth::moderation_actions
|
2021-07-18 00:32:57 +00:00
|
|
|
],
|
2021-07-17 11:57:40 +00:00
|
|
|
)
|
2021-07-18 17:16:00 +00:00
|
|
|
.mount("/", StaticFiles::from("frontend"))
|
2021-07-17 11:57:40 +00:00
|
|
|
.attach(cors_fairing)
|
2021-07-18 00:32:57 +00:00
|
|
|
.launch();
|
2021-07-16 14:55:07 +00:00
|
|
|
}
|