and now we have .env file support
This commit is contained in:
parent
f65d564c9c
commit
d00f530ed7
1
.env.sample
Normal file
1
.env.sample
Normal file
|
@ -0,0 +1 @@
|
|||
DATABASE_URL=sqlite:db.sqlite
|
7
Cargo.lock
generated
7
Cargo.lock
generated
|
@ -389,6 +389,7 @@ version = "0.1.0"
|
|||
dependencies = [
|
||||
"anyhow",
|
||||
"async-std",
|
||||
"dotenv",
|
||||
"html-escape",
|
||||
"rocket",
|
||||
"sqlx",
|
||||
|
@ -534,6 +535,12 @@ dependencies = [
|
|||
"subtle",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dotenv"
|
||||
version = "0.15.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "77c90badedccf4105eca100756a0b1289e191f6fcbdadd3cee1d2f614f97da8f"
|
||||
|
||||
[[package]]
|
||||
name = "dotenvy"
|
||||
version = "0.15.7"
|
||||
|
|
|
@ -8,6 +8,7 @@ edition = "2021"
|
|||
[dependencies]
|
||||
anyhow = "1.0.82"
|
||||
async-std = { version = "1.12.0", features = ["attributes"] }
|
||||
dotenv = "0.15.0"
|
||||
html-escape = "0.2.13"
|
||||
rocket = "0.5.0"
|
||||
sqlx = { version = "0.7", features = ["runtime-async-std", "sqlite", "migrate"] }
|
||||
|
|
|
@ -112,6 +112,7 @@ async fn add(
|
|||
|
||||
#[rocket::launch]
|
||||
async fn rocket() -> _ {
|
||||
dotenv::dotenv().ok();
|
||||
let db_url = env::var("DATABASE_URL").expect("DATABASE_URL is required");
|
||||
let pool = SqlitePool::connect(&db_url)
|
||||
.await
|
||||
|
|
Loading…
Reference in a new issue