litestar-vite 0.2.2__tar.gz → 0.2.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of litestar-vite might be problematic. Click here for more details.

Files changed (121) hide show
  1. {litestar_vite-0.2.2 → litestar_vite-0.2.3}/PKG-INFO +1 -1
  2. {litestar_vite-0.2.2 → litestar_vite-0.2.3}/litestar_vite/inertia/config.py +4 -2
  3. {litestar_vite-0.2.2 → litestar_vite-0.2.3}/litestar_vite/inertia/exception_handler.py +22 -16
  4. {litestar_vite-0.2.2 → litestar_vite-0.2.3}/litestar_vite/inertia/response.py +29 -15
  5. {litestar_vite-0.2.2 → litestar_vite-0.2.3}/litestar_vite/plugin.py +1 -1
  6. {litestar_vite-0.2.2 → litestar_vite-0.2.3}/pyproject.toml +1 -1
  7. {litestar_vite-0.2.2 → litestar_vite-0.2.3}/tests/test_inertia/test_inertia_request.py +1 -1
  8. {litestar_vite-0.2.2 → litestar_vite-0.2.3}/tests/test_inertia/test_inertia_response.py +4 -4
  9. {litestar_vite-0.2.2 → litestar_vite-0.2.3}/.github/CODEOWNERS +0 -0
  10. {litestar_vite-0.2.2 → litestar_vite-0.2.3}/.github/dependabot.yaml +0 -0
  11. {litestar_vite-0.2.2 → litestar_vite-0.2.3}/.github/workflows/cd.yaml +0 -0
  12. {litestar_vite-0.2.2 → litestar_vite-0.2.3}/.github/workflows/ci.yaml +0 -0
  13. {litestar_vite-0.2.2 → litestar_vite-0.2.3}/.github/workflows/docs-preview.yaml +0 -0
  14. {litestar_vite-0.2.2 → litestar_vite-0.2.3}/.github/workflows/docs.yaml +0 -0
  15. {litestar_vite-0.2.2 → litestar_vite-0.2.3}/.github/workflows/pr-title.yaml +0 -0
  16. {litestar_vite-0.2.2 → litestar_vite-0.2.3}/.github/workflows/publish.yaml +0 -0
  17. {litestar_vite-0.2.2 → litestar_vite-0.2.3}/.gitignore +0 -0
  18. {litestar_vite-0.2.2 → litestar_vite-0.2.3}/.pre-commit-config.yaml +0 -0
  19. {litestar_vite-0.2.2 → litestar_vite-0.2.3}/.python-version +0 -0
  20. {litestar_vite-0.2.2 → litestar_vite-0.2.3}/CONTRIBUTING.rst +0 -0
  21. {litestar_vite-0.2.2 → litestar_vite-0.2.3}/LICENSE +0 -0
  22. {litestar_vite-0.2.2 → litestar_vite-0.2.3}/Makefile +0 -0
  23. {litestar_vite-0.2.2 → litestar_vite-0.2.3}/README.md +0 -0
  24. {litestar_vite-0.2.2 → litestar_vite-0.2.3}/docs/Makefile +0 -0
  25. {litestar_vite-0.2.2 → litestar_vite-0.2.3}/docs/conf.py +0 -0
  26. {litestar_vite-0.2.2 → litestar_vite-0.2.3}/docs/contribution-guide.rst +0 -0
  27. {litestar_vite-0.2.2 → litestar_vite-0.2.3}/docs/fix_missing_references.py +0 -0
  28. {litestar_vite-0.2.2 → litestar_vite-0.2.3}/docs/index.rst +0 -0
  29. {litestar_vite-0.2.2 → litestar_vite-0.2.3}/docs/reference/config.rst +0 -0
  30. {litestar_vite-0.2.2 → litestar_vite-0.2.3}/docs/reference/plugin.rst +0 -0
  31. {litestar_vite-0.2.2 → litestar_vite-0.2.3}/docs/usage/index.rst +0 -0
  32. {litestar_vite-0.2.2 → litestar_vite-0.2.3}/docs/usage/placeholder.rst +0 -0
  33. {litestar_vite-0.2.2 → litestar_vite-0.2.3}/examples/__init__.py +0 -0
  34. {litestar_vite-0.2.2 → litestar_vite-0.2.3}/examples/basic/app.py +0 -0
  35. {litestar_vite-0.2.2 → litestar_vite-0.2.3}/examples/basic/package-lock.json +0 -0
  36. {litestar_vite-0.2.2 → litestar_vite-0.2.3}/examples/basic/package.json +0 -0
  37. {litestar_vite-0.2.2 → litestar_vite-0.2.3}/examples/basic/public/assets/main-l0sNRNKZ.js +0 -0
  38. {litestar_vite-0.2.2 → litestar_vite-0.2.3}/examples/basic/public/assets/styles-l0sNRNKZ.js +0 -0
  39. {litestar_vite-0.2.2 → litestar_vite-0.2.3}/examples/basic/public/manifest.json +0 -0
  40. {litestar_vite-0.2.2 → litestar_vite-0.2.3}/examples/basic/resources/main.ts +0 -0
  41. {litestar_vite-0.2.2 → litestar_vite-0.2.3}/examples/basic/resources/styles.css +0 -0
  42. {litestar_vite-0.2.2 → litestar_vite-0.2.3}/examples/basic/templates/index.html.j2 +0 -0
  43. {litestar_vite-0.2.2 → litestar_vite-0.2.3}/examples/basic/tsconfig.json +0 -0
  44. {litestar_vite-0.2.2 → litestar_vite-0.2.3}/examples/basic/vite.config.ts +0 -0
  45. {litestar_vite-0.2.2 → litestar_vite-0.2.3}/examples/flash/app.py +0 -0
  46. {litestar_vite-0.2.2 → litestar_vite-0.2.3}/examples/flash/package-lock.json +0 -0
  47. {litestar_vite-0.2.2 → litestar_vite-0.2.3}/examples/flash/package.json +0 -0
  48. {litestar_vite-0.2.2 → litestar_vite-0.2.3}/examples/flash/public/assets/main-l0sNRNKZ.js +0 -0
  49. {litestar_vite-0.2.2 → litestar_vite-0.2.3}/examples/flash/public/assets/styles-l0sNRNKZ.js +0 -0
  50. {litestar_vite-0.2.2 → litestar_vite-0.2.3}/examples/flash/public/manifest.json +0 -0
  51. {litestar_vite-0.2.2 → litestar_vite-0.2.3}/examples/flash/resources/main.ts +0 -0
  52. {litestar_vite-0.2.2 → litestar_vite-0.2.3}/examples/flash/resources/styles.css +0 -0
  53. {litestar_vite-0.2.2 → litestar_vite-0.2.3}/examples/flash/templates/index.html.j2 +0 -0
  54. {litestar_vite-0.2.2 → litestar_vite-0.2.3}/examples/flash/tsconfig.json +0 -0
  55. {litestar_vite-0.2.2 → litestar_vite-0.2.3}/examples/flash/vite.config.ts +0 -0
  56. {litestar_vite-0.2.2 → litestar_vite-0.2.3}/examples/inertia/app.py +0 -0
  57. {litestar_vite-0.2.2 → litestar_vite-0.2.3}/examples/inertia/package-lock.json +0 -0
  58. {litestar_vite-0.2.2 → litestar_vite-0.2.3}/examples/inertia/package.json +0 -0
  59. {litestar_vite-0.2.2 → litestar_vite-0.2.3}/examples/inertia/postcss.config.cjs +0 -0
  60. {litestar_vite-0.2.2 → litestar_vite-0.2.3}/examples/inertia/public/assets/main-BIhkjqcE.js +0 -0
  61. {litestar_vite-0.2.2 → litestar_vite-0.2.3}/examples/inertia/public/assets/styles-B8hX6ha2.css +0 -0
  62. {litestar_vite-0.2.2 → litestar_vite-0.2.3}/examples/inertia/public/manifest.json +0 -0
  63. {litestar_vite-0.2.2 → litestar_vite-0.2.3}/examples/inertia/resources/Layout.vue +0 -0
  64. {litestar_vite-0.2.2 → litestar_vite-0.2.3}/examples/inertia/resources/main.js +0 -0
  65. {litestar_vite-0.2.2 → litestar_vite-0.2.3}/examples/inertia/resources/pages/Dashboard.vue +0 -0
  66. {litestar_vite-0.2.2 → litestar_vite-0.2.3}/examples/inertia/resources/pages/Home.vue +0 -0
  67. {litestar_vite-0.2.2 → litestar_vite-0.2.3}/examples/inertia/resources/styles.css +0 -0
  68. {litestar_vite-0.2.2 → litestar_vite-0.2.3}/examples/inertia/resources/templates/index.html +0 -0
  69. {litestar_vite-0.2.2 → litestar_vite-0.2.3}/examples/inertia/resources/vite-env.d.ts +0 -0
  70. {litestar_vite-0.2.2 → litestar_vite-0.2.3}/examples/inertia/tailwind.config.cjs +0 -0
  71. {litestar_vite-0.2.2 → litestar_vite-0.2.3}/examples/inertia/tsconfig.json +0 -0
  72. {litestar_vite-0.2.2 → litestar_vite-0.2.3}/examples/inertia/vite.config.ts +0 -0
  73. {litestar_vite-0.2.2 → litestar_vite-0.2.3}/litestar_vite/__init__.py +0 -0
  74. {litestar_vite-0.2.2 → litestar_vite-0.2.3}/litestar_vite/__metadata__.py +0 -0
  75. {litestar_vite-0.2.2 → litestar_vite-0.2.3}/litestar_vite/cli.py +0 -0
  76. {litestar_vite-0.2.2 → litestar_vite-0.2.3}/litestar_vite/commands.py +0 -0
  77. {litestar_vite-0.2.2 → litestar_vite-0.2.3}/litestar_vite/config.py +0 -0
  78. {litestar_vite-0.2.2 → litestar_vite-0.2.3}/litestar_vite/inertia/__init__.py +0 -0
  79. {litestar_vite-0.2.2 → litestar_vite-0.2.3}/litestar_vite/inertia/_utils.py +0 -0
  80. {litestar_vite-0.2.2 → litestar_vite-0.2.3}/litestar_vite/inertia/middleware.py +0 -0
  81. {litestar_vite-0.2.2 → litestar_vite-0.2.3}/litestar_vite/inertia/plugin.py +0 -0
  82. {litestar_vite-0.2.2 → litestar_vite-0.2.3}/litestar_vite/inertia/request.py +0 -0
  83. {litestar_vite-0.2.2 → litestar_vite-0.2.3}/litestar_vite/inertia/routes.py +0 -0
  84. {litestar_vite-0.2.2 → litestar_vite-0.2.3}/litestar_vite/inertia/types.py +0 -0
  85. {litestar_vite-0.2.2 → litestar_vite-0.2.3}/litestar_vite/loader.py +0 -0
  86. {litestar_vite-0.2.2 → litestar_vite-0.2.3}/litestar_vite/py.typed +0 -0
  87. {litestar_vite-0.2.2 → litestar_vite-0.2.3}/litestar_vite/template_engine.py +0 -0
  88. {litestar_vite-0.2.2 → litestar_vite-0.2.3}/litestar_vite/templates/__init__.py +0 -0
  89. {litestar_vite-0.2.2 → litestar_vite-0.2.3}/litestar_vite/templates/index.html.j2 +0 -0
  90. {litestar_vite-0.2.2 → litestar_vite-0.2.3}/litestar_vite/templates/main.ts.j2 +0 -0
  91. {litestar_vite-0.2.2 → litestar_vite-0.2.3}/litestar_vite/templates/package.json.j2 +0 -0
  92. {litestar_vite-0.2.2 → litestar_vite-0.2.3}/litestar_vite/templates/styles.css.j2 +0 -0
  93. {litestar_vite-0.2.2 → litestar_vite-0.2.3}/litestar_vite/templates/tsconfig.json.j2 +0 -0
  94. {litestar_vite-0.2.2 → litestar_vite-0.2.3}/litestar_vite/templates/vite.config.ts.j2 +0 -0
  95. {litestar_vite-0.2.2 → litestar_vite-0.2.3}/pdm.lock +0 -0
  96. {litestar_vite-0.2.2 → litestar_vite-0.2.3}/tests/__init__.py +0 -0
  97. {litestar_vite-0.2.2 → litestar_vite-0.2.3}/tests/conftest.py +0 -0
  98. {litestar_vite-0.2.2 → litestar_vite-0.2.3}/tests/templates/__init__.py +0 -0
  99. {litestar_vite-0.2.2 → litestar_vite-0.2.3}/tests/templates/index.html.j2 +0 -0
  100. {litestar_vite-0.2.2 → litestar_vite-0.2.3}/tests/test_app/__init__.py +0 -0
  101. {litestar_vite-0.2.2 → litestar_vite-0.2.3}/tests/test_app/app.py +0 -0
  102. {litestar_vite-0.2.2 → litestar_vite-0.2.3}/tests/test_app/web/__init__.py +0 -0
  103. {litestar_vite-0.2.2 → litestar_vite-0.2.3}/tests/test_app/web/public/.gitkeep +0 -0
  104. {litestar_vite-0.2.2 → litestar_vite-0.2.3}/tests/test_app/web/public/assets/main-l0sNRNKZ.js +0 -0
  105. {litestar_vite-0.2.2 → litestar_vite-0.2.3}/tests/test_app/web/public/assets/styles-l0sNRNKZ.js +0 -0
  106. {litestar_vite-0.2.2 → litestar_vite-0.2.3}/tests/test_app/web/public/manifest.json +0 -0
  107. {litestar_vite-0.2.2 → litestar_vite-0.2.3}/tests/test_app/web/resources/.gitkeep +0 -0
  108. {litestar_vite-0.2.2 → litestar_vite-0.2.3}/tests/test_app/web/resources/main.ts +0 -0
  109. {litestar_vite-0.2.2 → litestar_vite-0.2.3}/tests/test_app/web/resources/styles.css +0 -0
  110. {litestar_vite-0.2.2 → litestar_vite-0.2.3}/tests/test_app/web/templates/.gitkeep +0 -0
  111. {litestar_vite-0.2.2 → litestar_vite-0.2.3}/tests/test_app/web/templates/index.html +0 -0
  112. {litestar_vite-0.2.2 → litestar_vite-0.2.3}/tests/test_cli/__init__.py +0 -0
  113. {litestar_vite-0.2.2 → litestar_vite-0.2.3}/tests/test_cli/conftest.py +0 -0
  114. {litestar_vite-0.2.2 → litestar_vite-0.2.3}/tests/test_cli/test_init.py +0 -0
  115. {litestar_vite-0.2.2 → litestar_vite-0.2.3}/tests/test_commands.py +0 -0
  116. {litestar_vite-0.2.2 → litestar_vite-0.2.3}/tests/test_config.py +0 -0
  117. {litestar_vite-0.2.2 → litestar_vite-0.2.3}/tests/test_inertia/__init__.py +0 -0
  118. {litestar_vite-0.2.2 → litestar_vite-0.2.3}/tests/test_inertia/conftest.py +0 -0
  119. {litestar_vite-0.2.2 → litestar_vite-0.2.3}/tests/test_inertia/templates/index.html.j2 +0 -0
  120. {litestar_vite-0.2.2 → litestar_vite-0.2.3}/tests/test_inertia/test_routes.py +0 -0
  121. {litestar_vite-0.2.2 → litestar_vite-0.2.3}/tests/test_template_engine.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: litestar-vite
