mirror of
https://github.com/zedeus/nitter.git
synced 2025-04-21 16:34:12 +00:00
Merge pull request #1 from DimensionDev/feat/add-api-route
feat: add jsonapi route
This commit is contained in:
commit
9aec266b80
6 changed files with 20 additions and 1 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -9,6 +9,7 @@ nitter
|
|||
/tools/rendermd
|
||||
/public/css/style.css
|
||||
/public/md/*.html
|
||||
/tools/venv
|
||||
nitter.conf
|
||||
guest_accounts.json*
|
||||
sessions.json*
|
||||
|
|
|
@ -23,6 +23,7 @@ redisMaxConnections = 30
|
|||
hmacKey = "secretkey" # random key for cryptographic signing of video urls
|
||||
base64Media = false # use base64 encoding for proxied media urls
|
||||
enableRSS = true # set this to false to disable RSS feeds
|
||||
enableJsonApi = true # set this to false to disable the JSON API
|
||||
enableDebug = false # enable request logs and debug endpoints (/.sessions)
|
||||
proxy = "" # http/https url, SOCKS proxies are not supported
|
||||
proxyAuth = ""
|
||||
|
|
|
@ -38,6 +38,7 @@ proc getConfig*(path: string): (Config, parseCfg.Config) =
|
|||
base64Media: cfg.get("Config", "base64Media", false),
|
||||
minTokens: cfg.get("Config", "tokenCount", 10),
|
||||
enableRss: cfg.get("Config", "enableRSS", true),
|
||||
enableJsonApi: cfg.get("Config", "enableJsonApi", true),
|
||||
enableDebug: cfg.get("Config", "enableDebug", false),
|
||||
proxy: cfg.get("Config", "proxy", ""),
|
||||
proxyAuth: cfg.get("Config", "proxyAuth", "")
|
||||
|
|
|
@ -9,7 +9,7 @@ import jester
|
|||
import types, config, prefs, formatters, redis_cache, http_pool, auth
|
||||
import views/[general, about]
|
||||
import routes/[
|
||||
preferences, timeline, status, media, search, rss, list, debug,
|
||||
preferences, timeline, status, media, search, jsonapi, rss, list, debug,
|
||||
unsupported, embed, resolver, router_utils]
|
||||
|
||||
const instancesUrl = "https://github.com/zedeus/nitter/wiki/Instances"
|
||||
|
@ -52,6 +52,7 @@ createStatusRouter(cfg)
|
|||
createSearchRouter(cfg)
|
||||
createMediaRouter(cfg)
|
||||
createEmbedRouter(cfg)
|
||||
createJsonApiRouter(cfg)
|
||||
createRssRouter(cfg)
|
||||
createDebugRouter(cfg)
|
||||
|
||||
|
@ -102,6 +103,7 @@ routes:
|
|||
resp Http429, showError(
|
||||
&"Instance has no auth tokens, or is fully rate limited.<br>Use {link} or try again later.", cfg)
|
||||
|
||||
extend jsonapi, ""
|
||||
extend rss, ""
|
||||
extend status, ""
|
||||
extend search, ""
|
||||
|
|
13
src/routes/jsonapi.nim
Normal file
13
src/routes/jsonapi.nim
Normal file
|
@ -0,0 +1,13 @@
|
|||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
import asyncdispatch
|
||||
|
||||
import jester
|
||||
|
||||
import router_utils, timeline
|
||||
|
||||
proc createJsonApiRouter*(cfg: Config) =
|
||||
router jsonapi:
|
||||
get "/hello":
|
||||
cond cfg.enableJsonApi
|
||||
let headers = {"Content-Type": "application/json; charset=utf-8"}
|
||||
resp Http200, headers, """{"message": "Hello, world"}"""
|
|
@ -268,6 +268,7 @@ type
|
|||
base64Media*: bool
|
||||
minTokens*: int
|
||||
enableRss*: bool
|
||||
enableJsonApi*: bool
|
||||
enableDebug*: bool
|
||||
proxy*: string
|
||||
proxyAuth*: string
|
||||
|
|
Loading…
Reference in a new issue