refactor: clean up __init__ file following some Flask conventions

Flask extensions are loaded in a way that makes them easily reusable by blueprints.
In this commit we are also adding `environs` to manage .env and settings:
breaking changes!

- FLASK_APP=lnbits.app
- LNBITS_ALLOWED_USERS needs to be empty now to allow all users (NOT "all")
This commit is contained in:
Eneko Illarramendi
2020-09-06 21:06:01 -03:00
committed by fiatjaf
parent ffa3c3f6a6
commit 1bc5e144d3
13 changed files with 226 additions and 138 deletions
+7 -3
View File
@@ -4,7 +4,7 @@ import shortuuid # type: ignore
from typing import List, NamedTuple, Optional
from .settings import LNBITS_PATH
from .settings import LNBITS_DISABLED_EXTENSIONS, LNBITS_PATH
class Extension(NamedTuple):
@@ -17,8 +17,8 @@ class Extension(NamedTuple):
class ExtensionManager:
def __init__(self, *, disabled: list = []):
self._disabled = disabled
def __init__(self):
self._disabled: List[str] = LNBITS_DISABLED_EXTENSIONS
self._extension_folders: List[str] = [x[1] for x in os.walk(os.path.join(LNBITS_PATH, "extensions"))][0]
@property
@@ -48,5 +48,9 @@ class ExtensionManager:
return output
def get_valid_extensions() -> List[Extension]:
return [extension for extension in ExtensionManager().extensions if extension.is_valid]
def urlsafe_short_hash() -> str:
return shortuuid.uuid()