feat(api): load config using shared helpers
- add django settings module documentation - use default for previously required fields BREAKING CHANGE: The API command line interface require the configuration file to be present. The default configuration file path is `/etc/airtime/airtime.conf`
This commit is contained in:
parent
9af717ef7f
commit
2dcc654b70
12 changed files with 119 additions and 146 deletions
46
api/libretime_api/settings/__init__.py
Normal file
46
api/libretime_api/settings/__init__.py
Normal file
|
@ -0,0 +1,46 @@
|
|||
# pylint: disable=unused-import
|
||||
from os import getenv
|
||||
|
||||
from ._internal import (
|
||||
AUTH_PASSWORD_VALIDATORS,
|
||||
AUTH_USER_MODEL,
|
||||
DEBUG,
|
||||
INSTALLED_APPS,
|
||||
MIDDLEWARE,
|
||||
REST_FRAMEWORK,
|
||||
ROOT_URLCONF,
|
||||
TEMPLATES,
|
||||
TEST_RUNNER,
|
||||
WSGI_APPLICATION,
|
||||
setup_logger,
|
||||
)
|
||||
from ._schema import Config
|
||||
|
||||
API_VERSION = "2.0.0"
|
||||
|
||||
LIBRETIME_LOG_FILEPATH = getenv("LIBRETIME_LOG_FILEPATH")
|
||||
LIBRETIME_CONFIG_FILEPATH = getenv("LIBRETIME_CONFIG_FILEPATH")
|
||||
|
||||
CONFIG = Config(filepath=LIBRETIME_CONFIG_FILEPATH)
|
||||
|
||||
SECRET_KEY = CONFIG.general.api_key
|
||||
ALLOWED_HOSTS = ["*"]
|
||||
|
||||
DATABASES = {
|
||||
"default": {
|
||||
"ENGINE": "django.db.backends.postgresql",
|
||||
"HOST": CONFIG.database.host,
|
||||
"PORT": CONFIG.database.port,
|
||||
"NAME": CONFIG.database.name,
|
||||
"USER": CONFIG.database.user,
|
||||
"PASSWORD": CONFIG.database.password,
|
||||
}
|
||||
}
|
||||
|
||||
LANGUAGE_CODE = "en-us"
|
||||
TIME_ZONE = "UTC"
|
||||
USE_I18N = True
|
||||
USE_L10N = True
|
||||
USE_TZ = True
|
||||
|
||||
LOGGING = setup_logger(LIBRETIME_LOG_FILEPATH)
|
Loading…
Add table
Add a link
Reference in a new issue