Docs.rs comments

Comments for generating the docs with cargo doc
This commit is contained in:
2026-05-09 23:00:15 +02:00
parent 8ddfe2ba14
commit b87a6ff297
19 changed files with 1447 additions and 15 deletions

View File

@@ -1,11 +1,37 @@
/// Environment configuration for the application.
///
/// Loads required configuration from environment variables at startup.
/// All variables must be present or the application will panic.
///
/// # Fields
/// - `db_url`: PostgreSQL database connection URL.
/// - `token_secret`: Secret key used to sign and verify JWT tokens.
/// - `origin`: Frontend origin URL for CORS policy.
///
/// # Required Environment Variables
/// - `DATABASE_URL`: PostgreSQL connection string (e.g., `postgresql://user:pass@localhost/dbname`)
/// - `TOKEN_SECRET`: Secret key for JWT token signing (use a strong random string in production)
/// - `ORIGIN`: Frontend URL for CORS (e.g., `http://localhost:8080`)
#[derive(Debug, Clone)]
pub struct Env {
/// PostgreSQL database connection URL
pub db_url: String,
/// Secret key used to sign and verify JWT tokens
pub token_secret: String,
/// Frontend origin URL for CORS policy
pub origin: String,
}
impl Env {
/// Loads environment configuration from system environment variables.
///
/// Panics if any required variable is missing.
///
/// # Example
/// ```ignore
/// let env = Env::load();
/// // Environment must have DATABASE_URL, TOKEN_SECRET, and ORIGIN set
/// ```
pub fn load() -> Env {
let db_url = std::env::var("DATABASE_URL").expect("DATABASE_URL must be set");
let token_secret = std::env::var("TOKEN_SECRET").expect("TOKEN_SECRET must be set");