-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Nikita Sokov
committed
Apr 17, 2024
1 parent
ae1cc8f
commit 6f92af8
Showing
102 changed files
with
2,703 additions
and
1 deletion.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
from fastapi import FastAPI | ||
from server.configuration.server import Server | ||
from fastapi.middleware.cors import CORSMiddleware | ||
|
||
|
||
def create_app(_=None) -> FastAPI: | ||
app = FastAPI(openapi_url="/auto_layout_dev/v1/openapi.json", docs_url="/auto_layout_dev/v1/docs") | ||
app.add_middleware(CORSMiddleware, allow_origins=["*"], allow_credentials=True, allow_methods=["*"], allow_headers=["*"]) | ||
return Server(app).get_app() |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from server.configuration.routes.routes import Routes | ||
from server.internal.routes import route | ||
from server.internal.routes import auth | ||
|
||
__routes__ = Routes(routes=(route.router, auth.router)) |
Binary file added
BIN
+361 Bytes
auto_layout/configuration/routes/__pycache__/__init__.cpython-310.pyc
Binary file not shown.
Binary file added
BIN
+674 Bytes
auto_layout/configuration/routes/__pycache__/routes.cpython-310.pyc
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
from fastapi import FastAPI | ||
from dataclasses import dataclass | ||
|
||
|
||
@dataclass(frozen=True) | ||
class Routes: | ||
|
||
routes: tuple | ||
|
||
def register_routes(self, app: FastAPI): | ||
for router in self.routes: | ||
app.include_router(router) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
from fastapi import FastAPI | ||
from server.configuration.routes import __routes__ | ||
|
||
|
||
class Server: | ||
|
||
__app: FastAPI | ||
|
||
def __init__(self, app: FastAPI): | ||
self.__app = app | ||
self.__register_routers(app=app) | ||
|
||
def get_app(self) -> FastAPI: | ||
|
||
return self.__app | ||
|
||
@staticmethod | ||
def __register_events(app): | ||
... | ||
|
||
@staticmethod | ||
def __register_routers(app): | ||
__routes__.register_routes(app) | ||
|
||
|
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
from fastapi import APIRouter, Depends | ||
from db.models import User | ||
from server.schemas.schemas import UserCreate, UserRead, UserUpdate | ||
from server.pkg.users import auth_backend, current_active_user, fastapi_users | ||
|
||
router = APIRouter( | ||
prefix="/auto_layout_dev/v1" | ||
) | ||
|
||
router.include_router( | ||
fastapi_users.get_auth_router(auth_backend), prefix="/auth/jwt", tags=["auth"] | ||
) | ||
router.include_router( | ||
fastapi_users.get_register_router(UserRead, UserCreate), | ||
prefix="/auth", | ||
tags=["auth"], | ||
) | ||
router.include_router( | ||
fastapi_users.get_reset_password_router(), | ||
prefix="/auth", | ||
tags=["auth"], | ||
) | ||
router.include_router( | ||
fastapi_users.get_verify_router(UserRead), | ||
prefix="/auth", | ||
tags=["auth"], | ||
) | ||
router.include_router( | ||
fastapi_users.get_users_router(UserRead, UserUpdate), | ||
prefix="/users", | ||
tags=["users"], | ||
) | ||
|
||
|
||
@router.get("/authenticated-route") | ||
async def authenticated_route(user: User = Depends(current_active_user)): | ||
return "ok" |
Oops, something went wrong.