update endpoints
This commit is contained in:
@@ -5,7 +5,7 @@ https://ru.homyk.space {
|
||||
encode gzip
|
||||
|
||||
# --- API ---
|
||||
handle_path /api/* {
|
||||
handle /api/* {
|
||||
reverse_proxy backend:{$PORT}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ from fastapi.security import HTTPBearer, HTTPAuthorizationCredentials
|
||||
import server.backend.schema.pydantic as pydantic
|
||||
import server.backend.database.db as db
|
||||
from server.backend.auth.JWT import signJWT, decodeJWT
|
||||
api = FastAPI(openapi_url="/api/openapi.json")
|
||||
api = FastAPI(openapi_url="/api/openapi.json",docs_url="/api/docs", redoc_url="/api/redoc")
|
||||
security = HTTPBearer()
|
||||
|
||||
async def get_current_user(credentials: HTTPAuthorizationCredentials = Depends(security)):
|
||||
@@ -20,7 +20,7 @@ async def check_roles(user=Depends(get_current_user)):
|
||||
raise HTTPException(status_code=status.HTTP_403_FORBIDDEN, detail="Access denied")
|
||||
return user
|
||||
|
||||
@api.post("/update", response_model=pydantic.UserUpdate)
|
||||
@api.post("/api/update", response_model=pydantic.UserUpdate)
|
||||
async def update_user(data: pydantic.UserUpdate, user=Depends(get_current_user)):
|
||||
user_check = await db.list_user(user["user_id"])
|
||||
if not user_check:
|
||||
@@ -43,7 +43,7 @@ async def update_user(data: pydantic.UserUpdate, user=Depends(get_current_user))
|
||||
updated_data = await db.update_user(updated_data)
|
||||
return updated_data
|
||||
|
||||
@api.post("/create", response_model=pydantic.UserAccess)
|
||||
@api.post("/api/create", response_model=pydantic.UserAccess)
|
||||
async def create_user(user_info: pydantic.UserCreate,user=Depends(check_roles)):
|
||||
user = await db.create_user(user_info)
|
||||
if user == None:
|
||||
@@ -53,12 +53,12 @@ async def create_user(user_info: pydantic.UserCreate,user=Depends(check_roles)):
|
||||
)
|
||||
return user_info
|
||||
|
||||
@api.get("/list")
|
||||
@api.get("/api/list")
|
||||
async def list_users(user=Depends(check_roles)):
|
||||
list_of_users = await db.list_users()
|
||||
return list_of_users
|
||||
|
||||
@api.post("/auth",response_model=pydantic.Token)
|
||||
@api.post("/api/auth",response_model=pydantic.Token)
|
||||
async def auth(code:pydantic.UserAccess):
|
||||
login = await db.login_user(code)
|
||||
if login == None:
|
||||
|
||||
Reference in New Issue
Block a user