diff options
Diffstat (limited to 'backend')
-rw-r--r-- | backend/__init__.py | 12 | ||||
-rw-r--r-- | backend/constants.py | 3 | ||||
-rw-r--r-- | backend/routes/index.py | 7 |
3 files changed, 20 insertions, 2 deletions
diff --git a/backend/__init__.py b/backend/__init__.py index 5c6328b..a3704a0 100644 --- a/backend/__init__.py +++ b/backend/__init__.py @@ -1,13 +1,22 @@ +import sentry_sdk +from sentry_sdk.integrations.asgi import SentryAsgiMiddleware from starlette.applications import Starlette from starlette.middleware import Middleware from starlette.middleware.authentication import AuthenticationMiddleware from starlette.middleware.cors import CORSMiddleware +from backend import constants from backend.authentication import JWTAuthenticationBackend from backend.route_manager import create_route_map from backend.middleware import DatabaseMiddleware, ProtectedDocsMiddleware from backend.validation import api +sentry_sdk.init( + dsn=constants.FORMS_BACKEND_DSN, + send_default_pii=True, + release=f"forms-backend@{constants.GIT_SHA}" +) + middleware = [ Middleware( CORSMiddleware, @@ -21,7 +30,8 @@ middleware = [ ), Middleware(DatabaseMiddleware), Middleware(AuthenticationMiddleware, backend=JWTAuthenticationBackend()), - Middleware(ProtectedDocsMiddleware) + Middleware(SentryAsgiMiddleware), + Middleware(ProtectedDocsMiddleware), ] app = Starlette(routes=create_route_map(), middleware=middleware) diff --git a/backend/constants.py b/backend/constants.py index bf0c33c..fedab64 100644 --- a/backend/constants.py +++ b/backend/constants.py @@ -17,6 +17,9 @@ OAUTH2_REDIRECT_URI = os.getenv( "https://forms.pythondiscord.com/callback" ) +GIT_SHA = os.getenv("GIT_SHA", "dev") +FORMS_BACKEND_DSN = os.getenv("FORMS_BACKEND_DSN") + DOCS_PASSWORD = os.getenv("DOCS_PASSWORD") SECRET_KEY = os.getenv("SECRET_KEY", binascii.hexlify(os.urandom(30)).decode()) diff --git a/backend/routes/index.py b/backend/routes/index.py index dd40d01..2551c58 100644 --- a/backend/routes/index.py +++ b/backend/routes/index.py @@ -7,6 +7,7 @@ from spectree import Response from starlette.requests import Request from starlette.responses import JSONResponse +from backend.constants import GIT_SHA from backend.route import Route from backend.validation import api @@ -19,6 +20,9 @@ class IndexResponse(BaseModel): " be an IP of our internal load balancer" ) ) + sha: str = Field( + description="Current release Git SHA in production." + ) class IndexRoute(Route): @@ -41,7 +45,8 @@ class IndexRoute(Route): "client": request.client.host, "user": { "authenticated": False - } + }, + "sha": GIT_SHA } if request.user.is_authenticated: |