Skip to content

Commit c02232c

Browse files
committed
Pass through Tidewave team configuration
1 parent c8d8801 commit c02232c

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

src/tidewave/django/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ class Middleware(MiddlewareMixin):
2929
Configuration:
3030
- ALLOWED_HOSTS: Used as allowed origins
3131
- TIDEWAVE['allow_remote_access']: Whether to allow remote connections (default False)
32+
- TIDEWAVE['team']: Enable Tidewave for teams
3233
"""
3334

3435
def __init__(self, get_response: Callable):
@@ -66,6 +67,7 @@ def _build_config(self) -> dict[str, Any]:
6667
tidewave_settings = getattr(settings, "TIDEWAVE", {})
6768
allow_remote_access = tidewave_settings.get("allow_remote_access", False)
6869
client_url = tidewave_settings.get("client_url", "https://tidewave.ai")
70+
team = tidewave_settings.get("team", {})
6971

7072
project_name = "django_app"
7173
try:
@@ -79,6 +81,7 @@ def _build_config(self) -> dict[str, Any]:
7981
"client_url": client_url,
8082
"allow_remote_access": allow_remote_access,
8183
"allowed_origins": allowed_hosts,
84+
"team": team,
8285
}
8386

8487
return config

src/tidewave/middleware.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ def _handle_home_route(self, start_response: Callable) -> Iterator[bytes]:
9292
client_config = {
9393
"project_name": self.config.get("project_name", "unknown"),
9494
"framework_type": self.config.get("framework_type", "unknown"),
95+
"team": self.config.get("team", {}),
9596
"tidewave_version": __version__,
9697
}
9798
config_json = html.escape(json.dumps(client_config))

tests/test_middleware.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,13 @@ def test_non_mcp_route_passes_through(self):
6262

6363
result = self.middleware(environ, self.start_response)
6464

65-
# Should call the wrapped app
6665
self.demo_app.assert_called_once_with(environ, self.start_response)
6766
self.assertEqual(result, [b"demo response"])
6867

6968
def test_home_route_returns_html(self):
7069
"""Test that /tidewave/ returns a valid HTML response"""
71-
result = self.middleware._handle_home_route(self.start_response)
70+
environ = self._create_environ("/tidewave")
71+
result = self.middleware(environ, self.start_response)
7272

7373
self.start_response.assert_called_once()
7474
call_args = self.start_response.call_args[0]
@@ -79,6 +79,7 @@ def test_home_route_returns_html(self):
7979
self.assertTrue(result)
8080
self.assertIsInstance(result[0], bytes)
8181
self.assertIn(b"tidewave:config", result[0].lower())
82+
self.assertIn(b""team": {}", result[0].lower())
8283

8384
def test_mcp_get_returns_405(self):
8485
"""Test that GET requests to /tidewave/mcp return 405"""

0 commit comments

Comments
 (0)