Skip to content

Commit 05e6b21

Browse files
authored
Merge branch 'master' into sync-docs
2 parents cc3afcc + b0f6195 commit 05e6b21

27 files changed

+1858
-650
lines changed

.github/workflows/generate-client.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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/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@v3
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

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 & 1 deletion
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(

backend/app/api/routes/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from app.models import Message
66
from app.utils import generate_test_email, send_email
77

8-
router = APIRouter()
8+
router = APIRouter(prefix="/utils", tags=["utils"])
99

1010

1111
@router.post(
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
from fastapi.testclient import TestClient
2+
from sqlmodel import Session, select
3+
4+
from app.core.config import settings
5+
from app.models import User
6+
7+
8+
def test_create_user(client: TestClient, db: Session) -> None:
9+
r = client.post(
10+
f"{settings.API_V1_STR}/private/users/",
11+
json={
12+
"email": "[email protected]",
13+
"password": "password123",
14+
"full_name": "Pollo Listo",
15+
},
16+
)
17+
18+
assert r.status_code == 200
19+
20+
data = r.json()
21+
22+
user = db.exec(select(User).where(User.id == data["id"])).first()
23+
24+
assert user
25+
assert user.email == "[email protected]"
26+
assert user.full_name == "Pollo Listo"

frontend/modify-openapi-operationids.js

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

0 commit comments

Comments
 (0)