diff --git a/backend/clubs/urls.py b/backend/clubs/urls.py index 4a1006cad..48f2f0572 100644 --- a/backend/clubs/urls.py +++ b/backend/clubs/urls.py @@ -24,6 +24,7 @@ FavoriteCalendarAPIView, FavoriteEventsAPIView, FavoriteViewSet, + HealthView, MajorViewSet, MassInviteAPIView, MeetingZoomAPIView, @@ -176,6 +177,7 @@ WhartonApplicationStatusAPIView.as_view(), name="wharton-applications-status", ), + path(r"health/", HealthView.as_view(), name="health"), ] urlpatterns += router.urls diff --git a/backend/clubs/views.py b/backend/clubs/views.py index d8a127c62..d645a24ad 100644 --- a/backend/clubs/views.py +++ b/backend/clubs/views.py @@ -7565,6 +7565,27 @@ def post(self, request): return Response({"output": output.getvalue()}) +class HealthView(APIView): + def get(self, request): + """ + Health check endpoint to confirm the backend is running. + --- + summary: Health Check + responses: + "200": + content: + application/json: + schema: + type: object + properties: + message: + type: string + enum: ["OK"] + --- + """ + return Response({"message": "OK"}, status=status.HTTP_200_OK) + + def get_initial_context_from_types(types): """ Generate a sample context given the specified types. diff --git a/backend/tests/clubs/test_views.py b/backend/tests/clubs/test_views.py index f005efd00..150bbc8fa 100644 --- a/backend/tests/clubs/test_views.py +++ b/backend/tests/clubs/test_views.py @@ -2923,3 +2923,11 @@ def test_club_approval_response_templates(self): content_type="application/json", ) self.assertEqual(resp.status_code, 403) + + +class HealthTestCase(TestCase): + def test_health(self): + url = reverse("health") + resp = self.client.get(url) + self.assertEqual(resp.status_code, 200) + self.assertEqual(resp.data, {"message": "OK"})