from django.conf import settings
from django.conf.urls.static import static
from django.contrib import admin
from django.urls import include, path
from games import urls as games_urls
from search import urls as search_urls
from games.api.views import (
    DeveloperViewSet,
    GameSystemViewSet,
    GameViewSet,
    PublisherViewSet,
)
from rest_framework import routers

router = routers.DefaultRouter()
router.register(r"games", GameViewSet)
router.register(r"publishers", PublisherViewSet)
router.register(r"developers", DeveloperViewSet)
router.register(r"game-systems", GameSystemViewSet)

urlpatterns = [
    path("admin/", admin.site.urls),
    path("api-auth/", include("rest_framework.urls")),
    path("api/v1/", include(router.urls)),
    path("search/", include(search_urls, namespace="search")),
    path("", include(games_urls, namespace="games")),
]

if settings.DEBUG:
    urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
    urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
