MCPcopy Create free account
hub / github.com/etesync/server / create_application

Function create_application

etebase_server/fastapi/main.py:21–91  ·  view source on GitHub ↗
(prefix="", middlewares=[])

Source from the content-addressed store, hash-verified

19
20
21def create_application(prefix="", middlewares=[]):
22 app = FastAPI(
23 title="Etebase",
24 description="The Etebase server API documentation",
25 externalDocs={
26 "url": "https://docs.etebase.com",
27 "description": "Docs about the API specifications and clients.",
28 },
29 # FIXME: version="2.5.0",
30 )
31 VERSION = "v1" # noqa: N806
32 BASE_PATH = f"{prefix}/api/{VERSION}" # noqa: N806
33 COLLECTION_UID_MARKER = "{collection_uid}" # noqa: N806
34 app.include_router(authentication_router, prefix=f"{BASE_PATH}/authentication", tags=["authentication"])
35 app.include_router(collection_router, prefix=f"{BASE_PATH}/collection", tags=["collection"])
36 app.include_router(item_router, prefix=f"{BASE_PATH}/collection/{COLLECTION_UID_MARKER}", tags=["item"])
37 app.include_router(member_router, prefix=f"{BASE_PATH}/collection/{COLLECTION_UID_MARKER}", tags=["member"])
38 app.include_router(
39 invitation_incoming_router, prefix=f"{BASE_PATH}/invitation/incoming", tags=["incoming invitation"]
40 )
41 app.include_router(
42 invitation_outgoing_router, prefix=f"{BASE_PATH}/invitation/outgoing", tags=["outgoing invitation"]
43 )
44 app.include_router(websocket_router, prefix=f"{BASE_PATH}/ws", tags=["websocket"])
45
46 if settings.DEBUG:
47 from .routers.test_reset_view import test_reset_view_router
48
49 app.include_router(test_reset_view_router, prefix=f"{BASE_PATH}/test/authentication")
50
51 app.add_middleware(
52 CORSMiddleware,
53 allow_origin_regex="https?://.*",
54 allow_credentials=True,
55 allow_methods=["*"],
56 allow_headers=["*"],
57 )
58 app.add_middleware(TrustedHostMiddleware, allowed_hosts=settings.ALLOWED_HOSTS)
59
60 for middleware in middlewares:
61 app.add_middleware(middleware)
62
63 @app.on_event("startup")
64 async def on_startup() -> None:
65 from .redis import redisw
66
67 await redisw.setup()
68
69 @app.on_event("shutdown")
70 async def on_shutdown():
71 from .redis import redisw
72
73 await redisw.close()
74
75 @app.exception_handler(CustomHttpException)
76 async def custom_exception_handler(request: Request, exc: CustomHttpException):
77 return MsgpackResponse(status_code=exc.status_code, content=exc.as_dict)
78

Callers 2

create_applicationFunction · 0.90
asgi.pyFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected