"""Config for application"""

from functools import lru_cache

from betterconf import betterconf, field
from betterconf.caster import to_bool, to_int, to_list


@betterconf
class AppConfig:
    # pylint: disable=R0903
    """
    Class of configuration the application
    """

    app_debug: bool = field("APP_DEBUG", default=False, caster=to_bool)
    app_origin: list = field("APP_ORIGIN", default=[], caster=to_list)
    app_host: str = field("APP_HOST", default="0.0.0.0")
    app_port: int = field("APP_PORT", default=8000, caster=to_int)
    app_public_url: str = field("APP_PUBLIC_URL", default="http://127.0.0.1:8000")

    sentry_dns: str = field("SENTRY_DNS", default="")
    log_level: str = field("LOG_LEVEL", "INFO")

    db_uri: str = field("DB_URI", "postgresql+asyncpg://svcuser:svcpass@localhost:5432/svc")
    db_pass_salt: str = field("DB_PASS_SALT", "")
    db_search_path: str = field("DB_SEARCH_PATH", "beerds")

    fs_local_mount_dir: str = field("FS_LOCAL_MOUNT_DIR", default="files/")
    fs_s3_bucket: str = field("FS_S3_BUCKET", "")
    fs_s3_access_key_id: str = field("FS_ACCESS_KEY_ID", "")
    fs_s3_access_key: str = field("FS_SECRET_ACCESS_KEY", "")
    fs_s3_endpoint: str = field("FS_S3_ENDPOINT", "")
    fs_dir: str = field("FS_DIR", "beerds")

    admin_secret_key: str = field("ADMIN_SECRET_KEY", default="default")
    admin_login: str = field("ADMIN_LOGIN", default="admin")
    admin_pass: str = field("ADMIN_PASS", default="123456")


@lru_cache
def get_app_config() -> AppConfig:
    # pylint: disable=C0116
    return AppConfig()
