rustfmt
This commit is contained in:
parent
cbe276fc06
commit
0a1631e66c
13 changed files with 766 additions and 381 deletions
|
|
@ -1,24 +1,26 @@
|
|||
use actix_files as fs;
|
||||
use actix_web::{web, middleware, App, HttpServer};
|
||||
use actix_web::{middleware, web, App, HttpServer};
|
||||
use chrono::prelude::*;
|
||||
use clap::Parser;
|
||||
use log::error;
|
||||
|
||||
use data::db;
|
||||
|
||||
mod config;
|
||||
mod consts;
|
||||
mod utils;
|
||||
mod data;
|
||||
mod email;
|
||||
mod hash;
|
||||
mod model;
|
||||
mod user;
|
||||
mod email;
|
||||
mod config;
|
||||
mod services;
|
||||
mod user;
|
||||
mod utils;
|
||||
|
||||
#[actix_web::main]
|
||||
async fn main() -> std::io::Result<()> {
|
||||
if process_args() { return Ok(()) }
|
||||
if process_args() {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
std::env::set_var("RUST_LOG", "info,actix_web=info");
|
||||
env_logger::init();
|
||||
|
|
@ -32,27 +34,26 @@ async fn main() -> std::io::Result<()> {
|
|||
|
||||
let db_connection = web::Data::new(db::Connection::new().unwrap());
|
||||
|
||||
let server =
|
||||
HttpServer::new(move || {
|
||||
App::new()
|
||||
.wrap(middleware::Logger::default())
|
||||
.wrap(middleware::Compress::default())
|
||||
.app_data(db_connection.clone())
|
||||
.app_data(config.clone())
|
||||
.service(services::home_page)
|
||||
.service(services::sign_up_get)
|
||||
.service(services::sign_up_post)
|
||||
.service(services::sign_up_check_email)
|
||||
.service(services::sign_up_validation)
|
||||
.service(services::sign_in_get)
|
||||
.service(services::sign_in_post)
|
||||
.service(services::sign_out)
|
||||
.service(services::view_recipe)
|
||||
.service(services::edit_recipe)
|
||||
.service(fs::Files::new("/static", "static"))
|
||||
.default_service(web::to(services::not_found))
|
||||
});
|
||||
//.workers(1);
|
||||
let server = HttpServer::new(move || {
|
||||
App::new()
|
||||
.wrap(middleware::Logger::default())
|
||||
.wrap(middleware::Compress::default())
|
||||
.app_data(db_connection.clone())
|
||||
.app_data(config.clone())
|
||||
.service(services::home_page)
|
||||
.service(services::sign_up_get)
|
||||
.service(services::sign_up_post)
|
||||
.service(services::sign_up_check_email)
|
||||
.service(services::sign_up_validation)
|
||||
.service(services::sign_in_get)
|
||||
.service(services::sign_in_post)
|
||||
.service(services::sign_out)
|
||||
.service(services::view_recipe)
|
||||
.service(services::edit_recipe)
|
||||
.service(fs::Files::new("/static", "static"))
|
||||
.default_service(web::to(services::not_found))
|
||||
});
|
||||
//.workers(1);
|
||||
|
||||
server.bind(&format!("0.0.0.0:{}", port))?.run().await
|
||||
}
|
||||
|
|
@ -60,7 +61,7 @@ async fn main() -> std::io::Result<()> {
|
|||
#[derive(Parser, Debug)]
|
||||
struct Args {
|
||||
#[arg(long)]
|
||||
dbtest: bool
|
||||
dbtest: bool,
|
||||
}
|
||||
|
||||
fn process_args() -> bool {
|
||||
|
|
@ -73,11 +74,15 @@ fn process_args() -> bool {
|
|||
eprintln!("{}", error);
|
||||
}
|
||||
// Set the creation datetime to 'now'.
|
||||
con.execute_sql("UPDATE [User] SET [creation_datetime] = ?1 WHERE [email] = 'paul@test.org'", [Utc::now()]).unwrap();
|
||||
},
|
||||
con.execute_sql(
|
||||
"UPDATE [User] SET [creation_datetime] = ?1 WHERE [email] = 'paul@test.org'",
|
||||
[Utc::now()],
|
||||
)
|
||||
.unwrap();
|
||||
}
|
||||
Err(error) => {
|
||||
eprintln!("{}", error);
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue