Migrate to MongoDB

This commit is contained in:
Jai A
2020-05-28 13:28:58 -07:00
parent 14579a9320
commit b75a4667c2
16 changed files with 44 additions and 2429 deletions

View File

@@ -2,19 +2,25 @@
extern crate serde_json;
#[macro_use]
extern crate diesel;
extern crate bson;
#[macro_use]
extern crate log;
use actix_files as fs;
use actix_web::{web, App, HttpServer};
use handlebars::*;
use actix_web::middleware::Logger;
use env_logger::Env;
mod database;
mod helpers;
mod routes;
mod schema;
#[actix_rt::main]
async fn main() -> std::io::Result<()> {
env_logger::from_env(Env::default().default_filter_or("info")).init();
//Handlebars
let mut handlebars = Handlebars::new();
@@ -26,13 +32,17 @@ async fn main() -> std::io::Result<()> {
let handlebars_ref = web::Data::new(handlebars);
let database = database::connect();
routes::index_mods(database).await;
let client = database::connect().await.unwrap();
routes::index_mods(client.clone()).await;
info!("Starting Actix HTTP server!");
//Init App
HttpServer::new(move || {
App::new()
.wrap(Logger::default())
.wrap(Logger::new("%a %{User-Agent}i"))
.app_data(handlebars_ref.clone())
.app_data(client.clone())
.service(fs::Files::new("/static", "./static").show_files_listing())
.service(routes::index_get)
.service(routes::search_post)