-
-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into patch-fix-missing-slash-in-urls
- Loading branch information
Showing
53 changed files
with
2,343 additions
and
846 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,11 @@ jobs: | |
contents: write | ||
runs-on: ubuntu-latest | ||
steps: | ||
# For PRs from forks | ||
- uses: actions/checkout@v4 | ||
# For PRs from the same repo | ||
- uses: actions/checkout@v4 | ||
if: ( github.event_name != 'pull_request' || github.secret_source == 'Actions' ) | ||
with: | ||
ref: ${{ github.head_ref }} | ||
token: ${{ secrets.FULL_STACK_FASTAPI_TEMPLATE_REPO_TOKEN }} | ||
|
@@ -23,7 +27,7 @@ jobs: | |
with: | ||
python-version: "3.10" | ||
- name: Install uv | ||
uses: astral-sh/setup-uv@v2 | ||
uses: astral-sh/setup-uv@v5 | ||
with: | ||
version: "0.4.15" | ||
enable-cache: true | ||
|
@@ -35,10 +39,23 @@ jobs: | |
- run: uv run bash scripts/generate-client.sh | ||
env: | ||
VIRTUAL_ENV: backend/.venv | ||
- name: Commit changes | ||
ENVIRONMENT: production | ||
SECRET_KEY: just-for-generating-client | ||
POSTGRES_PASSWORD: just-for-generating-client | ||
FIRST_SUPERUSER_PASSWORD: just-for-generating-client | ||
- name: Add changes to git | ||
run: | | ||
git config --local user.email "[email protected]" | ||
git config --local user.name "github-actions" | ||
git add frontend/src/client | ||
# Same repo PRs | ||
- name: Push changes | ||
if: ( github.event_name != 'pull_request' || github.secret_source == 'Actions' ) | ||
run: | | ||
git diff --staged --quiet || git commit -m "✨ Autogenerate frontend client" | ||
git push | ||
# Fork PRs | ||
- name: Check changes | ||
if: ( github.event_name == 'pull_request' && github.secret_source != 'Actions' ) | ||
run: | | ||
git diff --staged --quiet || (echo "Changes detected in generated client, run scripts/generate-client.sh and commit the changes" && exit 1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,7 +27,7 @@ jobs: | |
env: | ||
GITHUB_CONTEXT: ${{ toJson(github) }} | ||
run: echo "$GITHUB_CONTEXT" | ||
- uses: tiangolo/[email protected].0 | ||
- uses: tiangolo/[email protected].1 | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
config: > | ||
|
@@ -39,5 +39,9 @@ jobs: | |
"waiting": { | ||
"delay": 2628000, | ||
"message": "As this PR has been waiting for the original user for a while but seems to be inactive, it's now going to be closed. But if there's anyone interested, feel free to create a new PR." | ||
}, | ||
"invalid": { | ||
"delay": 0, | ||
"message": "This was marked as invalid and will be closed now. If this is an error, please provide additional details." | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,7 +30,7 @@ jobs: | |
with: | ||
# To allow latest-changes to commit to the main branch | ||
token: ${{ secrets.LATEST_CHANGES }} | ||
- uses: tiangolo/[email protected].1 | ||
- uses: tiangolo/[email protected].2 | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
latest_changes_file: ./release-notes.md | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
FROM python:3.10 | ||
|
||
ENV PYTHONUNBUFFERED=1 | ||
|
||
WORKDIR /app/ | ||
|
||
# Install uv | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,14 @@ | ||
from fastapi import APIRouter | ||
|
||
from app.api.routes import items, login, users, utils | ||
from app.api.routes import items, login, private, users, utils | ||
from app.core.config import settings | ||
|
||
api_router = APIRouter() | ||
api_router.include_router(login.router, tags=["login"]) | ||
api_router.include_router(users.router, prefix="/users", tags=["users"]) | ||
api_router.include_router(utils.router, prefix="/utils", tags=["utils"]) | ||
api_router.include_router(items.router, prefix="/items", tags=["items"]) | ||
api_router.include_router(login.router) | ||
api_router.include_router(users.router) | ||
api_router.include_router(utils.router) | ||
api_router.include_router(items.router) | ||
|
||
|
||
if settings.ENVIRONMENT == "local": | ||
api_router.include_router(private.router) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
from typing import Any | ||
|
||
from fastapi import APIRouter | ||
from pydantic import BaseModel | ||
|
||
from app.api.deps import SessionDep | ||
from app.core.security import get_password_hash | ||
from app.models import ( | ||
User, | ||
UserPublic, | ||
) | ||
|
||
router = APIRouter(tags=["private"], prefix="/private") | ||
|
||
|
||
class PrivateUserCreate(BaseModel): | ||
email: str | ||
password: str | ||
full_name: str | ||
is_verified: bool = False | ||
|
||
|
||
@router.post("/users/", response_model=UserPublic) | ||
def create_user(user_in: PrivateUserCreate, session: SessionDep) -> Any: | ||
""" | ||
Create a new user. | ||
""" | ||
|
||
user = User( | ||
email=user_in.email, | ||
full_name=user_in.full_name, | ||
hashed_password=get_password_hash(user_in.password), | ||
) | ||
|
||
session.add(user) | ||
session.commit() | ||
|
||
return user |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from fastapi.testclient import TestClient | ||
from sqlmodel import Session, select | ||
|
||
from app.core.config import settings | ||
from app.models import User | ||
|
||
|
||
def test_create_user(client: TestClient, db: Session) -> None: | ||
r = client.post( | ||
f"{settings.API_V1_STR}/private/users/", | ||
json={ | ||
"email": "[email protected]", | ||
"password": "password123", | ||
"full_name": "Pollo Listo", | ||
}, | ||
) | ||
|
||
assert r.status_code == 200 | ||
|
||
data = r.json() | ||
|
||
user = db.exec(select(User).where(User.id == data["id"])).first() | ||
|
||
assert user | ||
assert user.email == "[email protected]" | ||
assert user.full_name == "Pollo Listo" |
Oops, something went wrong.