Skip to content

Commit

Permalink
update makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
ProFastCode committed Aug 10, 2024
1 parent 0f17886 commit 32af63d
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 14 deletions.
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ help:
@echo " dev Start the app"
@echo " ref Reformat code"
@echo " req pyproject.toml >> requirements.txt"
@echo " test Start the pytest"
@echo " migrate Alembic migrate database"
@echo " generate Alembic generate database"
@echo " generate Alembic generate database"


.PHONY: blue
Expand All @@ -30,6 +31,10 @@ dev:
req:
poetry export --without-hashes --without-urls | awk '{ print $1 }' FS=';' > requirements.txt

.PHONY: test
test:
poetry run pytest tests

.PHONY: migrate
migrate:
poetry run alembic upgrade head
Expand Down
20 changes: 10 additions & 10 deletions app/core/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,22 @@

class Settings(BaseSettings):
model_config = SettingsConfigDict(
env_file=".env", env_file_encoding="utf-8", case_sensitive=True
env_file='.env', env_file_encoding='utf-8', case_sensitive=True
)

# APP
APP_PATH: str = "/api"
APP_TITLE: str = "FastAPI Template"
APP_VERSION: str = "beta"
APP_SECRET_KEY: str = "abc"
APP_PATH: str = '/api'
APP_TITLE: str = 'FastAPI Template'
APP_VERSION: str = 'beta'
APP_SECRET_KEY: str = 'abc'

# DATABASE
DB: str = "postgres"
DB_HOST: str = "localhost"
DB: str = 'postgres'
DB_HOST: str = 'localhost'
DB_PORT: int = 5432
DB_USER: str = ""
DB_PASSWORD: str = ""
DB_DRIVERNAME: str = "postgresql+asyncpg"
DB_USER: str = ''
DB_PASSWORD: str = ''
DB_DRIVERNAME: str = 'postgresql+asyncpg'

@property
def db_dsn(self) -> str:
Expand Down
2 changes: 1 addition & 1 deletion app/logic/logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ def __init__(self, db: Database):

@classmethod
@asynccontextmanager
async def create(cls) -> AsyncGenerator["Logic", None]:
async def create(cls) -> AsyncGenerator['Logic', None]:
async with Database() as db:
yield cls(db)
8 changes: 6 additions & 2 deletions app/logic/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@


class Users:
def __init__(self, logic: "Logic"):
def __init__(self, logic: 'Logic'):
self.logic = logic

async def create(self, data: UserCreate) -> User | None:
Expand All @@ -21,7 +21,11 @@ async def create(self, data: UserCreate) -> User | None:

async def retrieve_by_token(self, token: str) -> User | None:
payload = self.logic.security.jwt.decode_token(token)
if not (user := await self.logic.db.user.retrieve_one(ident=payload.get("id"))):
if not (
user := await self.logic.db.user.retrieve_one(
ident=payload.get('id')
)
):
raise exps.UserNotFoundException()
return user

Expand Down

0 comments on commit 32af63d

Please sign in to comment.