From c73180449ff1618c3c8afa4ee4e8f20ba8bab4f6 Mon Sep 17 00:00:00 2001 From: codey Date: Wed, 29 Jan 2025 15:45:09 -0500 Subject: [PATCH] misc/breaking: remove trailing slashes from endpoints --- endpoints/ai.py | 8 ++++---- endpoints/karma.py | 8 ++++---- endpoints/lastfm.py | 2 +- endpoints/lyric_search.py | 2 +- endpoints/misc.py | 10 +++++----- endpoints/rand_msg.py | 3 ++- endpoints/transcriptions.py | 6 +++--- endpoints/xc.py | 4 ++-- endpoints/yt.py | 4 ++-- 9 files changed, 24 insertions(+), 23 deletions(-) diff --git a/endpoints/ai.py b/endpoints/ai.py index a657181..7c54369 100644 --- a/endpoints/ai.py +++ b/endpoints/ai.py @@ -50,7 +50,7 @@ class AI(FastAPI): } for endpoint, handler in self.endpoints.items(): - app.add_api_route(f"/{endpoint}/", handler, methods=["POST"] if not endpoint == "testy" else ["POST", "GET"]) + app.add_api_route(f"/{endpoint}", handler, methods=["POST"] if not endpoint == "testy" else ["POST", "GET"]) async def respond_via_webhook(self, data: ValidHookSongRequest, originalRequest: Request): @@ -87,7 +87,7 @@ class AI(FastAPI): async def ai_handler(self, request: Request): """ - /ai/base/ + /ai/base AI BASE Request (Requires key) """ @@ -118,7 +118,7 @@ class AI(FastAPI): async def ai_openai_handler(self, request: Request): """ - /ai/openai/ + /ai/openai AI Request (Requires key) """ @@ -160,7 +160,7 @@ class AI(FastAPI): async def ai_song_handler(self, data: ValidAISongRequest, request: Request): """ - /ai/song/ + /ai/song AI (Song Info) Request [Public] """ ai_prompt = "You are a helpful assistant who will provide tidbits of info on songs the user may listen to." diff --git a/endpoints/karma.py b/endpoints/karma.py index f5e965a..3a0082c 100644 --- a/endpoints/karma.py +++ b/endpoints/karma.py @@ -119,12 +119,12 @@ class Karma(FastAPI): } for endpoint, handler in self.endpoints.items(): - app.add_api_route(f"/{endpoint}/", handler, methods=["POST"]) + app.add_api_route(f"/{endpoint}", handler, methods=["POST"]) async def top_karma_handler(self, request: Request, data: ValidTopKarmaRequest | None = None): """ - /karma/top/ + /karma/top Get top keywords for karma (Requires key) """ @@ -149,7 +149,7 @@ class Karma(FastAPI): async def get_karma_handler(self, data: ValidKarmaRetrievalRequest, request: Request): """ - /karma/get/ + /karma/get Get current karma value (Requires key) """ @@ -173,7 +173,7 @@ class Karma(FastAPI): async def modify_karma_handler(self, data: ValidKarmaUpdateRequest, request: Request): """ - /karma/update/ + /karma/update Update karma count (Requires key) """ diff --git a/endpoints/lastfm.py b/endpoints/lastfm.py index 35d4fc1..6a43416 100644 --- a/endpoints/lastfm.py +++ b/endpoints/lastfm.py @@ -73,7 +73,7 @@ class LastFM(FastAPI): } for endpoint, handler in self.endpoints.items(): - app.add_api_route(f"/{endpoint}/", handler, methods=["POST"]) + app.add_api_route(f"/{endpoint}", handler, methods=["POST"]) async def artist_by_name_handler(self, data: ValidArtistSearchRequest): """ diff --git a/endpoints/lyric_search.py b/endpoints/lyric_search.py index 2de2e6c..2d73d45 100644 --- a/endpoints/lyric_search.py +++ b/endpoints/lyric_search.py @@ -118,7 +118,7 @@ class LyricSearch(FastAPI): self.lrc_regex = regex.compile(r'\[([0-9]{2}:[0-9]{2})\.[0-9]{1,3}\](\s(.*)){0,}') for endpoint, handler in self.endpoints.items(): - app.add_api_route(f"/{endpoint}/", handler, methods=["POST"]) + app.add_api_route(f"/{endpoint}", handler, methods=["POST", "GET"]) # async def lyric_cache_list_handler(self): # """ diff --git a/endpoints/misc.py b/endpoints/misc.py index 4bb6326..8076eca 100644 --- a/endpoints/misc.py +++ b/endpoints/misc.py @@ -32,7 +32,7 @@ class Misc(FastAPI): } for endpoint, handler in self.endpoints.items(): - app.add_api_route(f"/{endpoint}/", handler, methods=["GET"], + app.add_api_route(f"/{endpoint}", handler, methods=["GET"], include_in_schema=False) async def get_radio_np(self) -> dict: @@ -72,7 +72,7 @@ class Misc(FastAPI): async def homepage_redis_widget(self) -> dict: """ - /widget/redis/ + /widget/redis Homepage Redis Widget Handler Args: None @@ -101,7 +101,7 @@ class Misc(FastAPI): async def homepage_sqlite_widget(self) -> dict: """ - /widget/sqlite/ + /widget/sqlite Homepage SQLite Widget Handler Args: None @@ -119,7 +119,7 @@ class Misc(FastAPI): async def homepage_lyrics_widget(self) -> dict: """ - /widget/lyrics/ + /widget/lyrics Homepage Lyrics Widget Handler Args: None @@ -131,7 +131,7 @@ class Misc(FastAPI): async def homepage_radio_widget(self) -> dict: """ - /widget/radio/ + /widget/radio Homepage Radio Widget Handler Args: None diff --git a/endpoints/rand_msg.py b/endpoints/rand_msg.py index 1678b5b..be0c2ad 100644 --- a/endpoints/rand_msg.py +++ b/endpoints/rand_msg.py @@ -24,10 +24,11 @@ class RandMsg(FastAPI): self.endpoint_name = "randmsg" - app.add_api_route(f"/{self.endpoint_name}/", self.randmsg_handler, methods=["POST"]) + app.add_api_route(f"/{self.endpoint_name}", self.randmsg_handler, methods=["POST"]) async def randmsg_handler(self, data: RandMsgRequest = None): """ + /randmsg Get a randomly generated message """ random.seed() diff --git a/endpoints/transcriptions.py b/endpoints/transcriptions.py index 661d7aa..f43d685 100644 --- a/endpoints/transcriptions.py +++ b/endpoints/transcriptions.py @@ -36,11 +36,11 @@ class Transcriptions(FastAPI): } for endpoint, handler in self.endpoints.items(): - app.add_api_route(f"/{endpoint}/", handler, methods=["POST"]) + app.add_api_route(f"/{endpoint}", handler, methods=["POST"]) async def get_episodes_handler(self, data: ValidShowEpisodeListRequest): """ - /transcriptions/get_episodes/ + /transcriptions/get_episodes Get list of episodes by show id """ show_id = data.s @@ -97,7 +97,7 @@ class Transcriptions(FastAPI): } async def get_episode_lines_handler(self, data: ValidShowEpisodeLineRequest): - """/transcriptions/get_episode_lines/ + """/transcriptions/get_episode_lines Get lines for a particular episode """ show_id = data.s diff --git a/endpoints/xc.py b/endpoints/xc.py index b02ceb6..1d9857b 100644 --- a/endpoints/xc.py +++ b/endpoints/xc.py @@ -42,7 +42,7 @@ class XC(FastAPI): app.add_api_websocket_route(f"/{endpoint}/", handler) for endpoint, handler in self.endpoints.items(): - app.add_api_route(f"/{endpoint}/", handler, methods=["POST"]) + app.add_api_route(f"/{endpoint}", handler, methods=["POST"]) # async def put_ws_handler(self, ws: WebSocket): # await ws.accept() @@ -50,7 +50,7 @@ class XC(FastAPI): async def xc_handler(self, data: ValidXCRequest, request: Request): """ - /xc/ + /xc Handle XC Commands """ key = data.key diff --git a/endpoints/yt.py b/endpoints/yt.py index e88280f..18046ee 100644 --- a/endpoints/yt.py +++ b/endpoints/yt.py @@ -27,11 +27,11 @@ class YT(FastAPI): } for endpoint, handler in self.endpoints.items(): - app.add_api_route(f"/{endpoint}/", handler, methods=["POST"]) + app.add_api_route(f"/{endpoint}", handler, methods=["POST"]) async def yt_video_search_handler(self, data: ValidYTSearchRequest): """ - /yt_video_search/ + /yt_video_search Search for YT Video by Title (closest match returned) """