mirror of
https://github.com/etesync/server
synced 2024-11-22 08:48:07 +00:00
Change how we create applications.
This commit is contained in:
parent
65cd722616
commit
c1f171bde0
@ -12,28 +12,30 @@ from .member import member_router
|
|||||||
from .invitation import invitation_incoming_router, invitation_outgoing_router
|
from .invitation import invitation_incoming_router, invitation_outgoing_router
|
||||||
from .msgpack import MsgpackResponse
|
from .msgpack import MsgpackResponse
|
||||||
|
|
||||||
app = FastAPI()
|
def create_application(prefix=""):
|
||||||
VERSION = "v1"
|
app = FastAPI()
|
||||||
BASE_PATH = f"/api/{VERSION}"
|
VERSION = "v1"
|
||||||
COLLECTION_UID_MARKER = "{collection_uid}"
|
BASE_PATH = f"{prefix}/api/{VERSION}"
|
||||||
app.include_router(authentication_router, prefix=f"{BASE_PATH}/authentication", tags=["authentication"])
|
COLLECTION_UID_MARKER = "{collection_uid}"
|
||||||
app.include_router(collection_router, prefix=f"{BASE_PATH}/collection", tags=["collection"])
|
app.include_router(authentication_router, prefix=f"{BASE_PATH}/authentication", tags=["authentication"])
|
||||||
app.include_router(item_router, prefix=f"{BASE_PATH}/collection/{COLLECTION_UID_MARKER}", tags=["item"])
|
app.include_router(collection_router, prefix=f"{BASE_PATH}/collection", tags=["collection"])
|
||||||
app.include_router(member_router, prefix=f"{BASE_PATH}/collection/{COLLECTION_UID_MARKER}", tags=["member"])
|
app.include_router(item_router, prefix=f"{BASE_PATH}/collection/{COLLECTION_UID_MARKER}", tags=["item"])
|
||||||
app.include_router(invitation_incoming_router, prefix=f"{BASE_PATH}/invitation/incoming", tags=["incoming invitation"])
|
app.include_router(member_router, prefix=f"{BASE_PATH}/collection/{COLLECTION_UID_MARKER}", tags=["member"])
|
||||||
app.include_router(invitation_outgoing_router, prefix=f"{BASE_PATH}/invitation/outgoing", tags=["outgoing invitation"])
|
app.include_router(invitation_incoming_router, prefix=f"{BASE_PATH}/invitation/incoming", tags=["incoming invitation"])
|
||||||
|
app.include_router(invitation_outgoing_router, prefix=f"{BASE_PATH}/invitation/outgoing", tags=["outgoing invitation"])
|
||||||
|
|
||||||
if settings.DEBUG:
|
if settings.DEBUG:
|
||||||
from etebase_fastapi.test_reset_view import test_reset_view_router
|
from etebase_fastapi.test_reset_view import test_reset_view_router
|
||||||
|
|
||||||
app.include_router(test_reset_view_router, prefix=f"{BASE_PATH}/test/authentication")
|
app.include_router(test_reset_view_router, prefix=f"{BASE_PATH}/test/authentication")
|
||||||
|
|
||||||
app.add_middleware(
|
app.add_middleware(
|
||||||
CORSMiddleware, allow_origin_regex="https?://.*", allow_credentials=True, allow_methods=["*"], allow_headers=["*"]
|
CORSMiddleware, allow_origin_regex="https?://.*", allow_credentials=True, allow_methods=["*"], allow_headers=["*"]
|
||||||
)
|
)
|
||||||
app.add_middleware(TrustedHostMiddleware, allowed_hosts=settings.ALLOWED_HOSTS)
|
app.add_middleware(TrustedHostMiddleware, allowed_hosts=settings.ALLOWED_HOSTS)
|
||||||
|
|
||||||
|
|
||||||
@app.exception_handler(CustomHttpException)
|
@app.exception_handler(CustomHttpException)
|
||||||
async def custom_exception_handler(request: Request, exc: CustomHttpException):
|
async def custom_exception_handler(request: Request, exc: CustomHttpException):
|
||||||
return MsgpackResponse(status_code=exc.status_code, content=exc.as_dict)
|
return MsgpackResponse(status_code=exc.status_code, content=exc.as_dict)
|
||||||
|
return app
|
||||||
|
@ -7,7 +7,9 @@ django_application = get_asgi_application()
|
|||||||
|
|
||||||
|
|
||||||
def create_application():
|
def create_application():
|
||||||
from etebase_fastapi.main import app
|
from etebase_fastapi.main import create_application
|
||||||
|
|
||||||
|
app = create_application()
|
||||||
|
|
||||||
app.mount("/", django_application)
|
app.mount("/", django_application)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user