schon/schon/asgi.py
2026-01-25 23:16:38 +03:00

31 lines
840 B
Python

"""
ASGI config for the Schon project with Django Channels.
Exposes the ASGI callable as a module-level variable named ``application``.
"""
import os
from contextlib import suppress
from typing import List
import django
from channels.routing import ProtocolTypeRouter, URLRouter
from django.core.asgi import get_asgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "schon.settings")
django.setup()
from engine.vibes_auth.messaging.auth import JWTAuthMiddlewareStack # noqa: E402
http_application = get_asgi_application()
messaging_urlpatters: List = []
with suppress(ModuleNotFoundError):
from engine.vibes_auth.messaging.urls import messaging_urlpatters
application = ProtocolTypeRouter(
{
"http": http_application,
"websocket": JWTAuthMiddlewareStack(URLRouter(messaging_urlpatters)),
}
)