Split graph/import/meta into Django apps, add API v1 with OpenAPI and pytest, and introduce plugin registry with the tags reference plugin on both FE and BE. Co-authored-by: Cursor <cursoragent@cursor.com>
83 lines
2.1 KiB
Python
83 lines
2.1 KiB
Python
import os
|
|
from pathlib import Path
|
|
|
|
BASE_DIR = Path(__file__).resolve().parent.parent
|
|
|
|
SECRET_KEY = os.environ.get(
|
|
'SECRET_KEY',
|
|
'django-insecure-social-graph-dev-key-change-in-production',
|
|
)
|
|
DEBUG = os.environ.get('DEBUG', 'True').lower() in ('1', 'true', 'yes')
|
|
ALLOWED_HOSTS = [
|
|
h.strip() for h in os.environ.get('ALLOWED_HOSTS', '*').split(',') if h.strip()
|
|
]
|
|
|
|
ENABLED_PLUGINS = [
|
|
p.strip()
|
|
for p in os.environ.get('ENABLED_PLUGINS', 'tags').split(',')
|
|
if p.strip()
|
|
]
|
|
|
|
INSTALLED_APPS = [
|
|
'django.contrib.contenttypes',
|
|
'django.contrib.auth',
|
|
'django.contrib.staticfiles',
|
|
'rest_framework',
|
|
'corsheaders',
|
|
'drf_spectacular',
|
|
'core',
|
|
'contacts',
|
|
'graph',
|
|
'import_export',
|
|
'plugins',
|
|
'plugins_tags',
|
|
]
|
|
|
|
MIDDLEWARE = [
|
|
'corsheaders.middleware.CorsMiddleware',
|
|
'django.middleware.common.CommonMiddleware',
|
|
]
|
|
|
|
ROOT_URLCONF = 'config.urls'
|
|
|
|
DATABASES = {
|
|
'default': {
|
|
'ENGINE': 'django.db.backends.sqlite3',
|
|
'NAME': os.environ.get('DATABASE_PATH', str(BASE_DIR / 'db.sqlite3')),
|
|
}
|
|
}
|
|
|
|
STATIC_URL = '/static/'
|
|
STATIC_ROOT = BASE_DIR / 'staticfiles'
|
|
|
|
REST_FRAMEWORK = {
|
|
'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.PageNumberPagination',
|
|
'PAGE_SIZE': 100,
|
|
'DEFAULT_SCHEMA_CLASS': 'drf_spectacular.openapi.AutoSchema',
|
|
}
|
|
|
|
SPECTACULAR_SETTINGS = {
|
|
'TITLE': 'Social Graph API',
|
|
'DESCRIPTION': 'API for Social Graph Builder (local-first with optional remote backend)',
|
|
'VERSION': '1.0.0',
|
|
}
|
|
|
|
CORS_ALLOW_ALL_ORIGINS = True
|
|
|
|
DATA_UPLOAD_MAX_MEMORY_SIZE = 20 * 1024 * 1024
|
|
|
|
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
|
|
|
|
# Phase C: optional JWT auth (disabled by default)
|
|
USE_JWT_AUTH = os.environ.get('USE_JWT_AUTH', 'false').lower() in ('1', 'true', 'yes')
|
|
|
|
if USE_JWT_AUTH:
|
|
REST_FRAMEWORK['DEFAULT_AUTHENTICATION_CLASSES'] = [
|
|
'rest_framework_simplejwt.authentication.JWTAuthentication',
|
|
]
|
|
REST_FRAMEWORK['DEFAULT_PERMISSION_CLASSES'] = [
|
|
'rest_framework.permissions.IsAuthenticated',
|
|
]
|
|
|
|
DEFAULT_WORKSPACE_ID = os.environ.get('DEFAULT_WORKSPACE_ID', 'personal')
|