nomadro/apps/ebook/backend/app/features.py
eric d93a355fd5 Migrate navmini/ebook/nomadweb into apps/ as same-origin portal subpaths.
Shield external portal jumps (keep EXTERNAL_* for later), serve /nav from static build, and proxy /book + /community to vertical Next apps with Caddy notes.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-28 03:30:34 -05:00

27 lines
703 B
Python

"""Feature flags for the backend — reads content/features.json."""
import json
from functools import lru_cache
from pathlib import Path
FEATURES_PATH = Path(__file__).resolve().parent.parent.parent / "content" / "features.json"
@lru_cache
def get_features() -> dict:
if not FEATURES_PATH.exists():
return {}
with open(FEATURES_PATH, encoding="utf-8") as f:
return json.load(f)
def is_enabled(path: str) -> bool:
"""Check a dot-separated feature path, e.g. 'payment.crypto.enabled'."""
obj = get_features()
for key in path.split("."):
if isinstance(obj, dict):
obj = obj.get(key)
else:
return False
return bool(obj)