Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
**/.env
**/*.sqlite
**/*.vite
**/.coverage
**/.coverage.*
**/htmlcov/
**/coverage.xml
fastapi_startkit/dist
fastapi_startkit.github.io.git
laravel-repo
Expand Down
Empty file.
Empty file.
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
from pathlib import Path

from fastapi import FastAPI
from starlette.templating import Jinja2Templates

from fastapi_startkit.fastapi import FastAPIProvider as BaseFastAPIProvider

Expand All @@ -14,11 +11,6 @@ def register(self) -> None:
)
self.app.use_fastapi(fastapi)

# Bind Jinja2Templates so ViteProvider can inject vite() globals into it.
templates_dir = Path(self.app.base_path) / "templates"
templates = Jinja2Templates(directory=str(templates_dir))
self.app.bind("templates", templates)

def boot(self) -> None:
super().boot()

Expand Down
3 changes: 1 addition & 2 deletions example/vite-app/bootstrap/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
from fastapi_startkit.logging import LogProvider
from fastapi_startkit.vite import ViteProvider

# from config.vite import ViteConfig
from providers.fastapi_provider import FastAPIProvider
from app.providers.fastapi_provider import FastAPIProvider

app: Application = Application(
base_path=Path(__file__).resolve().parent.parent,
Expand Down
3 changes: 3 additions & 0 deletions example/vite-app/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,7 @@ fastapi-startkit = { path = "../../fastapi_startkit", editable = true }
[dependency-groups]
dev = [
"dumpdie>=1.5.0",
"httpx>=0.28.1",
"pytest>=9.0.3",
"pytest-asyncio>=1.3.0",
]
3 changes: 3 additions & 0 deletions example/vite-app/pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[pytest]
asyncio_mode = auto
pythonpath = .
6 changes: 3 additions & 3 deletions example/vite-app/routes/web.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
from fastapi import APIRouter, Request
from fastapi.responses import HTMLResponse

from fastapi_startkit.application import app

web = APIRouter()


@web.get("/", response_class=HTMLResponse)
async def index(request: Request):
from bootstrap.application import app

templates = app.make("templates")
templates = app().make("templates")
return templates.TemplateResponse(request, "index.html")


Expand Down
Empty file.
14 changes: 14 additions & 0 deletions example/vite-app/tests/test_case.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from abc import ABC
from typing import TYPE_CHECKING

from fastapi_startkit.testing import TestCase as BaseTestCase

if TYPE_CHECKING:
from fastapi_startkit.application import Application


class TestCase(BaseTestCase, ABC):
def get_application(self) -> "Application":
from bootstrap.application import app

return app
18 changes: 18 additions & 0 deletions example/vite-app/tests/test_web_routes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from fastapi_startkit.fastapi.testing import HttpTestCase

from tests.test_case import TestCase


class TestHomeController(TestCase, HttpTestCase):
async def test_health_endpoint_returns_ok(self):
response = await self.get("/api/health")

response.assert_ok()
assert response.json() == {"status": "healthy"}

async def test_index_page_renders(self):
response = await self.get("/")

response.assert_ok()
body = response.text
assert "FastAPI StartKit" in body
75 changes: 72 additions & 3 deletions example/vite-app/uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions fastapi_startkit/src/fastapi_startkit/vite/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
from .vite import Vite
from .config.vite import ViteConfig
from .providers.provider import ViteProvider
from .exceptions import ViteException, ViteManifestNotFoundException

__all__ = [
"Vite",
"ViteConfig",
"ViteProvider",
"ViteException",
"ViteManifestNotFoundException",
Expand Down
Loading
Loading