Files
2025-03-22 17:11:46 +01:00

40 lines
1.4 KiB
Python

"""
Configuration module for the Flask application.
"""
import os
from typing import Any, Dict, List
from dataclasses import dataclass, field
def get_cors_origins() -> List[str]:
"""Get CORS origins from environment variable."""
return os.environ.get('CORS_ORIGINS', '*').split(',')
@dataclass
class Config:
"""Base configuration class."""
DEBUG: bool = os.environ.get('DEBUG', 'False').lower() == 'true'
TESTING: bool = os.environ.get('TESTING', 'False').lower() == 'true'
PORT: int = int(os.environ.get('PORT', 8080)) # Changed default from 5000 to 8080
# API credentials
API_USERNAME: str = os.environ.get('API_USERNAME', 'admin')
API_PASSWORD: str = os.environ.get('API_PASSWORD', 'password')
# API keys for Simbrella to FirstBank API
SIMBRELLA_APP_ID: str = os.environ.get('SIMBRELLA_APP_ID', '')
SIMBRELLA_API_KEY: str = os.environ.get('SIMBRELLA_API_KEY', '')
# Database configuration
DATABASE_URI: str = os.environ.get('DATABASE_URI', 'sqlite:///app.db')
# Logging configuration
LOG_LEVEL: str = os.environ.get('LOG_LEVEL', 'INFO')
# CORS settings
CORS_ORIGINS: List[str] = field(default_factory=get_cors_origins)
@classmethod
def to_dict(cls) -> Dict[str, Any]:
"""Convert config to dictionary for Flask."""
return {k: v for k, v in cls.__dict__.items()
if not k.startswith('__') and not callable(v)}