3
- Version: 0.2.2
3
+ Version: 0.2.3
4
4
  Summary: Vite plugin for Litestar
5
5
  Project-URL: Changelog, https://cofin.github.io/litestar-vite/latest/changelog
6
6
  Project-URL: Discord, https://discord.gg/X3FJqy8d2j
@@ -21,5 +21,7 @@ class InertiaConfig:
21
21
  """An identifier to use on routes to exclude a route from the generated routes typescript file."""
22
22
  redirect_unauthorized_to: str | None = None
23
23
  """Optionally supply a path where unauthorized requests should redirect."""
24
- extra_page_props: dict[str, Any] = field(default_factory=dict)
25
- """A dictionary of values to automatically add in to page props on every request."""
24
+ extra_static_page_props: dict[str, Any] = field(default_factory=dict)
25
+ """A dictionary of values to automatically add in to page props on every response."""
26
+ extra_session_page_props: set[str] = field(default_factory=set)
27
+ """A set of session keys for which the value automatically be added (if it exists) to the response."""
@@ -1,4 +1,3 @@
1
- import contextlib
2
1
  import re
3
2
  from typing import TYPE_CHECKING, Any, cast
4
3
 
@@ -44,7 +43,7 @@ class _HTTPConflictException(HTTPException):
44
43
  status_code = HTTP_409_CONFLICT
