Skip to content

Commit

Permalink
Restracture api container to have the same file structure as local st…
Browse files Browse the repository at this point in the history
…ructure
  • Loading branch information
Maksymilian-Plywaczyk committed Nov 20, 2023
1 parent 990b9ae commit a765969
Show file tree
Hide file tree
Showing 11 changed files with 25 additions and 24 deletions.
File renamed without changes.
3 changes: 2 additions & 1 deletion api/src/api/models.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"""Describes models used in the project"""
from typing import List, Union

from api.databases import Base
from geoalchemy2 import Geography
from sqlalchemy import (
Boolean,
Expand All @@ -18,6 +17,8 @@
from sqlalchemy.orm import Mapped, mapped_column, relationship
from sqlalchemy.types import LargeBinary

from .databases import Base


class City(Base):
"""City model"""
Expand Down
2 changes: 1 addition & 1 deletion api/src/auth/config.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from api.config import EMAIL, EMAIL_PASSWORD
from fastapi_mail import ConnectionConfig
from src.api.config import EMAIL, EMAIL_PASSWORD

conf = ConnectionConfig(
MAIL_USERNAME=EMAIL,
Expand Down
10 changes: 5 additions & 5 deletions api/src/auth/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

from fastapi import Depends, Request

from api.config import SECRET
from auth.config import conf
from auth.exceptions import NicknameAlreadyTaken
from auth.models import User, get_user_db
from auth.schemas import CredentialsSchema, EmailSchema
from fastapi_mail import FastMail, MessageSchema, MessageType
from fastapi_users import BaseUserManager, IntegerIDMixin, exceptions, models, schemas
from sqlalchemy import Integer
from sqlalchemy.exc import IntegrityError
from src.api.config import SECRET
from src.auth.config import conf
from src.auth.exceptions import NicknameAlreadyTaken
from src.auth.models import User, get_user_db
from src.auth.schemas import CredentialsSchema, EmailSchema
from starlette.responses import JSONResponse


Expand Down
2 changes: 1 addition & 1 deletion api/src/auth/models.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from fastapi import Depends

from api.databases import Base, get_async_session
from fastapi_users.db import SQLAlchemyBaseUserTable, SQLAlchemyUserDatabase
from sqlalchemy import Column, Integer, String
from sqlalchemy.ext.asyncio import AsyncSession
from sqlalchemy.sql.expression import text
from sqlalchemy.sql.sqltypes import TIMESTAMP
from src.api.databases import Base, get_async_session


class User(SQLAlchemyBaseUserTable[int], Base):
Expand Down
4 changes: 2 additions & 2 deletions api/src/auth/router/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from fastapi import APIRouter

from auth.schemas import UserCreate, UserOut, UserRead, UserUpdate
from auth.utils import auth_backend, fastapi_users
from src.auth.schemas import UserCreate, UserOut, UserRead, UserUpdate
from src.auth.utils import auth_backend, fastapi_users

router = APIRouter(prefix="/api", tags=["auth"])

Expand Down
4 changes: 2 additions & 2 deletions api/src/auth/router/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
from fastapi import APIRouter, Depends, HTTPException, Request, status
from fastapi.openapi.models import Response

from auth.manager import UserManager
from auth.schemas import CredentialsSchema
from fastapi_users import models
from fastapi_users.authentication import AuthenticationBackend, Authenticator, Strategy
from fastapi_users.manager import UserManagerDependency
from fastapi_users.openapi import OpenAPIResponseType
from fastapi_users.router.common import ErrorCode, ErrorModel
from src.auth.manager import UserManager
from src.auth.schemas import CredentialsSchema


def get_auth_router(
Expand Down
6 changes: 3 additions & 3 deletions api/src/auth/utils.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
from fastapi import APIRouter

from api.config import SECRET
from auth.manager import get_user_manager
from auth.models import User
from fastapi_users import FastAPIUsers
from fastapi_users.authentication import (
AuthenticationBackend,
BearerTransport,
JWTStrategy,
)
from sqlalchemy import Integer
from src.api.config import SECRET
from src.auth.manager import get_user_manager
from src.auth.models import User

from .router.auth import get_auth_router

Expand Down
12 changes: 6 additions & 6 deletions api/src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware

from api.config import CORS_ORIGINS
from api.databases import create_db_and_tables, engine
from auth import router
from src.api.config import CORS_ORIGINS
from src.api.databases import create_db_and_tables, engine
from src.auth import router

app = FastAPI()

Expand All @@ -19,9 +19,9 @@
)


@app.on_event("startup")
async def init_tables():
await create_db_and_tables()
# @app.on_event("startup")
# async def init_tables():
# await create_db_and_tables()


# @app.on_event("startup")
Expand Down
2 changes: 1 addition & 1 deletion deployment/Dockerfile.backend
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ COPY ./api/requirements/docker.txt ./requirements.txt
RUN pip install --no-cache-dir --root-user-action=ignore --upgrade pip && \
pip install --no-cache-dir --root-user-action=ignore -r requirements.txt

CMD ["sh","-c","alembic upgrade head && uvicorn main:app --host 0.0.0.0 --port 8000 --reload"]
CMD ["sh","-c","alembic upgrade head && uvicorn src.main:app --host 0.0.0.0 --port 8000 --reload"]
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ services:
condition: service_healthy
restart: unless-stopped
volumes:
- ./api/src:/api/
- ./api/src:/api/src
- ./api/migrations:/api/migrations
- ./api/src/alembic.ini:/api/alembic.ini
- ./api/alembic.ini:/api/alembic.ini

ui:
build:
Expand Down

0 comments on commit a765969

Please sign in to comment.