Added frontend. Working on user management
This commit is contained in:
85
src/file-processor/app/config/settings.py
Normal file
85
src/file-processor/app/config/settings.py
Normal file
@@ -0,0 +1,85 @@
|
||||
"""
|
||||
Application configuration settings.
|
||||
|
||||
This module handles environment variables and application configuration
|
||||
using simple os.getenv() approach without external validation libraries.
|
||||
"""
|
||||
|
||||
import os
|
||||
from typing import Optional
|
||||
|
||||
|
||||
def get_mongodb_url() -> str:
|
||||
"""
|
||||
Get MongoDB connection URL from environment variables.
|
||||
|
||||
Returns:
|
||||
str: MongoDB connection URL
|
||||
|
||||
Returns default localhost URL if MONGODB_URL not set.
|
||||
"""
|
||||
return os.getenv("MONGODB_URL", "mongodb://localhost:27017")
|
||||
|
||||
|
||||
def get_mongodb_database_name() -> str:
|
||||
"""
|
||||
Get MongoDB database name from environment variables.
|
||||
|
||||
Returns:
|
||||
str: MongoDB database name
|
||||
"""
|
||||
return os.getenv("MONGODB_DATABASE", "mydocmanager")
|
||||
|
||||
|
||||
def get_jwt_secret_key() -> str:
|
||||
"""
|
||||
Get JWT secret key from environment variables.
|
||||
|
||||
Returns:
|
||||
str: JWT secret key
|
||||
|
||||
Raises:
|
||||
ValueError: If JWT_SECRET is not set in production
|
||||
"""
|
||||
secret = os.getenv("JWT_SECRET")
|
||||
if not secret:
|
||||
# For development, provide a default key with warning
|
||||
if os.getenv("ENVIRONMENT", "development") == "development":
|
||||
print("WARNING: Using default JWT secret key for development")
|
||||
return "dev-secret-key-change-in-production"
|
||||
else:
|
||||
raise ValueError("JWT_SECRET environment variable must be set in production")
|
||||
return secret
|
||||
|
||||
|
||||
def get_jwt_algorithm() -> str:
|
||||
"""
|
||||
Get JWT algorithm from environment variables.
|
||||
|
||||
Returns:
|
||||
str: JWT algorithm (default: HS256)
|
||||
"""
|
||||
return os.getenv("JWT_ALGORITHM", "HS256")
|
||||
|
||||
|
||||
def get_jwt_expire_hours() -> int:
|
||||
"""
|
||||
Get JWT token expiration time in hours from environment variables.
|
||||
|
||||
Returns:
|
||||
int: JWT expiration time in hours (default: 24)
|
||||
"""
|
||||
try:
|
||||
return int(os.getenv("JWT_EXPIRE_HOURS", "24"))
|
||||
except ValueError:
|
||||
return 24
|
||||
|
||||
|
||||
def is_development_environment() -> bool:
|
||||
"""
|
||||
Check if running in development environment.
|
||||
|
||||
Returns:
|
||||
bool: True if development environment
|
||||
"""
|
||||
return os.getenv("ENVIRONMENT", "development").lower() == "development"
|
||||
Reference in New Issue
Block a user