Updated main

This commit is contained in:
Joe Bellus 2022-02-10 22:40:04 -05:00
parent d059f5e447
commit b6bceb3ff8
2 changed files with 3 additions and 6 deletions

View File

@ -1,3 +0,0 @@
use std::process::Command;
fn main() {}

View File

@ -1,7 +1,6 @@
use actix_web::{get, web, App, HttpResponse, HttpServer}; use actix_web::{get, web, App, HttpResponse, HttpServer};
use rust_embed::RustEmbed; use rust_embed::RustEmbed;
use sea_orm::{Database, DatabaseConnection}; use sea_orm::{Database, DatabaseConnection};
use sqlx::SqliteConnection;
use tracing::{info, instrument}; use tracing::{info, instrument};
use tracing_subscriber::prelude::*; use tracing_subscriber::prelude::*;
@ -10,9 +9,10 @@ mod auth;
mod entity; mod entity;
mod error; mod error;
// Use Jemalloc only for musl-64 bits platforms
#[cfg(all(target_env = "musl", target_pointer_width = "64"))] #[cfg(all(target_env = "musl", target_pointer_width = "64"))]
#[global_allocator] #[global_allocator]
static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc;
#[derive(Debug)] #[derive(Debug)]
pub struct AppState { pub struct AppState {
pub db: DatabaseConnection, pub db: DatabaseConnection,
@ -69,7 +69,7 @@ async fn dist(path: web::Path<String>) -> HttpResponse {
.body(body) .body(body)
} }
use sqlx::Connection; #[instrument]
async fn setup_database() -> error::Result<DatabaseConnection> { async fn setup_database() -> error::Result<DatabaseConnection> {
let pool = sqlx::SqlitePool::connect("sqlite://data.db").await?; let pool = sqlx::SqlitePool::connect("sqlite://data.db").await?;
sqlx::migrate!("./migrations").run(&pool).await?; sqlx::migrate!("./migrations").run(&pool).await?;