-
Notifications
You must be signed in to change notification settings - Fork 59
Develop Decouple Issue #99 #100
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 2 commits
50917f7
9e9da03
417821f
92edba7
921db66
fd38152
a7da700
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| from fastapi import APIRouter as FastAPIRouter | ||
| from fastapi import FastAPI as FastAPIApp |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| from .app import App | ||
| from .router import Router | ||
| from .route import Route, RouteProtocol |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| from typing import Protocol, TypeVar, List, Optional, Iterable | ||
|
|
||
| from nest.engine.proto.router import Router | ||
| from nest.engine.proto.route import Route | ||
| from nest.engine.types import Endpoint | ||
|
|
||
| Middleware = TypeVar('Middleware') | ||
|
|
||
|
|
||
| class AppProtocol(Protocol): | ||
|
|
||
| def __init__(self, **kwargs) -> None: ... | ||
| def add_middleware(self, middleware: Middleware, **options) -> None: ... | ||
| def include_router(self, router: Router, *, prefix: str = "", tags: Optional[List[str]] = None, **options) -> None: ... | ||
| def add_api_route(self, *, path: str, endpoint: Endpoint, methods: Optional[Iterable[str]]) -> None: ... | ||
| @property | ||
| def routes(self) -> List[Route]: ... | ||
|
|
||
|
|
||
| App = TypeVar('App', bound=AppProtocol) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| from typing import Protocol, TypeVar, runtime_checkable | ||
|
|
||
| from nest.engine.types import Endpoint | ||
|
|
||
|
|
||
| @runtime_checkable | ||
| class RouteProtocol(Protocol): | ||
| endpoint: Endpoint | ||
| """Function representing the route endpoint logic.""" | ||
|
|
||
|
|
||
| Route = TypeVar('Route', bound=RouteProtocol) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| from typing import Protocol, List, Optional, TypeVar, Iterable, runtime_checkable | ||
| from .route import Route | ||
| from ..types import Endpoint | ||
|
|
||
|
|
||
| @runtime_checkable | ||
| class RouterProtocol(Protocol): | ||
| routes: List[Route] | ||
| def __init__(self, tags: Optional[List[str]] = None, **kwargs) -> None: ... | ||
| def include_router(self, router: 'RouterProtocol', **kwargs) -> None: ... | ||
| def add_api_route(self, *, path: str, endpoint: Endpoint, methods: Optional[Iterable[str]]) -> None: ... | ||
|
|
||
|
|
||
| Router = TypeVar('Router', bound=RouterProtocol) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| from typing import Callable, TypeAlias, Any | ||
|
||
|
|
||
| Endpoint: TypeAlias = Callable[..., Any] | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to think of a way to remove router intilization.
Could be done by creating abs for controller and make instace for fastapi/others.
instead of