Add a dev mode configuration flag
This commit is contained in:
parent
c3cd7c2796
commit
13779d5a74
3 changed files with 10 additions and 1 deletions
|
|
@ -1,6 +1,7 @@
|
|||
{
|
||||
"host": "0.0.0.0",
|
||||
"port": 8080,
|
||||
"dev_mode": false,
|
||||
"logging": {
|
||||
"level": "info"
|
||||
}
|
||||
|
|
|
|||
0
src/api/__init__.py
Normal file
0
src/api/__init__.py
Normal file
|
|
@ -1,7 +1,6 @@
|
|||
import json
|
||||
from dataclasses import dataclass
|
||||
from typing import Any
|
||||
|
||||
from .logging import Logging
|
||||
from .email import Email
|
||||
from .auth import Auth
|
||||
|
|
@ -13,6 +12,7 @@ from .parse import parse_nested_config
|
|||
class Config:
|
||||
host: str
|
||||
port: int | None
|
||||
dev_mode: bool
|
||||
logging: Logging
|
||||
email: Email
|
||||
database: Database
|
||||
|
|
@ -25,9 +25,17 @@ class Config:
|
|||
db_config = parse_nested_config(config, 'database', Database.from_dict)
|
||||
auth_config = parse_nested_config(config, 'auth', Auth.from_dict)
|
||||
|
||||
mode = config.get('dev_mode')
|
||||
|
||||
if mode != True: # noqa: E712
|
||||
# Explicitly checking for True and falling back to false for anything else. Only explicitly setting
|
||||
# dev_mode to true will run in dev mode
|
||||
mode = False
|
||||
|
||||
return Config(
|
||||
host=config.get('host', '0.0.0.0'),
|
||||
port=config.get('port'),
|
||||
dev_mode=mode,
|
||||
email=email_config,
|
||||
logging=log_config,
|
||||
database=db_config,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue