Skip to content

Commit 304c936

Browse files
Merge branch 'fastapi:master' into alembic-autogenerate-issue
2 parents 8c76243 + 6efd3ba commit 304c936

File tree

94 files changed

+8252
-6633
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

94 files changed

+8252
-6633
lines changed

.github/workflows/generate-client.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
with:
2828
python-version: "3.10"
2929
- name: Install uv
30-
uses: astral-sh/setup-uv@v3
30+
uses: astral-sh/setup-uv@v5
3131
with:
3232
version: "0.4.15"
3333
enable-cache: true
@@ -39,6 +39,10 @@ jobs:
3939
- run: uv run bash scripts/generate-client.sh
4040
env:
4141
VIRTUAL_ENV: backend/.venv
42+
ENVIRONMENT: production
43+
SECRET_KEY: just-for-generating-client
44+
POSTGRES_PASSWORD: just-for-generating-client
45+
FIRST_SUPERUSER_PASSWORD: just-for-generating-client
4246
- name: Add changes to git
4347
run: |
4448
git config --local user.email "[email protected]"

.github/workflows/lint-backend.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
with:
2121
python-version: "3.10"
2222
- name: Install uv
23-
uses: astral-sh/setup-uv@v3
23+
uses: astral-sh/setup-uv@v5
2424
with:
2525
version: "0.4.15"
2626
enable-cache: true

.github/workflows/playwright.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,18 @@ jobs:
5959
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.debug_enabled == 'true' }}
6060
with:
6161
limit-access-to-actor: true
62+
- name: Install uv
63+
uses: astral-sh/setup-uv@v5
64+
with:
65+
version: "0.4.15"
66+
enable-cache: true
67+
- run: uv sync
68+
working-directory: backend
69+
- run: npm ci
70+
working-directory: frontend
71+
- run: uv run bash scripts/generate-client.sh
72+
env:
73+
VIRTUAL_ENV: backend/.venv
6274
- run: docker compose build
6375
- run: docker compose down -v --remove-orphans
6476
- name: Run Playwright tests

.github/workflows/test-backend.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
with:
2121
python-version: "3.10"
2222
- name: Install uv
23-
uses: astral-sh/setup-uv@v3
23+
uses: astral-sh/setup-uv@v5
2424
with:
2525
version: "0.4.15"
2626
enable-cache: true

backend/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ WORKDIR /app/
66

77
# Install uv
88
# Ref: https://docs.astral.sh/uv/guides/integration/docker/#installing-uv
9-
COPY --from=ghcr.io/astral-sh/uv:0.4.15 /uv /bin/uv
9+
COPY --from=ghcr.io/astral-sh/uv:0.5.11 /uv /uvx /bin/
1010

1111
# Place executables in the environment at the front of the path
1212
# Ref: https://docs.astral.sh/uv/guides/integration/docker/#using-the-environment

backend/app/api/main.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
from fastapi import APIRouter
22

3-
from app.api.routes import items, login, users, utils
3+
from app.api.routes import items, login, private, users, utils
4+
from app.core.config import settings
45

56
api_router = APIRouter()
6-
api_router.include_router(login.router, tags=["login"])
7-
api_router.include_router(users.router, prefix="/users", tags=["users"])
8-
api_router.include_router(utils.router, prefix="/utils", tags=["utils"])
9-
api_router.include_router(items.router, prefix="/items", tags=["items"])
7+
api_router.include_router(login.router)
8+
api_router.include_router(users.router)
9+
api_router.include_router(utils.router)
10+
api_router.include_router(items.router)
11+
12+
13+
if settings.ENVIRONMENT == "local":
14+
api_router.include_router(private.router)

backend/app/api/routes/items.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from app.api.deps import CurrentUser, SessionDep
88
from app.models import Item, ItemCreate, ItemPublic, ItemsPublic, ItemUpdate, Message
99

10-
router = APIRouter()
10+
router = APIRouter(prefix="/items", tags=["items"])
1111

1212

1313
@router.get("/", response_model=ItemsPublic)

backend/app/api/routes/login.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
verify_password_reset_token,
1919
)
2020

21-
router = APIRouter()
21+
router = APIRouter(tags=["login"])
2222

2323

2424
@router.post("/login/access-token")

backend/app/api/routes/private.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
from typing import Any
2+
3+
from fastapi import APIRouter
4+
from pydantic import BaseModel
5+
6+
from app.api.deps import SessionDep
7+
from app.core.security import get_password_hash
8+
from app.models import (
9+
User,
10+
UserPublic,
11+
)
12+
13+
router = APIRouter(tags=["private"], prefix="/private")
14+
15+
16+
class PrivateUserCreate(BaseModel):
17+
email: str
18+
password: str
19+
full_name: str
20+
is_verified: bool = False
21+
22+
23+
@router.post("/users/", response_model=UserPublic)
24+
def create_user(user_in: PrivateUserCreate, session: SessionDep) -> Any:
25+
"""
26+
Create a new user.
27+
"""
28+
29+
user = User(
30+
email=user_in.email,
31+
full_name=user_in.full_name,
32+
hashed_password=get_password_hash(user_in.password),
33+
)
34+
35+
session.add(user)
36+
session.commit()
37+
38+
return user

backend/app/api/routes/users.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
)
2727
from app.utils import generate_new_account_email, send_email
2828

29-
router = APIRouter()
29+
router = APIRouter(prefix="/users", tags=["users"])
3030

3131

3232
@router.get(
@@ -134,8 +134,6 @@ def delete_user_me(session: SessionDep, current_user: CurrentUser) -> Any:
134134
raise HTTPException(
135135
status_code=403, detail="Super users are not allowed to delete themselves"
136136
)
137-
statement = delete(Item).where(col(Item.owner_id) == current_user.id)
138-
session.exec(statement) # type: ignore
139137
session.delete(current_user)
140138
session.commit()
141139
return Message(message="User deleted successfully")

0 commit comments

Comments
 (0)