Skip to content

Commit

Permalink
feat(server): add user information endpoint
Browse files Browse the repository at this point in the history
- Added a new endpoint `/user/information` to retrieve user information.
- The endpoint requires the `current_token` parameter for authorization.
- If successful, the result is returned as a model dump.
  • Loading branch information
sudoskys committed Feb 8, 2024
1 parent d1d2e2a commit 9470966
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/novelai_python/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

from .credential import JwtCredential, SecretStr
from .sdk.ai.generate_image import GenerateImageInfer
from .sdk.user.information import Information
from .sdk.user.login import Login
from .sdk.user.subscription import Subscription

Expand Down Expand Up @@ -55,6 +56,23 @@ async def login(
return JSONResponse(status_code=500, content=e.__dict__)


@app.get("/user/information")
async def information(
current_token: str = Depends(get_current_token)
):
"""
用户信息
:param current_token: Authorization
:return:
"""
try:
_result = await Information().request(session=get_session(current_token))
return _result.model_dump()
except Exception as e:
logger.exception(e)
return JSONResponse(status_code=500, content=e.__dict__)


@app.get("/user/subscription")
async def subscription(
current_token: str = Depends(get_current_token)
Expand Down

0 comments on commit 9470966

Please sign in to comment.