This commit is contained in:
@@ -1,39 +0,0 @@
|
||||
from starlette.exceptions import HTTPException
|
||||
|
||||
|
||||
# TODO: remove traceback from logs for defined exceptions
|
||||
|
||||
|
||||
class BaseHttpException(HTTPException):
|
||||
states_code = 500
|
||||
detail = "500 Server error"
|
||||
|
||||
|
||||
class ExpiredToken(BaseHttpException):
|
||||
states_code = 401
|
||||
detail = "401 Expired Token"
|
||||
|
||||
|
||||
class InvalidToken(BaseHttpException):
|
||||
states_code = 401
|
||||
detail = "401 Invalid Token"
|
||||
|
||||
|
||||
class Unauthorized(BaseHttpException):
|
||||
states_code = 401
|
||||
detail = "401 Unauthorized"
|
||||
|
||||
|
||||
class ObjectNotExist(BaseHttpException):
|
||||
code = 404
|
||||
detail = "404 Object Does Not Exist"
|
||||
|
||||
|
||||
class OperationNotAllowed(BaseHttpException):
|
||||
states_code = 403
|
||||
detail = "403 Operation Is Not Allowed"
|
||||
|
||||
|
||||
class InvalidPassword(BaseHttpException):
|
||||
states_code = 403
|
||||
message = "403 Invalid Password"
|
@@ -12,7 +12,7 @@ class Following:
|
||||
queue = asyncio.Queue()
|
||||
|
||||
def __init__(self, kind, uid):
|
||||
self.kind = kind # author topic shout chat
|
||||
self.kind = kind # author topic shout community
|
||||
self.uid = uid
|
||||
|
||||
|
||||
|
@@ -26,6 +26,7 @@ class SearchService:
|
||||
"limit": limit,
|
||||
"offset": offset,
|
||||
}
|
||||
# FIXME: use elastic request here
|
||||
payload = await load_shouts_by(None, None, options)
|
||||
await redis.execute("SET", text, json.dumps(payload))
|
||||
return payload
|
||||
|
@@ -1,67 +0,0 @@
|
||||
import sys
|
||||
import uvicorn
|
||||
from uvicorn.main import logger
|
||||
|
||||
from settings import PORT
|
||||
|
||||
log_settings = {
|
||||
"version": 1,
|
||||
"disable_existing_loggers": True,
|
||||
"formatters": {
|
||||
"default": {
|
||||
"()": "uvicorn.logging.DefaultFormatter",
|
||||
"fmt": "%(levelprefix)s %(message)s",
|
||||
"use_colors": None,
|
||||
},
|
||||
"access": {
|
||||
"()": "uvicorn.logging.AccessFormatter",
|
||||
"fmt": '%(levelprefix)s %(client_addr)s - "%(request_line)s" %(status_code)s',
|
||||
},
|
||||
},
|
||||
"handlers": {
|
||||
"default": {
|
||||
"formatter": "default",
|
||||
"class": "logging.StreamHandler",
|
||||
"stream": "ext://sys.stderr",
|
||||
},
|
||||
"access": {
|
||||
"formatter": "access",
|
||||
"class": "logging.StreamHandler",
|
||||
"stream": "ext://sys.stdout",
|
||||
},
|
||||
},
|
||||
"loggers": {
|
||||
"uvicorn": {"handlers": ["default"], "level": "INFO"},
|
||||
"uvicorn.error": {"level": "INFO", "handlers": ["default"], "propagate": True},
|
||||
"uvicorn.access": {"handlers": ["access"], "level": "INFO", "propagate": False},
|
||||
},
|
||||
}
|
||||
|
||||
local_headers = [
|
||||
("Access-Control-Allow-Methods", "GET, POST, OPTIONS, HEAD"),
|
||||
("Access-Control-Allow-Origin", "https://localhost:3000"),
|
||||
(
|
||||
"Access-Control-Allow-Headers",
|
||||
"DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization",
|
||||
),
|
||||
("Access-Control-Expose-Headers", "Content-Length,Content-Range"),
|
||||
("Access-Control-Allow-Credentials", "true"),
|
||||
]
|
||||
|
||||
|
||||
def exception_handler(_et, exc, _tb):
|
||||
logger.error(..., exc_info=(type(exc), exc, exc.__traceback__))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.excepthook = exception_handler
|
||||
if "dev" in sys.argv:
|
||||
import os
|
||||
os.environ.set("MODE", "development")
|
||||
uvicorn.run(
|
||||
"main:app",
|
||||
host="0.0.0.0",
|
||||
port=PORT,
|
||||
proxy_headers=True,
|
||||
server_header=True
|
||||
)
|
@@ -1,14 +0,0 @@
|
||||
from os import environ
|
||||
|
||||
PORT = 8080
|
||||
DB_URL = (
|
||||
environ.get("DATABASE_URL")
|
||||
or environ.get("DB_URL")
|
||||
or "postgresql://postgres@localhost:5432/discoursio"
|
||||
)
|
||||
REDIS_URL = environ.get("REDIS_URL") or "redis://127.0.0.1"
|
||||
API_BASE = environ.get("API_BASE") or ""
|
||||
AUTH_URL = environ.get("AUTH_URL") or ""
|
||||
MODE = environ.get("MODE") or "production"
|
||||
SENTRY_DSN = environ.get("SENTRY_DSN")
|
||||
DEV_SERVER_PID_FILE_NAME = "dev-server.pid"
|
Reference in New Issue
Block a user