feat: add FastAPIConfig for server settings - #55
Merged
Conversation
Introduce FastAPIConfig dataclass with host, port, reload, reload_dirs, and reload_excludes fields — all env-var backed. FastAPIProvider registers the config automatically; ServeCommand resolves settings via CLI flag > config > built-in default. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Register config/fastapi.py as a publishable resource so users can run `artisan provider:publish --provider=fastapi` to scaffold a customisable config file in their application root. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Log file writes were triggering uvicorn reloads on every request. Add node_modules/*, logs/*, and storage/logs/* to the default reload_excludes so only real source changes trigger a restart. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The manual config.has/config.set approach ignored self.config entirely, so user-provided config passed as (FastAPIProvider, FastAPIConfig) had no effect. Now uses resolve_config + merge_config_from with provider_key = "fastapi", matching the ViteProvider pattern. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Matches the framework default — *.log covers all log files regardless of location, cleaner than listing specific directories. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
FastAPIConfig is the single source of truth for defaults. Config.get() fallbacks now return None so uvicorn uses its own defaults when nothing is configured, rather than duplicating hardcoded values in the command. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
An empty list was preventing uvicorn from watching anything useful. None lets uvicorn apply its own default (current working directory), consistent with the None-fallback pattern in ServeCommand. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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
FastAPIConfigdataclass (fastapi/config/fastapi.py) withhost,port,reload,reload_dirs, andreload_excludesfields, all backed by environment variables (APP_HOST,APP_PORT,APP_RELOAD)FastAPIProviderregisters a defaultFastAPIConfiginstance under thefastapiconfig key at boot; user-publishedconfig/fastapi.pytakes precedence via the normal config pipelineServeCommandnow resolves server settings with priority: CLI flag → config → built-in default, and passesreload_dirs/reload_excludesfrom config through to uvicornTest plan
uv run artisan serve— verify it starts with defaults fromFastAPIConfigAPP_HOST=0.0.0.0 APP_PORT=9000in.envand re-run — verify env vars are picked upconfig/fastapi.pywith custom values — verify config file overrides env defaultsuv run artisan serve --host 0.0.0.0 --port 9001— verify CLI flags win over config🤖 Generated with Claude Code