Initial commit

This commit is contained in:
Mats Rauhala committed 2026-10-05 22:39:55 +03:00
commit b9ce73b51d
19 files changed
+2112

No files matched your search

+25
View File
@@ -0,0 +1,25 @@
use std::env;
use secrecy::SecretString;
use thiserror::Error;
pub struct Config {
pub server_secret: SecretString,
}
#[derive(Error, Debug)]
pub enum ConfigError {
#[error("Missing SERVER_SECRET")]
MissingServerSecret,
#[error("Unknown error: #{0}")]
Unknown(anyhow::Error),
}
impl Config {
pub fn new() -> Result<Self, ConfigError> {
dotenvy::dotenv().map_err(|err| ConfigError::Unknown(err.into()))?;
let server_secret = env::var("SERVER_SECRET").map(SecretString::from).map_err(|_| ConfigError::MissingServerSecret)?;
Ok(Self{server_secret})
}
}