Skip to content

feat: add FastAPIConfig for server settings - #55

Merged
tmgbedu merged 10 commits into
mainfrom
schema-add-schemas
May 17, 2026
Merged

feat: add FastAPIConfig for server settings#55
tmgbedu merged 10 commits into
mainfrom
schema-add-schemas

Conversation

@tmgbedu

@tmgbedu tmgbedu commented May 16, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Adds FastAPIConfig dataclass (fastapi/config/fastapi.py) with host, port, reload, reload_dirs, and reload_excludes fields, all backed by environment variables (APP_HOST, APP_PORT, APP_RELOAD)
  • FastAPIProvider registers a default FastAPIConfig instance under the fastapi config key at boot; user-published config/fastapi.py takes precedence via the normal config pipeline
  • ServeCommand now resolves server settings with priority: CLI flag → config → built-in default, and passes reload_dirs/reload_excludes from config through to uvicorn

Test plan

  • Run uv run artisan serve — verify it starts with defaults from FastAPIConfig
  • Set APP_HOST=0.0.0.0 APP_PORT=9000 in .env and re-run — verify env vars are picked up
  • Publish a config/fastapi.py with custom values — verify config file overrides env defaults
  • Run uv run artisan serve --host 0.0.0.0 --port 9001 — verify CLI flags win over config

🤖 Generated with Claude Code

tmgbedu and others added 10 commits May 16, 2026 16:34
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>
@tmgbedu
tmgbedu merged commit d62117a into main May 17, 2026
0 of 3 checks passed
@tmgbedu
tmgbedu deleted the schema-add-schemas branch May 17, 2026 00:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant