The Blazr-critical surface for FastAPI. Forms, Channels, Shapes, SSR,
and MWT are out of scope (Ryth's call: defer until Blazr exercises
them; FastAPI projects use native equivalents anyway).
What ships:
- POST /api/mizan/call/ RPC dispatch with Pydantic input validation
- GET /api/mizan/ctx/{name}/ bundled context fetch (all functions in
the named context, parallel-evaluated, single
JSON response)
- JSON-body invalidation transport (the 'invalidate' field on mutation
responses, with auto-scoping when mutation arg names match context params)
- Auth check infrastructure expecting request.state.user populated by
FastAPI middleware/deps (matches FastAPI idioms)
- Cache-Control: no-store on all responses
Built on existing mizan-core: registry (function lookup, context groups,
invalidation metadata), client.function (the @client decorator + ServerFunction
+ _FunctionWrapper). No code copied or duplicated from mizan-django — the
shared substrate is genuinely shared.
Package layout:
backends/mizan-fastapi/
pyproject.toml distribution=mizan-fastapi, module=mizan_fastapi
src/mizan_fastapi/
executor.py dispatch + auth + invalidation
router.py FastAPI APIRouter with the two endpoints
tests/test_dispatch.py 11 e2e tests against TestClient
Test fixture establishes the registration pattern: explicit
register(fn_class, "name") after each @client. mizan-fastapi doesn't
ship discovery — apps register their functions explicitly. (mizan-django
keeps its DjangoAppVisitor discovery; FastAPI's lack of an app system
makes auto-discovery less natural.)
Makefile: install + test targets now include mizan-fastapi alongside
the other packages. New test-core / test-fastapi targets added for
symmetry.
Verified:
- mizan-core: 15/15
- mizan-django: 348 pass, 21 skip, 0 fail
- mizan-fastapi: 11/11
- mizan-ts edge-compat: 34/34
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
60 lines
2.7 KiB
Makefile
60 lines
2.7 KiB
Makefile
.PHONY: install test test-core test-django test-fastapi test-react test-integration docker-up docker-down clean
|
|
|
|
CORE = cores/mizan-python
|
|
DJANGO = backends/mizan-django
|
|
FASTAPI = backends/mizan-fastapi
|
|
REACT = frontends/mizan-react
|
|
|
|
# ─── Setup ───────────────────────────────────────────────────────────────────
|
|
|
|
install:
|
|
cd $(CORE) && uv pip install -e .
|
|
cd $(DJANGO) && uv pip install -e ".[dev,channels]"
|
|
cd $(FASTAPI) && uv pip install -e ".[dev]"
|
|
cd $(REACT) && npm install
|
|
|
|
# ─── Unit Tests ──────────────────────────────────────────────────────────────
|
|
|
|
test: test-core test-django test-fastapi test-react
|
|
|
|
test-core:
|
|
cd $(CORE) && uv run --extra dev pytest
|
|
|
|
test-django:
|
|
cd $(DJANGO) && uv run pytest
|
|
|
|
test-fastapi:
|
|
cd $(FASTAPI) && uv run pytest
|
|
|
|
test-react:
|
|
cd $(REACT) && npm test
|
|
|
|
# ─── Integration Tests ──────────────────────────────────────────────────────
|
|
|
|
test-integration: docker-up
|
|
@echo "Waiting for backend..."
|
|
@timeout 30 sh -c 'until curl -sf http://localhost:8000/api/mizan/session/ > /dev/null 2>&1; do sleep 1; done'
|
|
cd $(REACT) && npm run test:integration
|
|
@$(MAKE) docker-down
|
|
|
|
# ─── Docker ──────────────────────────────────────────────────────────────────
|
|
|
|
docker-up:
|
|
docker compose -f examples/django-react-site/docker-compose.test.yml up -d --build
|
|
@echo "Backend starting at http://localhost:8000"
|
|
|
|
docker-down:
|
|
docker compose -f examples/django-react-site/docker-compose.test.yml down
|
|
|
|
# ─── All ─────────────────────────────────────────────────────────────────────
|
|
|
|
test-all: test test-integration
|
|
|
|
# ─── Cleanup ─────────────────────────────────────────────────────────────────
|
|
|
|
clean:
|
|
docker compose -f examples/django-react-site/docker-compose.test.yml down -v --remove-orphans 2>/dev/null || true
|
|
rm -rf $(DJANGO)/src/mizan.egg-info $(DJANGO)/dist $(DJANGO)/build
|
|
rm -rf $(REACT)/dist $(REACT)/node_modules
|
|
rm -f examples/django-react-site/backend/db.sqlite3
|