from fastapi import APIRouter, UploadFile, File, Form, HTTPException from app.services.skin import SkinService from app.services.auth import AuthService router = APIRouter(tags=["Skins"]) @router.post("/user/{username}/skin") async def set_skin( username: str, skin_file: UploadFile = File(...), skin_model: str = Form("classic"), accessToken: str = Form(...), clientToken: str = Form(...) ): # Validate the token is_valid = await AuthService().validate(accessToken, clientToken) if not is_valid: raise HTTPException(status_code=401, detail="Invalid authentication tokens") return await SkinService().set_skin(username, skin_file, skin_model) @router.delete("/user/{username}/skin") async def remove_skin( username: str, accessToken: str, clientToken: str ): # Validate the token is_valid = await AuthService().validate(accessToken, clientToken) if not is_valid: raise HTTPException(status_code=401, detail="Invalid authentication tokens") return await SkinService().remove_skin(username)