feat(api): split api into multiple apps (#1626)
Fixes #1622 - split the api into 4 apps: core, history, schedule, storage - exploded the settings into testing/prod
This commit is contained in:
parent
87d2da9d84
commit
fce988aef1
120 changed files with 1499 additions and 1078 deletions
|
@ -1,13 +1,18 @@
|
|||
from os import getenv
|
||||
from typing import Optional
|
||||
|
||||
API_VERSION = "2.0.0"
|
||||
|
||||
# SECURITY WARNING: don't run with debug turned on in production!
|
||||
DEBUG = getenv("LIBRETIME_DEBUG")
|
||||
DEBUG = getenv("LIBRETIME_DEBUG", "false").lower() == "true"
|
||||
|
||||
# Application definition
|
||||
|
||||
INSTALLED_APPS = [
|
||||
"libretime_api.apps.LibreTimeAPIConfig",
|
||||
"libretime_api.core",
|
||||
"libretime_api.history",
|
||||
"libretime_api.storage",
|
||||
"libretime_api.schedule",
|
||||
"django.contrib.auth",
|
||||
"django.contrib.contenttypes",
|
||||
"django.contrib.sessions",
|
||||
|
@ -48,8 +53,19 @@ TEMPLATES = [
|
|||
|
||||
WSGI_APPLICATION = "libretime_api.wsgi.application"
|
||||
|
||||
# Static files (CSS, JavaScript, Images)
|
||||
# https://docs.djangoproject.com/en/3.2/howto/static-files/
|
||||
|
||||
STATIC_URL = "/api/v2/static/"
|
||||
|
||||
# Default primary key field type
|
||||
# https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field
|
||||
|
||||
DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
|
||||
|
||||
|
||||
# Password validation
|
||||
# https://docs.djangoproject.com/en/3.0/ref/settings/#auth-password-validators
|
||||
# https://docs.djangoproject.com/en/3.2/ref/settings/#auth-password-validators
|
||||
|
||||
AUTH_PASSWORD_VALIDATORS = [
|
||||
{
|
||||
|
@ -66,39 +82,11 @@ AUTH_PASSWORD_VALIDATORS = [
|
|||
},
|
||||
]
|
||||
|
||||
# Rest Framework settings
|
||||
# https://www.django-rest-framework.org/api-guide/settings/
|
||||
|
||||
renderer_classes = ["rest_framework.renderers.JSONRenderer"]
|
||||
if DEBUG:
|
||||
renderer_classes += ["rest_framework.renderers.BrowsableAPIRenderer"]
|
||||
|
||||
REST_FRAMEWORK = {
|
||||
"DEFAULT_RENDERER_CLASSES": renderer_classes,
|
||||
"DEFAULT_AUTHENTICATION_CLASSES": (
|
||||
"rest_framework.authentication.SessionAuthentication",
|
||||
"rest_framework.authentication.BasicAuthentication",
|
||||
),
|
||||
"DEFAULT_PERMISSION_CLASSES": [
|
||||
"libretime_api.permissions.IsSystemTokenOrUser",
|
||||
],
|
||||
"DEFAULT_FILTER_BACKENDS": [
|
||||
"django_filters.rest_framework.DjangoFilterBackend",
|
||||
],
|
||||
"DEFAULT_SCHEMA_CLASS": "drf_spectacular.openapi.AutoSchema",
|
||||
"URL_FIELD_NAME": "item_url",
|
||||
}
|
||||
|
||||
# Static files (CSS, JavaScript, Images)
|
||||
# https://docs.djangoproject.com/en/3.0/howto/static-files/
|
||||
|
||||
STATIC_URL = "/api/v2/static/"
|
||||
|
||||
AUTH_USER_MODEL = "libretime_api.User"
|
||||
|
||||
TEST_RUNNER = "libretime_api.tests.runners.ManagedModelTestRunner"
|
||||
|
||||
# Logging
|
||||
# https://docs.djangoproject.com/en/3.2/topics/logging/#configuring-logging
|
||||
|
||||
|
||||
def setup_logger(log_filepath: Optional[str]):
|
||||
logging_handlers = {
|
||||
"console": {
|
||||
|
@ -143,3 +131,41 @@ def setup_logger(log_filepath: Optional[str]):
|
|||
},
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
# Rest Framework
|
||||
# https://www.django-rest-framework.org/api-guide/settings/
|
||||
|
||||
renderer_classes = ["rest_framework.renderers.JSONRenderer"]
|
||||
if DEBUG:
|
||||
renderer_classes += ["rest_framework.renderers.BrowsableAPIRenderer"]
|
||||
|
||||
REST_FRAMEWORK = {
|
||||
"DEFAULT_RENDERER_CLASSES": renderer_classes,
|
||||
"DEFAULT_AUTHENTICATION_CLASSES": (
|
||||
"rest_framework.authentication.SessionAuthentication",
|
||||
"rest_framework.authentication.BasicAuthentication",
|
||||
),
|
||||
"DEFAULT_PERMISSION_CLASSES": [
|
||||
"libretime_api.permissions.IsSystemTokenOrUser",
|
||||
],
|
||||
"DEFAULT_FILTER_BACKENDS": [
|
||||
"django_filters.rest_framework.DjangoFilterBackend",
|
||||
],
|
||||
"DEFAULT_SCHEMA_CLASS": "drf_spectacular.openapi.AutoSchema",
|
||||
"URL_FIELD_NAME": "item_url",
|
||||
}
|
||||
|
||||
# Auth
|
||||
# https://docs.djangoproject.com/en/3.2/topics/auth/customizing/#substituting-a-custom-user-model
|
||||
|
||||
AUTH_USER_MODEL = "core.User"
|
||||
|
||||
# Spectacular
|
||||
# https://drf-spectacular.readthedocs.io/en/latest/settings.html
|
||||
|
||||
SPECTACULAR_SETTINGS = {
|
||||
"TITLE": "LibreTime API",
|
||||
"DESCRIPTION": "Radio Broadcast & Automation Platform",
|
||||
"VERSION": API_VERSION,
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue