diff options
| author | mrw1593 <botahamec@outlook.com> | 2023-06-30 19:27:33 -0400 |
|---|---|---|
| committer | mrw1593 <botahamec@outlook.com> | 2023-06-30 19:27:33 -0400 |
| commit | 55cfb8187cb814e17a2a99d02bfd9296fc01dcc2 (patch) | |
| tree | c5f7ed60c8a814addd60b1cfb843fb9a107f1458 /src/main.rs | |
| parent | 9058b01d6c0e3d1e9e485a537258a312ccfc841c (diff) | |
Added config file
Diffstat (limited to 'src/main.rs')
| -rw-r--r-- | src/main.rs | 17 |
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?; |
