summaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
authormrw1593 <botahamec@outlook.com>2023-06-30 19:27:33 -0400
committermrw1593 <botahamec@outlook.com>2023-06-30 19:27:33 -0400
commit55cfb8187cb814e17a2a99d02bfd9296fc01dcc2 (patch)
treec5f7ed60c8a814addd60b1cfb843fb9a107f1458 /src/main.rs
parent9058b01d6c0e3d1e9e485a537258a312ccfc841c (diff)
Added config file
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/main.rs b/src/main.rs
index da740be..e946161 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -5,6 +5,7 @@ use actix_web::middleware::{ErrorHandlerResponse, ErrorHandlers, Logger, Normali
use actix_web::web::Data;
use actix_web::{dev, App, HttpServer};
+use bpaf::Bpaf;
use exun::*;
mod api;
@@ -44,12 +45,28 @@ async fn delete_expired_tokens(db: MySqlPool) {
}
}
+#[derive(Debug, Clone, Bpaf)]
+#[bpaf(options, version)]
+struct Opts {
+ /// The environment that the server is running in. Must be one of: local,
+ /// dev, staging, prod.
+ #[bpaf(
+ env("LOCKDAGGER_ENVIRONMENT"),
+ fallback(config::Environment::Local),
+ display_fallback
+ )]
+ env: config::Environment,
+}
+
#[actix_web::main]
async fn main() -> Result<(), RawUnexpected> {
// load the environment file, but only in debug mode
#[cfg(debug_assertions)]
dotenv::dotenv()?;
+ let args = opts().run();
+ config::set_environment(args.env);
+
// initialize the database
let db_url = secrets::database_url()?;
let sql_pool = db::initialize(&db_url).await?;