Skip to content

Commit e95e501

Browse files
authored
♻️ Use FASTAPI_ENV for development (#2427)
## AI Disclaimer Using Codex with gpt-5.6-sol. Reviewed manually.
1 parent 111c5fa commit e95e501

5 files changed

Lines changed: 7 additions & 7 deletions

File tree

.env

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
# Enable local-only development behavior
2-
ENVIRONMENT=local
1+
# Enable development behavior for commands that import the app directly
2+
FASTAPI_ENV=development
33

44
PROJECT_NAME="Full Stack FastAPI Project"
55

backend/app/api/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@
1010
api_router.include_router(items.router)
1111

1212

13-
if settings.ENVIRONMENT == "local":
13+
if settings.FASTAPI_ENV == "development":
1414
api_router.include_router(private.router)

backend/app/core/config.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class Settings(BaseSettings):
3333
# 60 minutes * 24 hours * 8 days = 8 days
3434
ACCESS_TOKEN_EXPIRE_MINUTES: int = 60 * 24 * 8
3535
FRONTEND_HOST: str = "http://localhost:5173"
36-
ENVIRONMENT: Literal["local"] | None = None
36+
FASTAPI_ENV: Literal["development"] | None = None
3737

3838
BACKEND_CORS_ORIGINS: Annotated[
3939
list[AnyUrl] | str, BeforeValidator(parse_cors)
@@ -98,7 +98,7 @@ def _check_default_secret(self, var_name: str, value: str | None) -> None:
9898
f'The value of {var_name} is "changethis", '
9999
"for security, please change it, at least for deployments."
100100
)
101-
if self.ENVIRONMENT == "local":
101+
if self.FASTAPI_ENV == "development":
102102
warnings.warn(message, stacklevel=1)
103103
else:
104104
raise ValueError(message)

backend/app/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def custom_generate_unique_id(route: APIRoute) -> str:
1515
return f"{route.tags[0]}-{route.name}"
1616

1717

18-
if settings.SENTRY_DSN and settings.ENVIRONMENT != "local":
18+
if settings.SENTRY_DSN and settings.FASTAPI_ENV != "development":
1919
sentry_sdk.init(dsn=str(settings.SENTRY_DSN), enable_tracing=True)
2020

2121
app = FastAPI(

compose.override.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ services:
6767
volumes:
6868
- ./backend/htmlcov:/app/backend/htmlcov
6969
environment:
70-
ENVIRONMENT: "local"
70+
FASTAPI_ENV: "development"
7171
SMTP_HOST: "mailcatcher"
7272
SMTP_PORT: "1025"
7373
SMTP_TLS: "false"

0 commit comments

Comments
 (0)