kopia lustrzana https://github.com/bugout-dev/moonstream
Migrated to fastapi router from subapps
rodzic
d23313c9d1
commit
79dab82972
|
@ -3,24 +3,46 @@ The Moonstream HTTP API
|
|||
"""
|
||||
import logging
|
||||
import time
|
||||
from typing import Dict
|
||||
|
||||
from fastapi import FastAPI
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
|
||||
from . import data
|
||||
from .routes.subscriptions import app as subscriptions_api
|
||||
from .routes.users import app as users_api
|
||||
from .routes.txinfo import app as txinfo_api
|
||||
from .routes.streams import app as streams_api
|
||||
from .routes.address_info import app as addressinfo_api
|
||||
from .routes.address_info import router as addressinfo_router
|
||||
from .routes.streams import router as streams_router
|
||||
from .routes.subscriptions import router as subscriptions_router
|
||||
from .routes.txinfo import router as txinfo_router
|
||||
from .routes.users import router as users_router
|
||||
|
||||
from .settings import ORIGINS
|
||||
from .middleware import BroodAuthMiddleware
|
||||
from .settings import DOCS_PATHS, DOCS_TARGET_PATH, ORIGINS
|
||||
from .version import MOONSTREAM_VERSION
|
||||
|
||||
logging.basicConfig(level=logging.INFO)
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
app = FastAPI(openapi_url=None)
|
||||
|
||||
tags_metadata = [
|
||||
{"name": "addressinfo", "description": "Address public information."},
|
||||
{"name": "labels", "description": "Addresses label information."},
|
||||
{"name": "streams", "description": "Operations with data stream and filters."},
|
||||
{"name": "subscriptions", "description": "Operations with subscriptions."},
|
||||
{"name": "time", "description": "Timestamp endpoints."},
|
||||
{"name": "tokens", "description": "Operations with user tokens."},
|
||||
{"name": "txinfo", "description": "Ethereum transactions info."},
|
||||
{"name": "users", "description": "Operations with users."},
|
||||
]
|
||||
|
||||
app = FastAPI(
|
||||
title=f"Moonstream API",
|
||||
description="Moonstream API endpoints.",
|
||||
version=MOONSTREAM_VERSION,
|
||||
openapi_tags=tags_metadata,
|
||||
openapi_url="/openapi.json",
|
||||
docs_url=None,
|
||||
redoc_url=f"/{DOCS_TARGET_PATH}",
|
||||
)
|
||||
|
||||
app.add_middleware(
|
||||
CORSMiddleware,
|
||||
|
@ -29,6 +51,24 @@ app.add_middleware(
|
|||
allow_methods=["*"],
|
||||
allow_headers=["*"],
|
||||
)
|
||||
whitelist_paths: Dict[str, str] = {}
|
||||
whitelist_paths.update(DOCS_PATHS)
|
||||
whitelist_paths.update(
|
||||
{
|
||||
"/ping": "GET",
|
||||
"/version": "GET",
|
||||
"/now": "GET",
|
||||
"/docs": "GET",
|
||||
"/openapi.json": "GET",
|
||||
"/streams/info": "GET",
|
||||
"/subscriptions/types": "GET",
|
||||
"/users": "POST",
|
||||
"/users/token": "POST",
|
||||
"/users/password/reset_initiate": "POST",
|
||||
"/users/password/reset_complete": "POST",
|
||||
}
|
||||
)
|
||||
app.add_middleware(BroodAuthMiddleware, whitelist=whitelist_paths)
|
||||
|
||||
|
||||
@app.get("/ping", response_model=data.PingResponse)
|
||||
|
@ -46,8 +86,10 @@ async def now_handler() -> data.NowResponse:
|
|||
return data.NowResponse(epoch_time=time.time())
|
||||
|
||||
|
||||
app.mount("/subscriptions", subscriptions_api)
|
||||
app.mount("/users", users_api)
|
||||
app.mount("/streams", streams_api)
|
||||
app.mount("/txinfo", txinfo_api)
|
||||
app.mount("/address_info", addressinfo_api)
|
||||
app.include_router(addressinfo_router)
|
||||
app.include_router(streams_router)
|
||||
app.include_router(subscriptions_router)
|
||||
app.include_router(txinfo_router)
|
||||
app.include_router(users_router)
|
||||
|
||||
# app.mount("/address_info", addressinfo_api)
|
||||
|
|
|
@ -1,50 +1,22 @@
|
|||
import logging
|
||||
from typing import Dict, List, Optional
|
||||
from typing import Optional
|
||||
|
||||
from sqlalchemy.sql.expression import true
|
||||
|
||||
from fastapi import FastAPI, Depends, Query
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
from fastapi import APIRouter, Depends, Query
|
||||
from moonstreamdb.db import yield_db_session
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from .. import actions
|
||||
from .. import data
|
||||
from ..middleware import BroodAuthMiddleware, MoonstreamHTTPException
|
||||
from ..settings import DOCS_TARGET_PATH, ORIGINS, DOCS_PATHS
|
||||
from ..version import MOONSTREAM_VERSION
|
||||
from ..middleware import MoonstreamHTTPException
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
tags_metadata = [
|
||||
{"name": "addressinfo", "description": "Address public information."},
|
||||
{"name": "labels", "description": "Addresses label information."},
|
||||
]
|
||||
|
||||
app = FastAPI(
|
||||
title=f"Moonstream users API.",
|
||||
description="User, token and password handlers.",
|
||||
version=MOONSTREAM_VERSION,
|
||||
openapi_tags=tags_metadata,
|
||||
openapi_url="/openapi.json",
|
||||
docs_url=None,
|
||||
redoc_url=f"/{DOCS_TARGET_PATH}",
|
||||
router = APIRouter(
|
||||
prefix="/users",
|
||||
)
|
||||
|
||||
app.add_middleware(
|
||||
CORSMiddleware,
|
||||
allow_origins=ORIGINS,
|
||||
allow_credentials=True,
|
||||
allow_methods=["*"],
|
||||
allow_headers=["*"],
|
||||
)
|
||||
|
||||
whitelist_paths: Dict[str, str] = {}
|
||||
whitelist_paths.update(DOCS_PATHS)
|
||||
app.add_middleware(BroodAuthMiddleware, whitelist=whitelist_paths)
|
||||
|
||||
|
||||
@app.get(
|
||||
@router.get(
|
||||
"/ethereum_blockchain",
|
||||
tags=["addressinfo"],
|
||||
response_model=data.EthereumAddressInfo,
|
||||
|
@ -57,9 +29,9 @@ async def addressinfo_handler(
|
|||
return response
|
||||
|
||||
|
||||
@app.get(
|
||||
@router.get(
|
||||
"/labels/ethereum_blockchain",
|
||||
tags=["labels bul"],
|
||||
tags=["labels"],
|
||||
response_model=data.AddressListLabelsResponse,
|
||||
)
|
||||
async def addresses_labels_bulk_handler(
|
||||
|
|
|
@ -5,14 +5,12 @@ import logging
|
|||
from typing import Any, Dict, List, Optional
|
||||
|
||||
from bugout.data import BugoutResource
|
||||
from fastapi import FastAPI, Request, Query, Depends
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
from fastapi import APIRouter, Request, Query, Depends
|
||||
from moonstreamdb import db
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
|
||||
from .. import data
|
||||
from ..middleware import BroodAuthMiddleware, MoonstreamHTTPException
|
||||
from ..middleware import MoonstreamHTTPException
|
||||
from ..providers import (
|
||||
ReceivingEventsException,
|
||||
event_providers,
|
||||
|
@ -22,47 +20,20 @@ from ..providers import (
|
|||
previous_event,
|
||||
)
|
||||
from ..settings import (
|
||||
DOCS_TARGET_PATH,
|
||||
MOONSTREAM_ADMIN_ACCESS_TOKEN,
|
||||
MOONSTREAM_DATA_JOURNAL_ID,
|
||||
ORIGINS,
|
||||
DOCS_PATHS,
|
||||
bugout_client as bc,
|
||||
BUGOUT_REQUEST_TIMEOUT_SECONDS,
|
||||
)
|
||||
from .. import stream_queries
|
||||
from .subscriptions import BUGOUT_RESOURCE_TYPE_SUBSCRIPTION
|
||||
from ..version import MOONSTREAM_VERSION
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
tags_metadata = [
|
||||
{"name": "streams", "description": "Operations with data stream and filters."},
|
||||
]
|
||||
|
||||
app = FastAPI(
|
||||
title=f"Moonstream streams API.",
|
||||
description="Streams endpoints.",
|
||||
version=MOONSTREAM_VERSION,
|
||||
openapi_tags=tags_metadata,
|
||||
openapi_url="/openapi.json",
|
||||
docs_url=None,
|
||||
redoc_url=f"/{DOCS_TARGET_PATH}",
|
||||
router = APIRouter(
|
||||
prefix="/streams",
|
||||
)
|
||||
|
||||
app.add_middleware(
|
||||
CORSMiddleware,
|
||||
allow_origins=ORIGINS,
|
||||
allow_credentials=True,
|
||||
allow_methods=["*"],
|
||||
allow_headers=["*"],
|
||||
)
|
||||
|
||||
whitelist_paths: Dict[str, str] = {"/streams/info": "GET"}
|
||||
whitelist_paths.update(DOCS_PATHS)
|
||||
whitelist_paths.update()
|
||||
app.add_middleware(BroodAuthMiddleware, whitelist=whitelist_paths)
|
||||
|
||||
|
||||
def get_user_subscriptions(token: str) -> Dict[str, List[BugoutResource]]:
|
||||
"""
|
||||
|
@ -89,7 +60,7 @@ def get_user_subscriptions(token: str) -> Dict[str, List[BugoutResource]]:
|
|||
return user_subscriptions
|
||||
|
||||
|
||||
@app.get("/info", tags=["streams"])
|
||||
@router.get("/info", tags=["streams"])
|
||||
async def info_handler() -> Dict[str, Any]:
|
||||
info = {
|
||||
event_type: {
|
||||
|
@ -102,7 +73,7 @@ async def info_handler() -> Dict[str, Any]:
|
|||
return info
|
||||
|
||||
|
||||
@app.get("/", tags=["streams"], response_model=data.GetEventsResponse)
|
||||
@router.get("/", tags=["streams"], response_model=data.GetEventsResponse)
|
||||
async def stream_handler(
|
||||
request: Request,
|
||||
q: str = Query(""),
|
||||
|
@ -159,7 +130,7 @@ async def stream_handler(
|
|||
return response
|
||||
|
||||
|
||||
@app.get("/latest", tags=["streams"])
|
||||
@router.get("/latest", tags=["streams"])
|
||||
async def latest_events_handler(
|
||||
request: Request, q=Query(""), db_session: Session = Depends(db.yield_db_session)
|
||||
) -> List[data.Event]:
|
||||
|
@ -201,7 +172,7 @@ async def latest_events_handler(
|
|||
return events
|
||||
|
||||
|
||||
@app.get("/next", tags=["stream"])
|
||||
@router.get("/next", tags=["stream"])
|
||||
async def next_event_handler(
|
||||
request: Request,
|
||||
q: str = Query(""),
|
||||
|
@ -256,7 +227,7 @@ async def next_event_handler(
|
|||
return event
|
||||
|
||||
|
||||
@app.get("/previous", tags=["stream"])
|
||||
@router.get("/previous", tags=["stream"])
|
||||
async def previous_event_handler(
|
||||
request: Request,
|
||||
q: str = Query(""),
|
||||
|
|
|
@ -2,60 +2,31 @@
|
|||
The Moonstream subscriptions HTTP API
|
||||
"""
|
||||
import logging
|
||||
from typing import Dict, List, Optional
|
||||
from typing import List, Optional
|
||||
|
||||
from bugout.data import BugoutResource, BugoutResources
|
||||
from bugout.exceptions import BugoutResponseException
|
||||
from fastapi import FastAPI, Request, Form
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
from fastapi import APIRouter, Request, Form
|
||||
|
||||
from ..admin import subscription_types
|
||||
from .. import data
|
||||
from ..middleware import BroodAuthMiddleware, MoonstreamHTTPException
|
||||
from ..middleware import MoonstreamHTTPException
|
||||
from ..reporter import reporter
|
||||
from ..settings import (
|
||||
DOCS_TARGET_PATH,
|
||||
DOCS_PATHS,
|
||||
MOONSTREAM_APPLICATION_ID,
|
||||
ORIGINS,
|
||||
bugout_client as bc,
|
||||
)
|
||||
from ..version import MOONSTREAM_VERSION
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
tags_metadata = [
|
||||
{"name": "subscriptions", "description": "Operations with subscriptions."},
|
||||
]
|
||||
|
||||
app = FastAPI(
|
||||
title=f"Moonstream subscriptions API.",
|
||||
description="User subscriptions endpoints.",
|
||||
version=MOONSTREAM_VERSION,
|
||||
openapi_tags=tags_metadata,
|
||||
openapi_url="/openapi.json",
|
||||
docs_url=None,
|
||||
redoc_url=f"/{DOCS_TARGET_PATH}",
|
||||
router = APIRouter(
|
||||
prefix="/subscriptions",
|
||||
)
|
||||
|
||||
app.add_middleware(
|
||||
CORSMiddleware,
|
||||
allow_origins=ORIGINS,
|
||||
allow_credentials=True,
|
||||
allow_methods=["*"],
|
||||
allow_headers=["*"],
|
||||
)
|
||||
|
||||
whitelist_paths: Dict[str, str] = {}
|
||||
whitelist_paths.update(DOCS_PATHS)
|
||||
whitelist_paths.update({"/subscriptions/types": "GET"})
|
||||
app.add_middleware(BroodAuthMiddleware, whitelist=whitelist_paths)
|
||||
|
||||
|
||||
BUGOUT_RESOURCE_TYPE_SUBSCRIPTION = "subscription"
|
||||
|
||||
|
||||
@app.post("/", tags=["subscriptions"], response_model=data.SubscriptionResourceData)
|
||||
@router.post("/", tags=["subscriptions"], response_model=data.SubscriptionResourceData)
|
||||
async def add_subscription_handler(
|
||||
request: Request, # subscription_data: data.CreateSubscriptionRequest = Body(...)
|
||||
address: str = Form(...),
|
||||
|
@ -118,7 +89,7 @@ async def add_subscription_handler(
|
|||
)
|
||||
|
||||
|
||||
@app.delete(
|
||||
@router.delete(
|
||||
"/{subscription_id}",
|
||||
tags=["subscriptions"],
|
||||
response_model=data.SubscriptionResourceData,
|
||||
|
@ -148,7 +119,7 @@ async def delete_subscription_handler(request: Request, subscription_id: str):
|
|||
)
|
||||
|
||||
|
||||
@app.get("/", tags=["subscriptions"], response_model=data.SubscriptionsListResponse)
|
||||
@router.get("/", tags=["subscriptions"], response_model=data.SubscriptionsListResponse)
|
||||
async def get_subscriptions_handler(request: Request) -> data.SubscriptionsListResponse:
|
||||
"""
|
||||
Get user's subscriptions.
|
||||
|
@ -186,7 +157,7 @@ async def get_subscriptions_handler(request: Request) -> data.SubscriptionsListR
|
|||
)
|
||||
|
||||
|
||||
@app.put(
|
||||
@router.put(
|
||||
"/{subscription_id}",
|
||||
tags=["subscriptions"],
|
||||
response_model=data.SubscriptionResourceData,
|
||||
|
@ -236,7 +207,7 @@ async def update_subscriptions_handler(
|
|||
)
|
||||
|
||||
|
||||
@app.get(
|
||||
@router.get(
|
||||
"/types", tags=["subscriptions"], response_model=data.SubscriptionTypesListResponse
|
||||
)
|
||||
async def list_subscription_types() -> data.SubscriptionTypesListResponse:
|
||||
|
|
|
@ -6,10 +6,8 @@ transactions, etc.) with side information and return objects that are better sui
|
|||
end users.
|
||||
"""
|
||||
import logging
|
||||
from typing import Dict
|
||||
|
||||
from fastapi import FastAPI, Depends
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
from fastapi import APIRouter, Depends
|
||||
from moonstreamdb.db import yield_db_session
|
||||
from moonstreamdb.models import EthereumAddress
|
||||
from sqlalchemy.orm import Session
|
||||
|
@ -17,43 +15,18 @@ from sqlalchemy.orm import Session
|
|||
from ..abi_decoder import decode_abi
|
||||
from .. import actions
|
||||
from .. import data
|
||||
from ..middleware import BroodAuthMiddleware
|
||||
from ..settings import DOCS_TARGET_PATH, ORIGINS, DOCS_PATHS
|
||||
from ..version import MOONSTREAM_VERSION
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
tags_metadata = [
|
||||
{"name": "txinfo", "description": "Ethereum transactions info."},
|
||||
]
|
||||
|
||||
app = FastAPI(
|
||||
title=f"Moonstream users API.",
|
||||
description="User, token and password handlers.",
|
||||
version=MOONSTREAM_VERSION,
|
||||
openapi_tags=tags_metadata,
|
||||
openapi_url="/openapi.json",
|
||||
docs_url=None,
|
||||
redoc_url=f"/{DOCS_TARGET_PATH}",
|
||||
router = APIRouter(
|
||||
prefix="/txinfo",
|
||||
)
|
||||
|
||||
app.add_middleware(
|
||||
CORSMiddleware,
|
||||
allow_origins=ORIGINS,
|
||||
allow_credentials=True,
|
||||
allow_methods=["*"],
|
||||
allow_headers=["*"],
|
||||
)
|
||||
|
||||
whitelist_paths: Dict[str, str] = {}
|
||||
whitelist_paths.update(DOCS_PATHS)
|
||||
app.add_middleware(BroodAuthMiddleware, whitelist=whitelist_paths)
|
||||
|
||||
|
||||
# TODO(zomglings): Factor out the enrichment logic into a separate action, because it may be useful
|
||||
# independently from serving API calls (e.g. data processing).
|
||||
# TODO(kompotkot): Re-organize function to be able handle each steps with exceptions.
|
||||
@app.post(
|
||||
@router.post(
|
||||
"/ethereum_blockchain",
|
||||
tags=["txinfo"],
|
||||
response_model=data.TxinfoEthereumBlockchainResponse,
|
||||
|
|
|
@ -7,68 +7,31 @@ import uuid
|
|||
|
||||
from bugout.data import BugoutToken, BugoutUser, BugoutResource
|
||||
from bugout.exceptions import BugoutResponseException
|
||||
|
||||
from fastapi import (
|
||||
APIRouter,
|
||||
Body,
|
||||
FastAPI,
|
||||
Form,
|
||||
Request,
|
||||
)
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
|
||||
from .. import data
|
||||
from ..middleware import BroodAuthMiddleware, MoonstreamHTTPException
|
||||
from ..middleware import MoonstreamHTTPException
|
||||
|
||||
from ..settings import (
|
||||
MOONSTREAM_APPLICATION_ID,
|
||||
DOCS_TARGET_PATH,
|
||||
ORIGINS,
|
||||
DOCS_PATHS,
|
||||
bugout_client as bc,
|
||||
BUGOUT_REQUEST_TIMEOUT_SECONDS,
|
||||
)
|
||||
from ..version import MOONSTREAM_VERSION
|
||||
from ..actions import create_onboarding_resource
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
tags_metadata = [
|
||||
{"name": "users", "description": "Operations with users."},
|
||||
{"name": "tokens", "description": "Operations with user tokens."},
|
||||
]
|
||||
|
||||
app = FastAPI(
|
||||
title=f"Moonstream users API.",
|
||||
description="User, token and password handlers.",
|
||||
version=MOONSTREAM_VERSION,
|
||||
openapi_tags=tags_metadata,
|
||||
openapi_url="/openapi.json",
|
||||
docs_url=None,
|
||||
redoc_url=f"/{DOCS_TARGET_PATH}",
|
||||
router = APIRouter(
|
||||
prefix="/users",
|
||||
)
|
||||
|
||||
app.add_middleware(
|
||||
CORSMiddleware,
|
||||
allow_origins=ORIGINS,
|
||||
allow_credentials=True,
|
||||
allow_methods=["*"],
|
||||
allow_headers=["*"],
|
||||
)
|
||||
|
||||
whitelist_paths: Dict[str, str] = {}
|
||||
whitelist_paths.update(DOCS_PATHS)
|
||||
whitelist_paths.update(
|
||||
{
|
||||
"/users": "POST",
|
||||
"/users/token": "POST",
|
||||
"/users/password/reset_initiate": "POST",
|
||||
"/users/password/reset_complete": "POST",
|
||||
}
|
||||
)
|
||||
app.add_middleware(BroodAuthMiddleware, whitelist=whitelist_paths)
|
||||
|
||||
|
||||
@app.post("/", tags=["users"], response_model=BugoutUser)
|
||||
@router.post("/", tags=["users"], response_model=BugoutUser)
|
||||
async def create_user_handler(
|
||||
username: str = Form(...), email: str = Form(...), password: str = Form(...)
|
||||
) -> BugoutUser:
|
||||
|
@ -86,13 +49,13 @@ async def create_user_handler(
|
|||
return user
|
||||
|
||||
|
||||
@app.get("/", tags=["users"], response_model=BugoutUser)
|
||||
@router.get("/", tags=["users"], response_model=BugoutUser)
|
||||
async def get_user_handler(request: Request) -> BugoutUser:
|
||||
user: BugoutUser = request.state.user
|
||||
return user
|
||||
|
||||
|
||||
@app.post("/password/reset_initiate", tags=["users"], response_model=Dict[str, Any])
|
||||
@router.post("/password/reset_initiate", tags=["users"], response_model=Dict[str, Any])
|
||||
async def restore_password_handler(email: str = Form(...)) -> Dict[str, Any]:
|
||||
try:
|
||||
response = bc.restore_password(email=email)
|
||||
|
@ -103,7 +66,7 @@ async def restore_password_handler(email: str = Form(...)) -> Dict[str, Any]:
|
|||
return response
|
||||
|
||||
|
||||
@app.post("/password/reset_complete", tags=["users"], response_model=BugoutUser)
|
||||
@router.post("/password/reset_complete", tags=["users"], response_model=BugoutUser)
|
||||
async def reset_password_handler(
|
||||
reset_id: str = Form(...), new_password: str = Form(...)
|
||||
) -> BugoutUser:
|
||||
|
@ -116,7 +79,7 @@ async def reset_password_handler(
|
|||
return response
|
||||
|
||||
|
||||
@app.post("/password/change", tags=["users"], response_model=BugoutUser)
|
||||
@router.post("/password/change", tags=["users"], response_model=BugoutUser)
|
||||
async def change_password_handler(
|
||||
request: Request, current_password: str = Form(...), new_password: str = Form(...)
|
||||
) -> BugoutUser:
|
||||
|
@ -132,7 +95,7 @@ async def change_password_handler(
|
|||
return user
|
||||
|
||||
|
||||
@app.delete("/", tags=["users"], response_model=BugoutUser)
|
||||
@router.delete("/", tags=["users"], response_model=BugoutUser)
|
||||
async def delete_user_handler(
|
||||
request: Request, password: str = Form(...)
|
||||
) -> BugoutUser:
|
||||
|
@ -147,7 +110,7 @@ async def delete_user_handler(
|
|||
return user
|
||||
|
||||
|
||||
@app.post("/token", tags=["tokens"], response_model=BugoutToken)
|
||||
@router.post("/token", tags=["tokens"], response_model=BugoutToken)
|
||||
async def login_handler(
|
||||
username: str = Form(...), password: str = Form(...)
|
||||
) -> BugoutToken:
|
||||
|
@ -166,7 +129,7 @@ async def login_handler(
|
|||
return token
|
||||
|
||||
|
||||
@app.delete("/token", tags=["tokens"], response_model=uuid.UUID)
|
||||
@router.delete("/token", tags=["tokens"], response_model=uuid.UUID)
|
||||
async def logout_handler(request: Request) -> uuid.UUID:
|
||||
token = request.state.token
|
||||
try:
|
||||
|
@ -178,7 +141,7 @@ async def logout_handler(request: Request) -> uuid.UUID:
|
|||
return token_id
|
||||
|
||||
|
||||
@app.post("/onboarding", tags=["users"], response_model=data.OnboardingState)
|
||||
@router.post("/onboarding", tags=["users"], response_model=data.OnboardingState)
|
||||
async def set_onboarding_state(
|
||||
request: Request,
|
||||
onboarding_data: data.OnboardingState = Body(...),
|
||||
|
@ -224,7 +187,7 @@ async def set_onboarding_state(
|
|||
return result
|
||||
|
||||
|
||||
@app.get("/onboarding", tags=["users"], response_model=data.OnboardingState)
|
||||
@router.get("/onboarding", tags=["users"], response_model=data.OnboardingState)
|
||||
async def get_onboarding_state(request: Request) -> data.OnboardingState:
|
||||
token = request.state.token
|
||||
try:
|
||||
|
@ -259,7 +222,7 @@ async def get_onboarding_state(request: Request) -> data.OnboardingState:
|
|||
return result
|
||||
|
||||
|
||||
@app.delete("/onboarding", tags=["users"], response_model=data.OnboardingState)
|
||||
@router.delete("/onboarding", tags=["users"], response_model=data.OnboardingState)
|
||||
async def delete_onboarding_state(request: Request) -> data.OnboardingState:
|
||||
token = request.state.token
|
||||
try:
|
||||
|
|
Ładowanie…
Reference in New Issue