mirror of
https://github.com/revanced/revanced-releases-api.git
synced 2025-04-30 06:24:27 +02:00

* refactor: import routers from old branch * refactor: import InternalCache removal * refactor: move routes into dedicated routers * fix: fixes entrypoint * refactor: add documentation and bump libs
32 lines
920 B
Python
32 lines
920 B
Python
import os
|
|
import httpx_cache
|
|
import app.utils.Logger as Logger
|
|
|
|
class HTTPXClient:
|
|
|
|
"""Implements the methods required to get the latest releases and patches from revanced repositories."""
|
|
|
|
@staticmethod
|
|
def create() -> httpx_cache.AsyncClient:
|
|
"""Create HTTPX client with cache
|
|
|
|
Returns:
|
|
httpx_cache.AsyncClient: HTTPX client with cache
|
|
"""
|
|
|
|
headers = {'Accept': "application/vnd.github+json",
|
|
'Authorization': "token " + os.environ['GITHUB_TOKEN']
|
|
}
|
|
|
|
httpx_logger = Logger.HTTPXLogger()
|
|
|
|
httpx_client = httpx_cache.AsyncClient(
|
|
headers=headers,
|
|
http2=True,
|
|
event_hooks={
|
|
'request': [httpx_logger.log_request],
|
|
'response': [httpx_logger.log_response]
|
|
}
|
|
)
|
|
|
|
return httpx_client |