Implementace sluzby workdays
- endpointy /workdays/add, is-workday, next, previous, between - /holidays, /countries (filtr eu), /markets, /health, /version - data svatku z knihovny holidays 0.109, vsech 27 zemi EU vcetne regionu - vychozi zeme CZ a cestina pres DEFAULT_COUNTRY a DEFAULT_LANGUAGE - vlastni vikend, extra_holidays a extra_workdays v requestu - testy logiky, API a testy proti realnym kalendarum - CLAUDE.md s povinnym overenim vysledku proti realite - dokumentace ve slozce documentation - .gitignore: vyjimka pro app/lib
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
"""Runtime configuration read from environment variables.
|
||||
|
||||
AppFactory injects variables through the generated runtime .env file, so every
|
||||
option below has a safe default and the service starts without any variable set.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
from dataclasses import dataclass, field
|
||||
from functools import lru_cache
|
||||
|
||||
|
||||
def _str(name: str, default: str) -> str:
|
||||
raw = os.getenv(name)
|
||||
if raw is None or raw.strip() == "":
|
||||
return default
|
||||
return raw.strip()
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class Settings:
|
||||
app_name: str = field(default_factory=lambda: _str("APP_NAME", "workdays"))
|
||||
app_version: str = field(default_factory=lambda: _str("APP_VERSION", "1.0.0"))
|
||||
root_path: str = field(
|
||||
default_factory=lambda: os.getenv("ROOT_PATH") or os.getenv("BASE_PATH") or ""
|
||||
)
|
||||
log_level: str = field(default_factory=lambda: _str("LOG_LEVEL", "INFO").upper())
|
||||
|
||||
# Calendar used when the request names neither a country nor a market.
|
||||
default_country: str = field(default_factory=lambda: _str("DEFAULT_COUNTRY", "CZ").upper())
|
||||
# Preferred language of holiday names. A country that does not support it
|
||||
# falls back to its own default language.
|
||||
default_language: str = field(default_factory=lambda: _str("DEFAULT_LANGUAGE", "cs"))
|
||||
|
||||
|
||||
@lru_cache(maxsize=1)
|
||||
def get_settings() -> Settings:
|
||||
return Settings()
|
||||
Reference in New Issue
Block a user