Skip to content

Commit 491bcb1

Browse files
committed
fix(api): clean up API routes and remove debug code
- Remove debug echo statement from status API route - Fix route pattern for /api/i/user/@user_id by removing trailing optional slash - Improve code formatting by consolidating condition checks - Add validation condition for username parameter in timeline API route These changes improve code quality and ensure API routes work correctly.
1 parent ea05262 commit 491bcb1

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

src/jsons/status.nim

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,6 @@ proc createJsonApiStatusRouter*(cfg: Config) =
5555
respJsonError "Invalid tweet ID"
5656

5757
let conv = await getTweet(id, getCursor())
58-
if conv == nil:
59-
echo "nil conv"
6058

6159
if conv == nil or conv.tweet == nil or conv.tweet.id == 0:
6260
var error = "Tweet not found"

src/jsons/timeline.nim

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ proc formatProfileAsJson*(profile: Profile): JsonNode =
115115

116116
proc createJsonApiTimelineRouter*(cfg: Config) =
117117
router jsonapi_timeline:
118-
get "/api/i/user/@user_id/?":
118+
get "/api/i/user/@user_id":
119119
cond @"user_id".len > 0
120120
let username = await getCachedUsername(@"user_id")
121121
if username.len > 0:
@@ -141,8 +141,8 @@ proc createJsonApiTimelineRouter*(cfg: Config) =
141141

142142
get "/api/@name/?@tab?/?":
143143
cond '.' notin @"name"
144-
cond @"name" notin ["pic", "gif", "video", "search", "settings", "login",
145-
"intent", "i"]
144+
cond @"name" notin ["pic", "gif", "video", "search", "settings", "login", "intent", "i"]
145+
cond @"name".allCharsInSet({'a'..'z', 'A'..'Z', '0'..'9', '_', ','})
146146
cond @"tab" in ["with_replies", "media", "search", ""]
147147
let
148148
prefs = cookiePrefs()

0 commit comments

Comments
 (0)