Skip to content

Commit

Permalink
Update clippy and env example.
Browse files Browse the repository at this point in the history
  • Loading branch information
kirkbyers committed Sep 22, 2024
1 parent 03ff17a commit 6227ae5
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 9 deletions.
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
DB_FILE_PATH=./.data/db.sqlite
APPLICATION_PORT=8000
5 changes: 1 addition & 4 deletions src/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@ use crate::models::{
/// # Error
/// libsql::Error
pub async fn start_db() -> Result<Database, Error> {
let db_url = match env::var("DB_URL") {
Ok(url) => url,
Err(_) => String::new(),
};
let db_url = env::var("DB_URL").unwrap_or_default();
let db_file_path = match env::var("DB_FILE_PATH") {
Ok(file_path) => file_path,
Err(_) => {
Expand Down
7 changes: 2 additions & 5 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
use actix_web::rt;
use dotenvy::dotenv;
use std::{env::var, net::TcpListener};
use std::{env, net::TcpListener};

use zero2prod::{jobs::process::process_job, startup::run};

#[actix_web::main]
async fn main() -> Result<(), std::io::Error> {
dotenv().expect("No .env file found");

let application_port = match var("APPLICATION_PORT") {
Ok(s) => s,
Err(_) => "8000".to_string(),
};
let application_port = env::var("APPLICATION_PORT").unwrap_or("8000".to_string());

let address = format!("0.0.0.0:{}", application_port);
let listener = TcpListener::bind(address)?;
Expand Down

0 comments on commit 6227ae5

Please sign in to comment.