Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikita Sokov committed Apr 17, 2024
1 parent ae1cc8f commit 6f92af8
Show file tree
Hide file tree
Showing 102 changed files with 2,703 additions and 1 deletion.
Binary file added .DS_Store
Binary file not shown.
1 change: 0 additions & 1 deletion README.md

This file was deleted.

Binary file added auto_layout/.DS_Store
Binary file not shown.
9 changes: 9 additions & 0 deletions auto_layout/__init__.py
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 added auto_layout/configuration/.DS_Store
Binary file not shown.
5 changes: 5 additions & 0 deletions auto_layout/configuration/routes/__init__.py
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 not shown.
Binary file not shown.
12 changes: 12 additions & 0 deletions auto_layout/configuration/routes/routes.py
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)
25 changes: 25 additions & 0 deletions auto_layout/configuration/server.py
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.
37 changes: 37 additions & 0 deletions auto_layout/internal/routes/auth.py
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"
Loading

0 comments on commit 6f92af8

Please sign in to comment.