Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
dj-kaos-rest / urls.py
Size: Mime:
from django.conf import settings
from django.conf.urls import include
from django.urls import re_path, path
from django.utils.module_loading import import_string
from rest_framework.routers import DefaultRouter, SimpleRouter
from rest_framework.schemas import get_schema_view
from rest_framework_simplejwt.views import TokenRefreshView

from .jwt import with_user_jwt_factory

API_TITLE = settings.API_TITLE
API_VERSIONS = settings.API_VERSIONS
CURR_API_VERSION = API_VERSIONS[-1]
API_VERSION_PATH_REGEX = f'(?P<version>({"|".join(API_VERSIONS)}))/'

if settings.DEBUG:
    router = DefaultRouter()
else:
    router = SimpleRouter()

for app_routes in settings.API_ROUTES:
    for prefix, viewset in import_string(app_routes):
        router.register(prefix, viewset)

TokenObtainPairView = with_user_jwt_factory(import_string(settings.AUTH_USER_SERIALIZER))
urlpatterns = [
    path('auth/token/obtain/', TokenObtainPairView.as_view()),
    path('auth/token/refresh/', TokenRefreshView.as_view()),
    re_path(API_VERSION_PATH_REGEX, include(router.urls)),
    path('auth/', include('rest_framework.urls')),
    path('', get_schema_view(title=API_TITLE, version=CURR_API_VERSION)),
]