Replies: 1 comment
-
Protocol we need: from typing import Protocol, Self, Callable, Any, Optional, Union, Set, List
# Should look all the usage of def get_server(self) and add them into the protocol for example on_event
class HttpServer(Protocol):
def __init__(self, **kwargs) -> None: ... # In the future can add common kwargs (extract them outside)
def add_middleware(self, middleware, **options) -> None: ... # middleware by the http server
def include_router(self, router: Router, prefix: str, tags: list, **options) -> None: ...
def add_api_route(self, router: Router, path: str, endpoint: Callable[..., Any], methods: Optional[Union[Set[str], List[str]]] )
class Router(Protocol):
routes: List['Route'] # Route is dynamic variable in http server ,in fastapi case WebRoute, Route
endpoint: Callable[..., Any]
def __init__(self, tags: List[str]) -> None: .... |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
I've talked on this advantage in previous discussion.
Here is mapping of all usage of FastAPI in the project. When we'll understand all of the instance usage we'll be able to replace those with python
Protocol
and use other web-framework as server engine.nest/common/route_resolver.py
nest/core/pynest_application.py
nest/core/pynest_factory.py
nest/core/decorators/class_based_view.py
nest/core/decorators/controller.py
nest/core/decorators/database.py
Now we can talk about possible protocol to replace and decouple the application.
Beta Was this translation helpful? Give feedback.
All reactions