45
44
 
46
45
 
47
- def exception_to_http_response(request: Request[UserT, AuthT, StateT], exc: Exception) -> Response[Any]: # noqa: PLR0911
46
+ def exception_to_http_response(request: Request[UserT, AuthT, StateT], exc: Exception) -> Response[Any]:
48
47
  """Handler for all exceptions subclassed from HTTPException."""
49
48
  inertia_enabled = getattr(request, "inertia_enabled", False) or getattr(request, "is_inertia", False)
50
49
  if isinstance(exc, NotFoundError):
@@ -57,17 +56,25 @@ def exception_to_http_response(request: Request[UserT, AuthT, StateT], exc: Exce
57
56
  if request.app.debug and http_exc not in (PermissionDeniedException, NotFoundError):
58
57
  return cast("Response[Any]", create_debug_response(request, exc))
59
58
  return cast("Response[Any]", create_exception_response(request, http_exc(detail=str(exc.__cause__))))
59
+ return create_inertia_exception_response(request, exc)
60
+
61
+
62
+ def create_inertia_exception_response(request: Request[UserT, AuthT, StateT], exc: Exception) -> Response[Any]:
63
+ """Create the inertia exception response"""
60
64
  is_inertia = getattr(request, "is_inertia", False)
61
65
  status_code = getattr(exc, "status_code", HTTP_500_INTERNAL_SERVER_ERROR)
62
- preferred_type = MediaType.HTML if inertia_enabled and not is_inertia else MediaType.JSON
66
+ preferred_type = MediaType.HTML if not is_inertia else MediaType.JSON
63
67
  detail = getattr(exc, "detail", "") # litestar exceptions
64
68
  extras = getattr(exc, "extra", "") # msgspec exceptions
65
69
  content = {"status_code": status_code, "message": getattr(exc, "detail", "")}
66
70
  inertia_plugin = cast("InertiaPlugin", request.app.plugins.get("InertiaPlugin"))
67
71
  if extras:
68
72
  content.update({"extra": extras})
69
- with contextlib.suppress(Exception):
73
+ try:
70
74
  flash(request, detail, category="error")
75
+ except Exception as flash_exc:
76
+ msg = f"Failed to set the `flash` session state. Reason: {flash_exc.__cause__!s}"
77
+ request.logger.exception(msg)
71
78
  if extras and len(extras) >= 1:
72
79
  message = extras[0]
73
80
  default_field = f"root.{message.get('key')}" if message.get("key", None) is not None else "root" # type: ignore
@@ -75,8 +82,7 @@ def exception_to_http_response(request: Request[UserT, AuthT, StateT], exc: Exce
75
82
  match = FIELD_ERR_RE.search(error_detail)
76
83
  field = match.group(1) if match else default_field
77
84
  if isinstance(message, dict):
78
- with contextlib.suppress(Exception):
79
- error(request, field, error_detail)
85
+ error(request, field, error_detail)
80
86
  if status_code in {HTTP_422_UNPROCESSABLE_ENTITY, HTTP_400_BAD_REQUEST} or isinstance(
81
87
  exc,
82
88
  PermissionDeniedException,
@@ -85,15 +91,15 @@ def exception_to_http_response(request: Request[UserT, AuthT, StateT], exc: Exce
85
91
  if isinstance(exc, PermissionDeniedException):
86
92
  return InertiaBack(request)
87
93
  if status_code == HTTP_401_UNAUTHORIZED or isinstance(exc, NotAuthorizedException):
88
- redirect_to = (
94
+ if (
89
95
  inertia_plugin.config.redirect_unauthorized_to is not None
90
96
  and str(request.url) != inertia_plugin.config.redirect_unauthorized_to
91
- )
92
- if redirect_to:
93
- return InertiaRedirect(request, redirect_to=cast("str", inertia_plugin.config.redirect_unauthorized_to))
94
- return InertiaBack(request)
95
- return InertiaResponse[Any](
96
- media_type=preferred_type,
97
- content=content,
98
- status_code=status_code,
99
- )
97
+ ):
98
+ return InertiaRedirect(request, redirect_to=inertia_plugin.config.redirect_unauthorized_to)
99
+ if str(request.url) != inertia_plugin.config.redirect_unauthorized_to:
100
+ return InertiaResponse[Any](
101
+ media_type=preferred_type,
102
+ content=content,
103
+ status_code=status_code,
104
+ )
105
+ return InertiaBack(request)
@@ -16,7 +16,6 @@ from litestar.response import Redirect
16
16
  from litestar.response.base import ASGIResponse
17
17
  from litestar.serialization import get_serializer
18
18
  from litestar.status_codes import HTTP_200_OK, HTTP_303_SEE_OTHER, HTTP_307_TEMPORARY_REDIRECT, HTTP_409_CONFLICT
19
- from litestar.types import Empty
20
19
  from litestar.utils.deprecation import warn_deprecation
21
20
  from litestar.utils.empty import value_or_default
22
21
  from litestar.utils.helpers import get_enum_string_value
@@ -47,7 +46,11 @@ def share(
47
46
  key: str,
48
47
  value: Any,
49
48
  ) -> None:
50
- connection.session.setdefault("_shared", {}).update({key: value})
49
+ try:
50
+ connection.session.setdefault("_shared", {}).update({key: value})
51
+ except Exception as exc:
52
+ msg = f"Failed to set the `share` session state. Reason: {exc.__cause__!s}"
53
+ connection.logger.exception(msg)
51
54
 
52
55
 
53
56
  def error(
@@ -55,7 +58,11 @@ def error(
55
58
  key: str,
56
59
  message: str,
57
60
  ) -> None:
58
- connection.session.setdefault("_errors", {}).update({key: message})
61
+ try:
62
+ connection.session.setdefault("_errors", {}).update({key: message})
63
+ except Exception as exc:
64
+ msg = f"Failed to set the `error` session state. Reason: {exc.__cause__!s}"
65
+ connection.logger.exception(msg)
59
66
 
60
67
 
61
68
  def get_shared_props(request: ASGIConnection[Any, Any, Any, Any]) -> Dict[str, Any]: # noqa: UP006
@@ -64,19 +71,26 @@ def get_shared_props(request: ASGIConnection[Any, Any, Any, Any]) -> Dict[str, A
64
71
 
65
72
  Be sure to call this before `self.create_template_context` if you would like to include the `flash` message details.
66
73
  """
67
- error_bag = request.headers.get("X-Inertia-Error-Bag", None)
68
- has_active_session = not (not request.session or request.scope["session"] is Empty)
69
- errors: dict[str, Any] = request.session.pop("_errors", {}) if has_active_session else {}
70
- props: dict[str, Any] = request.session.pop("_shared", {}) if has_active_session else {}
71
- flash: dict[str, list[str]] = defaultdict(list)
72
- for message in cast("List[Dict[str,Any]]", request.session.pop("_messages", []) if has_active_session else []):
73
- flash[message["category"]].append(message["message"])
74
-
75
- inertia_plugin = cast("InertiaPlugin", request.app.plugins.get("InertiaPlugin"))
76
- props.update(inertia_plugin.config.extra_page_props)
74
+ props: dict[str, Any] = {}
75
+ try:
76
+ error_bag = request.headers.get("X-Inertia-Error-Bag", None)
77
+ errors: dict[str, Any] = request.session.pop("_errors", {})
78
+ props.update(cast("Dict[str,Any]", request.session.pop("_shared", {})))
79
+ flash: dict[str, list[str]] = defaultdict(list)
80
+ for message in cast("List[Dict[str,Any]]", request.session.pop("_messages", [])):
81
+ flash[message["category"]].append(message["message"])
82
+
83
+ inertia_plugin = cast("InertiaPlugin", request.app.plugins.get("InertiaPlugin"))
84
+ props.update(inertia_plugin.config.extra_static_page_props)
85
+ for session_prop in inertia_plugin.config.extra_session_page_props:
86
+ if session_prop not in props and session_prop in request.session:
87
+ props[session_prop] = request.session.get(session_prop)
88
+ props["flash"] = flash
89
+ props["errors"] = {error_bag: errors} if error_bag is not None else errors
90
+ except Exception as exc:
91
+ msg = f"Failed to set the `error` session state. Reason: {exc.__cause__}"
92
+ request.logger.exception(msg)
77
93
  props["csrf_token"] = value_or_default(ScopeState.from_scope(request.scope).csrf_token, "")
78
- props["flash"] = flash
79
- props["errors"] = {error_bag: errors} if error_bag is not None else errors
80
94
  return props
81
95
 
82
96
 
@@ -28,7 +28,7 @@ def set_environment(config: ViteConfig) -> None:
28
28
  os.environ.setdefault("VITE_PORT", str(config.port))
29
29
  os.environ.setdefault("VITE_HOST", config.host)
30
30
  os.environ.setdefault("VITE_PROTOCOL", config.protocol)
31
- os.environ.setdefault("APP_URL", "http://localhost:8000")
31
+ os.environ.setdefault("APP_URL", f"http://localhost:{os.environ.get('LITESTAR_PORT',8000)}")
32
32
  if config.dev_mode:
33
33
  os.environ.setdefault("VITE_DEV_MODE", str(config.dev_mode))
34
34
 
@@ -26,7 +26,7 @@ license = { text = "MIT" }
26
26
  name = "litestar-vite"
27
27
  readme = "README.md"
28
28
  requires-python = ">=3.8"
29
- version = "0.2.2"
29
+ version = "0.2.3"
30
30
 
31
31
  [project.urls]
32
32
  Changelog = "https://cofin.github.io/litestar-vite/latest/changelog"
@@ -73,7 +73,7 @@ async def test_is_inertia_true(inertia_plugin: InertiaPlugin, vite_plugin: ViteP
73
73
  response = client.get("/", headers={InertiaHeaders.ENABLED.value: "true"})
74
74
  assert (
75
75
  response.text
76
- == '{"component":null,"url":"/","version":"1.0","props":{"content":true,"csrf_token":"","flash":{},"errors":{}}}'
76
+ == '{"component":null,"url":"/","version":"1.0","props":{"content":true,"flash":{},"errors":{},"csrf_token":""}}'
77
77
  )
78
78
 
79
79
 
@@ -49,7 +49,7 @@ async def test_component_inertia_header_enabled(inertia_plugin: InertiaPlugin, v
49
49
  response = client.get("/", headers={InertiaHeaders.ENABLED.value: "true"})
50
50
  assert (
51
51
  response.content
52
- == b'{"component":"Home","url":"/","version":"1.0","props":{"content":{"thing":"value"},"csrf_token":"","flash":{},"errors":{}}}'
52
+ == b'{"component":"Home","url":"/","version":"1.0","props":{"content":{"thing":"value"},"flash":{},"errors":{},"csrf_token":""}}'
53
53
  )
54
54
 
55
55
 
@@ -72,7 +72,7 @@ async def test_component_inertia_flash_header_enabled(inertia_plugin: InertiaPlu
72
72
  response = client.get("/", headers={InertiaHeaders.ENABLED.value: "true"})
73
73
  assert (
74
74
  response.content
75
- == b'{"component":"Home","url":"/","version":"1.0","props":{"content":{"thing":"value"},"csrf_token":"","flash":{"info":["a flash message"]},"errors":{}}}'
75
+ == b'{"component":"Home","url":"/","version":"1.0","props":{"content":{"thing":"value"},"flash":{"info":["a flash message"]},"errors":{},"csrf_token":""}}'
76
76
  )
77
77
 
78
78
 
@@ -99,7 +99,7 @@ async def test_component_inertia_shared_flash_header_enabled(
99
99
  response = client.get("/", headers={InertiaHeaders.ENABLED.value: "true"})
100
100
  assert (
101
101
  response.content
102
- == b'{"component":"Home","url":"/","version":"1.0","props":{"content":{"thing":"value"},"auth":{"user":"nobody"},"csrf_token":"","flash":{"info":["a flash message"]},"errors":{}}}'
102
+ == b'{"component":"Home","url":"/","version":"1.0","props":{"content":{"thing":"value"},"auth":{"user":"nobody"},"flash":{"info":["a flash message"]},"errors":{},"csrf_token":""}}'
103
103
  )
104
104
 
105
105
 
@@ -135,5 +135,5 @@ async def test_component_inertia_version_redirect(inertia_plugin: InertiaPlugin,
135
135
  )
136
136
  assert (
137
137
  response.content
138
- == b'{"component":"Home","url":"/","version":"1.0","props":{"content":{"thing":"value"},"csrf_token":"","flash":{},"errors":{}}}'
138
+ == b'{"component":"Home","url":"/","version":"1.0","props":{"content":{"thing":"value"},"flash":{},"errors":{},"csrf_token":""}}'
139
139
  )
File without changes
File without changes
File without changes
File without changes
File without changes