-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapp.py.jinja
More file actions
69 lines (65 loc) · 1.64 KB
/
Copy pathapp.py.jinja
File metadata and controls
69 lines (65 loc) · 1.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
"""Litestar application factory."""
from litestar import Litestar, get
from litestar.logging import LoggingConfig
from litestar.openapi import OpenAPIConfig
from litestar.openapi.plugins import ScalarRenderPlugin
from .config import settings
{% if advanced_alchemy %}
from advanced_alchemy.exceptions import RepositoryError
from .config import alchemy
from .lib import exception_handler
from .controllers import UserController
{% endif %}
{% if litestar_vite %}
from litestar_vite import ViteConfig, VitePlugin
{% endif %}
{% if has_store %}
from .config import redis_store
{% endif %}
{% if litestar_saq %}
from .config import saq
{% endif %}
@get("/health")
async def health() -> dict[str, str]:
"""Health check endpoint."""
return {"status": "healthy"}
app = Litestar(
{% if advanced_alchemy %}
route_handlers=[health, UserController],
{% else %}
route_handlers=[health],
{% endif %}
debug=settings.DEBUG,
openapi_config=OpenAPIConfig(
title=settings.APP_NAME,
version="0.1.0",
path="/schema",
render_plugins=[ScalarRenderPlugin()],
),
logging_config=LoggingConfig(
disable_stack_trace={
404,
},
log_exceptions="always",
),
{% if has_store %}
stores={"redis": redis_store},
{% endif %}
{% if advanced_alchemy %}
exception_handlers={
Exception: exception_handler,
RepositoryError: exception_handler,
},
{% endif %}
plugins=[
{% if advanced_alchemy %}
alchemy,
{% endif %}
{% if litestar_vite %}
VitePlugin(config=ViteConfig(dev_mode=settings.DEBUG)),
{% endif %}
{% if litestar_saq %}
saq,
{% endif %}
],
)