feat(vite): re-export ViteConfig from vite package root#136
Merged
Conversation
…vider default Move the example templates into resources/templates to match ViteConfig's default templates_directory, and drop the bootstrap override so the example relies on ViteProvider's auto-bound Jinja2Templates engine.
Use `from fastapi_startkit.application import app` -> app().make('templates')
in the example route instead of the bootstrap module, matching the framework's
canonical app accessor (no top-level export).
Relocate providers/ to app/providers/ and update the bootstrap import, grouping application code under the app/ namespace.
Add HttpTestCase-based tests covering the health endpoint and the index page render (templates resolve from resources/templates with vite globals). Wire up pytest config and dev dependencies.
Resolve conflicts in vite-app bootstrap/application.py and routes/web.py, keeping the app/ provider package layout and canonical app() template accessor. Restore FastAPIProvider without the stale templates binding so ViteProvider serves templates from resources/templates. Remove tests/vite/test_vite.py per request.
Rely on the built manifest so the vite() directive resolves to production asset URLs, and drop the dev-server hot file setup. Assert against the built /build/assets/ output instead of the source path. Also remove the stale ViteProvider comment in bootstrap.
Match the routes/web.py module and the TestWebRoutes class it covers.
Keep the index page test focused on a successful render.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Makes
from fastapi_startkit.vite import ViteConfigwork by re-exportingViteConfigfrom the vite package root, and updates the Vite example app to the new templates convention.Changes
vite/__init__.py: importViteConfigfrom.config.viteand add it to__all__(alongside the existing exports). No behavior change beyond the export.tests/vite/test_vite.py: addTestViteConfigExportasserting the import works, resolves to the SAME class object asfastapi_startkit.vite.config.vite.ViteConfig, and is present in__all__.Vite example app (
example/vite-app)templates/index.html→resources/templates/index.htmlto matchViteConfig.templates_directorydefault (resources/templates).templates_directory="templates"override inbootstrap/application.py; the example now relies onViteProvider's auto-boundJinja2Templatesengine at the default directory.template()helper (decoupled frombootstrap.application); the manualJinja2Templatesbinding inproviders/fastapi_provider.pywas already removed earlier on this branch.Verification
uv run pytest tests/vite/ -v→ 41 passeduv run pytest --cov→ 1558 passed, coverage 67.29% (above fail_under)GET /→ 200, templates auto-bound fromresources/templates,vite/vite_asset/vite_react_refreshJinja globals present and thevite()directive renders (no unrendered{{ vite }});GET /api/health→ 200.Example app: tests + structure (follow-up)
example/vite-app/tests/using the framework'sHttpTestCase:GET /api/health→ 200 JSON, andGET /renders the index template (templates fromresources/templates,vite()directive resolved). Addedpytest.iniand dev deps (pytest,pytest-asyncio,httpx).uv run pytest -v→ 2 passed.providers/→app/providers/(grouped under anapp/package) and updated the bootstrap import accordingly.