Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,6 @@ JWT_ISSUER=xxx
OTP_LIFETIME=10

API_GATEWAY_PUBLIC_KEY=xxxxxxxxxxxxxxxxxxxxxxxx
API_KEY_EXPIRES_AT=2
API_KEY_EXPIRES_AT=2

RABBITMQ_HOST=localhost
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,5 @@ The Swagger documentation for the application is hosted on [Render](https://df-u
- Run the server locally on port 8000

```bash
uv run manage.py runserver 8000
uv run uvicorn src.config.asgi:application --reload --port 8000
```
4 changes: 3 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ dependencies = [
"pydantic[email]>=2.10.6",
"django-ninja>=1.3.0",
"pyjwt>=2.10.1",
"typing>=3.10.0.0",
"faststream[rabbit]>=0.5.39",
"starlette>=0.46.2",
"uvicorn>=0.34.2",
]

[dependency-groups]
Expand Down
1 change: 1 addition & 0 deletions src/api/services/external/RabbitMQRoutes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Empty file.
17 changes: 16 additions & 1 deletion src/config/asgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,22 @@
import os

from django.core.asgi import get_asgi_application
from faststream.rabbit import RabbitBroker
from starlette.routing import Mount
from starlette.applications import Starlette

from src.env import rabbitmq_config

broker = RabbitBroker(host=rabbitmq_config["host"])


os.environ.setdefault("DJANGO_SETTINGS_MODULE", "src.config.settings")

application = get_asgi_application()
application = Starlette(
routes=[Mount("/", get_asgi_application())], # type: ignore
on_startup=[broker.start],
on_shutdown=[broker.close],
)


from src.api.services.external import RabbitMQRoutes as RabbitMQRoutes # noqa: E402
19 changes: 18 additions & 1 deletion src/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ class OTP(TypedDict):
lifetime: int


class RabbitMQ(TypedDict):
host: str


env = Env()

app: App = {
Expand Down Expand Up @@ -105,4 +109,17 @@ class OTP(TypedDict):

otp: OTP = {"lifetime": get_env_int("OTP_LIFETIME")}

__all__ = ["api_gateway", "app", "cache", "db", "env", "jwt_config", "log", "otp"]
rabbitmq_config: RabbitMQ = {"host": get_env_str("RABBITMQ_HOST")}


__all__ = [
"api_gateway",
"app",
"cache",
"db",
"env",
"jwt_config",
"log",
"otp",
"rabbitmq_config",
]
482 changes: 407 additions & 75 deletions uv.lock

Large diffs are not rendered by default.