Dodaje backend /api/health/ endpoint i prebacuje frontend heartbeat sa /api/token/ OPTIONS na /api/health/ GET kako bi se izbjeglo periodicko gadanje auth rute. Dodaje TTL cache za clientStore (lastFetchedAt + force opcija) kako bi se smanjili redundantni crm/clients pozivi pri navigaciji. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
40 lines
1.3 KiB
Python
40 lines
1.3 KiB
Python
# backend/core/urls.py
|
|
from django.conf import settings
|
|
from django.conf.urls.static import static
|
|
from django.contrib import admin
|
|
from django.http import JsonResponse
|
|
from django.urls import path, include
|
|
from rest_framework_simplejwt.views import (
|
|
TokenObtainPairView,
|
|
TokenRefreshView,
|
|
)
|
|
|
|
def api_health(_request):
|
|
return JsonResponse({'status': 'ok'})
|
|
|
|
urlpatterns = [
|
|
path('admin/', admin.site.urls),
|
|
path('api/health/', api_health, name='api_health'),
|
|
|
|
# Uključujemo rute iz modula (svaki modul ima svoj urls.py)
|
|
path('api/crm/', include('modules.crm.urls')),
|
|
path('api/invoicing/', include('modules.invoicing.urls')),
|
|
path('api/tasks/', include('modules.task_management.urls')),
|
|
path('api/fleet/', include('modules.fleet.urls')),
|
|
|
|
# JWT Auth rute
|
|
path('api/token/', TokenObtainPairView.as_view(), name='token_obtain_pair'),
|
|
path('api/token/refresh/', TokenRefreshView.as_view(), name='token_refresh'),
|
|
|
|
# KORISNICI - registriramo ovdje
|
|
path('api/users/', include('core.users.urls')),
|
|
]
|
|
|
|
if settings.DEBUG:
|
|
import debug_toolbar
|
|
urlpatterns += [
|
|
path('__debug__/', include(debug_toolbar.urls)),
|
|
]
|
|
|
|
if settings.DEBUG or getattr(settings, 'SERVE_MEDIA_FILES', False):
|
|
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) |