Skip to content

Commit 637f961

Browse files
committed
.
1 parent 31769e3 commit 637f961

File tree

6 files changed

+19
-23
lines changed

6 files changed

+19
-23
lines changed

app/api/anotations.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
Dependencies
2+
Dependency annotations
33
"""
44

55
from typing import Annotated

app/core/db.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
Database
33
"""
44

5-
from sqlalchemy.ext.asyncio import (AsyncEngine, async_sessionmaker,
6-
create_async_engine)
5+
from sqlalchemy.ext.asyncio import AsyncEngine, async_sessionmaker, create_async_engine
76
from sqlmodel.ext.asyncio.session import AsyncSession
87

98
from app import repositories as repos

app/core/deps.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from fastapi.security import APIKeyHeader
99

1010
from app.core.db import Database, SessionLocal
11-
from app.core.logic import Logic
11+
from app.logic import Logic
1212
from app.core.security import Security
1313
from app.models.user import User
1414

@@ -30,7 +30,7 @@ async def get_logic(
3030

3131

3232
async def get_current_user(
33-
token: Annotated[str, Depends(APIKeyHeader(name='access-token'))],
33+
token: Annotated[str, Depends(APIKeyHeader(name="access-token"))],
3434
logic: Annotated[Logic, Depends(get_logic)],
3535
) -> User | None:
3636
return await logic.users.retrieve_by_token(token)

app/core/exps.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,11 @@
55
from fastapi import HTTPException, status
66

77
# Users
8-
USER_EXISTS = HTTPException(status.HTTP_409_CONFLICT, 'User is already taken.')
9-
USER_NOT_FOUND = HTTPException(status.HTTP_404_NOT_FOUND, 'User not found.')
8+
USER_EXISTS = HTTPException(status.HTTP_409_CONFLICT, "User is already taken.")
9+
USER_NOT_FOUND = HTTPException(status.HTTP_404_NOT_FOUND, "User not found.")
1010
USER_IS_CORRECT = HTTPException(
11-
status.HTTP_401_UNAUTHORIZED, 'User is correct'
12-
)
11+
status.HTTP_401_UNAUTHORIZED, "User is correct.")
1312

1413
# Tokens
15-
TOKEN_INVALID = HTTPException(status.HTTP_401_UNAUTHORIZED, 'Invalid token')
16-
TOKEN_EXPIRED = HTTPException(status.HTTP_401_UNAUTHORIZED, 'Token expired')
14+
TOKEN_INVALID = HTTPException(status.HTTP_401_UNAUTHORIZED, "Invalid token.")
15+
TOKEN_EXPIRED = HTTPException(status.HTTP_401_UNAUTHORIZED, "Token expired.")

app/core/logic.py

Lines changed: 0 additions & 11 deletions
This file was deleted.

app/logic/__init__.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
from app.core.db import Database
2+
from app.core.security import Security
3+
14
from .users import Users
25

3-
__all__ = ['Users']
6+
7+
class Logic:
8+
def __init__(self, db: Database, security: Security):
9+
self.users = Users(db, security)
10+
11+
12+
__all__ = ["Logic"]

0 commit comments

Comments
 (0)