Add /.tokens debug endpoint to see token pool
This commit is contained in:
parent
dd71e60f35
commit
f9c9b0d3a4
3 changed files with 22 additions and 1 deletions
|
@ -9,7 +9,7 @@ import jester
|
||||||
import types, config, prefs, formatters, redis_cache, http_pool, tokens
|
import types, config, prefs, formatters, redis_cache, http_pool, tokens
|
||||||
import views/[general, about]
|
import views/[general, about]
|
||||||
import routes/[
|
import routes/[
|
||||||
preferences, timeline, status, media, search, rss, list,
|
preferences, timeline, status, media, search, rss, list, debug,
|
||||||
unsupported, embed, resolver, router_utils]
|
unsupported, embed, resolver, router_utils]
|
||||||
|
|
||||||
const instancesUrl = "https://github.com/zedeus/nitter/wiki/Instances"
|
const instancesUrl = "https://github.com/zedeus/nitter/wiki/Instances"
|
||||||
|
@ -49,6 +49,7 @@ createSearchRouter(cfg)
|
||||||
createMediaRouter(cfg)
|
createMediaRouter(cfg)
|
||||||
createEmbedRouter(cfg)
|
createEmbedRouter(cfg)
|
||||||
createRssRouter(cfg)
|
createRssRouter(cfg)
|
||||||
|
createDebugRouter(cfg)
|
||||||
|
|
||||||
settings:
|
settings:
|
||||||
port = Port(cfg.port)
|
port = Port(cfg.port)
|
||||||
|
@ -98,3 +99,4 @@ routes:
|
||||||
extend status, ""
|
extend status, ""
|
||||||
extend media, ""
|
extend media, ""
|
||||||
extend embed, ""
|
extend embed, ""
|
||||||
|
extend debug, ""
|
||||||
|
|
|
@ -42,3 +42,6 @@ template getCursor*(req: Request): string =
|
||||||
|
|
||||||
proc getNames*(name: string): seq[string] =
|
proc getNames*(name: string): seq[string] =
|
||||||
name.strip(chars={'/'}).split(",").filterIt(it.len > 0)
|
name.strip(chars={'/'}).split(",").filterIt(it.len > 0)
|
||||||
|
|
||||||
|
template respJson*(body: string) =
|
||||||
|
resp body, "application/json"
|
||||||
|
|
|
@ -14,6 +14,22 @@ var
|
||||||
tokenPool: seq[Token]
|
tokenPool: seq[Token]
|
||||||
lastFailed: Time
|
lastFailed: Time
|
||||||
|
|
||||||
|
proc getPoolJson*: string =
|
||||||
|
let list = newJObject()
|
||||||
|
for token in tokenPool:
|
||||||
|
list[token.tok] = %*{
|
||||||
|
"apis": newJObject(),
|
||||||
|
"init": $token.init,
|
||||||
|
"lastUse": $token.lastUse
|
||||||
|
}
|
||||||
|
|
||||||
|
for api in token.apis.keys:
|
||||||
|
list[token.tok]["apis"][$api] = %*{
|
||||||
|
"remaining": token.apis[api].remaining,
|
||||||
|
"reset": $token.apis[api].reset
|
||||||
|
}
|
||||||
|
|
||||||
|
return $list
|
||||||
|
|
||||||
proc rateLimitError*(): ref RateLimitError =
|
proc rateLimitError*(): ref RateLimitError =
|
||||||
newException(RateLimitError, "rate limited")
|
newException(RateLimitError, "rate limited")
|
||||||
|
|
Loading…
Reference in a new issue