diff --git a/core/__init__.py b/core/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/core/asgi.py b/core/asgi.py deleted file mode 100644 index 6fcf569..0000000 --- a/core/asgi.py +++ /dev/null @@ -1,11 +0,0 @@ -"""generated with djinit""" - -import os -import environ -from django.core.asgi import get_asgi_application - -env = environ.Env() -environ.Env.read_env() - -os.environ.setdefault("DJANGO_SETTINGS_MODULE", env("DJANGO_SETTINGS_MODULE", default="core.settings.production")) -application = get_asgi_application() \ No newline at end of file diff --git a/core/settings/__init__.py b/core/settings/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/core/settings/base.py b/core/settings/base.py deleted file mode 100644 index a97c7a2..0000000 --- a/core/settings/base.py +++ /dev/null @@ -1,223 +0,0 @@ -""" -generated with djinit -Common settings shared between development and production environment -""" - -import os -from datetime import timedelta -from pathlib import Path - -import environ - -env = environ.Env() -environ.Env.read_env() - -# Build paths inside the project like this: BASE_DIR / 'subdir'. -BASE_DIR = Path(__file__).resolve().parent.parent.parent - -# Quick-start development settings - unsuitable for production -# See https://docs.djangoproject.com/en/5.2/howto/deployment/checklist/ - - -# Application definition -THIRD_PARTY_APPS = [ - "rest_framework", - "rest_framework_simplejwt", - "rest_framework_simplejwt.token_blacklist", - "corsheaders", - "drf_spectacular", - "django_tailwind_cli", - "django_htmx", -] - -USER_DEFINED_APPS = [ - "apps.apps.apps.AppsConfig", -] - -BUILT_IN_APPS = [ - "django.contrib.admin", - "django.contrib.auth", - "django.contrib.contenttypes", - "django.contrib.sessions", - "django.contrib.messages", - "django.contrib.staticfiles", -] - -INSTALLED_APPS = BUILT_IN_APPS + THIRD_PARTY_APPS + USER_DEFINED_APPS -INSTALLED_APPS.insert(0, "jazzmin") - -MIDDLEWARE = [ - "corsheaders.middleware.CorsMiddleware", - "django.middleware.security.SecurityMiddleware", - "whitenoise.middleware.WhiteNoiseMiddleware", - "django.contrib.sessions.middleware.SessionMiddleware", - "django.middleware.common.CommonMiddleware", - "django.middleware.csrf.CsrfViewMiddleware", - "django.contrib.auth.middleware.AuthenticationMiddleware", - "django.contrib.messages.middleware.MessageMiddleware", - "django.middleware.clickjacking.XFrameOptionsMiddleware", - "django_htmx.middleware.HtmxMiddleware", -] - -ROOT_URLCONF = "core.urls" - -TEMPLATES = [ - { - "BACKEND": "django.template.backends.django.DjangoTemplates", - "DIRS": [], - "APP_DIRS": True, - "OPTIONS": { - "context_processors": [ - "django.template.context_processors.request", - "django.contrib.auth.context_processors.auth", - "django.contrib.messages.context_processors.messages", - ], - }, - }, -] - -WSGI_APPLICATION = "core.wsgi.application" - - -# Password validation -# https://docs.djangoproject.com/en/5.2/ref/settings/#auth-password-validators - -AUTH_PASSWORD_VALIDATORS = [ - { - "NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator", - }, - { - "NAME": "django.contrib.auth.password_validation.MinimumLengthValidator", - }, - { - "NAME": "django.contrib.auth.password_validation.CommonPasswordValidator", - }, - { - "NAME": "django.contrib.auth.password_validation.NumericPasswordValidator", - }, -] - - -# Internationalization -# https://docs.djangoproject.com/en/5.2/topics/i18n/ - -LANGUAGE_CODE = "en-us" -TIME_ZONE = "UTC" -USE_I18N = True -USE_TZ = True - -# Static files and media files -STATIC_URL = "/static/" -STATIC_ROOT = BASE_DIR / "staticfiles" - -MEDIA_URL = "/media/" -MEDIA_ROOT = BASE_DIR / "media" - -STORAGES = { - "default": { - "BACKEND": "django.core.files.storage.FileSystemStorage", - }, - "staticfiles": { - "BACKEND": "whitenoise.storage.CompressedManifestStaticFilesStorage", - }, -} - -DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField" - -# REST Framework Settings -REST_FRAMEWORK = { - "DEFAULT_RENDERER_CLASSES": [ - "rest_framework.renderers.JSONRenderer", - ], - "DEFAULT_PARSER_CLASSES": [ - "rest_framework.parsers.JSONParser", - ], - "DEFAULT_AUTHENTICATION_CLASSES": ( - "rest_framework_simplejwt.authentication.JWTAuthentication", - "rest_framework.authentication.SessionAuthentication", - ), - "DEFAULT_SCHEMA_CLASS": "drf_spectacular.openapi.AutoSchema", - "DEFAULT_PAGINATION_CLASS": "rest_framework.pagination.PageNumberPagination", - "PAGE_SIZE": 20, -} - -# DRF Spectacular settings -SPECTACULAR_SETTINGS = { - "TITLE": "core API", - "DESCRIPTION": "API documentation for core", - "VERSION": "1.0.0", - "SERVE_INCLUDE_SCHEMA": False, - "COMPONENT_SPLIT_REQUEST": True, - "SCHEMA_PATH_PREFIX": "/api/", -} - -# JWT Settings -SIMPLE_JWT = { - "ACCESS_TOKEN_LIFETIME": timedelta(days=1), - "REFRESH_TOKEN_LIFETIME": timedelta(days=3), - "ROTATE_REFRESH_TOKENS": True, - "BLACKLIST_AFTER_ROTATION": True, -} - -# CORS Settings -CORS_ALLOW_METHODS = [ - "DELETE", - "GET", - "OPTIONS", - "PATCH", - "POST", - "PUT", -] - -CORS_ALLOW_HEADERS = [ - "accept", - "accept-encoding", - "authorization", - "content-type", - "dnt", - "origin", - "user-agent", - "x-csrftoken", - "x-requested-with", -] - -CORS_PREFLIGHT_MAX_AGE = 86400 # 24 hours -# Security Settings -SECURE_BROWSER_XSS_FILTER = True -SECURE_CONTENT_TYPE_NOSNIFF = True -X_FRAME_OPTIONS = "DENY" - -# for tailwind -STATICFILES_DIRS = [BASE_DIR / "static/"] -TAILWIND_CLI_VERSION = "2.7.8" -TAILWIND_CLI_USE_DAISY_UI = True -TAILWIND_CLI_CONFIG = { - "theme": { - "extend": { - "colors": { - "primary": "#DC2626", - "secondary": "#EF4444", - "accent": "#FCFECC", - } - } - }, - "daisyui": { - "themes": [ - { - "light": { - "primary": "#DC2626", - "secondary": "#EF4444", - "accent": "#FCFECC", - "neutral": "#1a1a2e", - "base-100": "#ffffff", - "base-200": "#f8fafc", - "base-300": "#e2e8f0", - "info": "#0E4D80", - "success": "#16a34a", - "warning": "#f59e0b", - "error": "#DC2626", - } - } - ] - }, -} \ No newline at end of file diff --git a/core/settings/development.py b/core/settings/development.py deleted file mode 100644 index 742e080..0000000 --- a/core/settings/development.py +++ /dev/null @@ -1,42 +0,0 @@ -"""generated with djinit""" - -from .base import * - -SECRET_KEY = "V+dILoQ9GMX(U)iI^*w-Q%Gb9feyJ=OgzyM9XMR%WpZG!oxlSJ" - -# SECURITY WARNING: don't run with debug turned on in production! -DEBUG = True - -ALLOWED_HOSTS = ["*"] - -# Database -# https://docs.djangoproject.com/en/5.2/ref/settings/#databases - -DATABASES = { - "default": { - "ENGINE": "django.db.backends.sqlite3", - "NAME": BASE_DIR / "db.sqlite3", - "OPTIONS": { - "transaction_mode": "IMMEDIATE", - "timeout": 5, # seconds - "init_command": """ - PRAGMA journal_mode=WAL; - PRAGMA synchronous=NORMAL; - PRAGMA mmap_size = 134217728; - PRAGMA journal_size_limit = 27103364; - PRAGMA cache_size=2000; - """, - }, - } -} - -# Email backend for development -EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend" - -# CORS settings for development -# Allow all origins in development (convenient but not secure) -CORS_ALLOW_ALL_ORIGINS = True -CORS_ALLOW_CREDENTIALS = True - -# Disable HTTPS redirect in development -SECURE_SSL_REDIRECT = False \ No newline at end of file diff --git a/core/settings/production.py b/core/settings/production.py deleted file mode 100644 index a3af9dc..0000000 --- a/core/settings/production.py +++ /dev/null @@ -1,51 +0,0 @@ -"""generated with djinit""" - -from .base import * -import dj_database_url - -DEBUG = False -SECRET_KEY = env('SECRET_KEY') -ALLOWED_HOSTS = env.list('ALLOWED_HOSTS', default=[]) - -# Database -# Using dj_database_url (recommended for production) -DATABASES = { - 'default': env.db('DATABASE_URL') -} - -# CORS settings for production -# Filter out empty strings from FRONTEND_URL -CORS_ALLOWED_ORIGINS = env.list('FRONTEND_URL', default=[]) -CORS_ALLOW_CREDENTIALS = True - -# Additional CORS security for production -CORS_ALLOW_PRIVATE_NETWORK = False - -# Email settings -EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' -EMAIL_HOST = env('EMAIL_HOST', default="smtp.gmail.com") -EMAIL_PORT = env.int('EMAIL_PORT', default=587) -EMAIL_USE_TLS = env.bool('EMAIL_USE_TLS', default=True) -EMAIL_HOST_USER = env('EMAIL_HOST_USER', default="") -EMAIL_HOST_PASSWORD = env('EMAIL_HOST_PASSWORD', default="") -DEFAULT_FROM_EMAIL = env('EMAIL_HOST_USER', default="") -SERVER_EMAIL = env('EMAIL_HOST_USER', default="") - -# Security settings for production -SECURE_SSL_REDIRECT = True -SECURE_HSTS_SECONDS = 31536000 -SECURE_HSTS_INCLUDE_SUBDOMAINS = True -SECURE_HSTS_PRELOAD = True -SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https') - -# Session settings -SESSION_COOKIE_SECURE = True -CSRF_COOKIE_SECURE = True - -# Static files -STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage' - -## Tailwind -TAILWIND_CLI_VERSION = "4.1.3" # Pin version -TAILWIND_CLI_AUTOMATIC_DOWNLOAD = False # Use pre-installed CLI -TAILWIND_CLI_DIST_CSS = "static/css/tailwind.min.css" \ No newline at end of file diff --git a/core/urls.py b/core/urls.py deleted file mode 100644 index 58c343a..0000000 --- a/core/urls.py +++ /dev/null @@ -1,30 +0,0 @@ -"""generated with djinit""" - -from django.contrib import admin -from django.urls import path -from django.urls import include -from django.conf import settings -from drf_spectacular.views import ( - SpectacularAPIView, - SpectacularSwaggerView, -) -from rest_framework_simplejwt.views import ( - TokenObtainPairView, - TokenRefreshView, - TokenBlacklistView, -) - -urlpatterns = [ - path("admin/", admin.site.urls), - # JWT tokens - path("token/", TokenObtainPairView.as_view(), name="token_obtain_pair"), - path("token/refresh/", TokenRefreshView.as_view(), name="token_refresh"), - path("token/blacklist/", TokenBlacklistView.as_view(), name="token_blacklist"), -] - -# Don't show schema in production -if settings.DEBUG: - urlpatterns += [ - path("schema/", SpectacularAPIView.as_view(), name="schema"), - path("docs/", SpectacularSwaggerView.as_view(url_name="schema")), - ] \ No newline at end of file diff --git a/core/wsgi.py b/core/wsgi.py deleted file mode 100644 index 6ea6a11..0000000 --- a/core/wsgi.py +++ /dev/null @@ -1,12 +0,0 @@ -"""generated with djinit""" - -import os -import environ -from django.core.wsgi import get_wsgi_application - -env = environ.Env() -environ.Env.read_env() - -os.environ.setdefault("DJANGO_SETTINGS_MODULE", env("DJANGO_SETTINGS_MODULE", default="core.settings.production")) - -application = get_wsgi_application() \ No newline at end of file