mirror of
https://github.com/fastapi/full-stack-fastapi-template.git
synced 2026-11-03 20:36:27 +00:00
♻️ Use FASTAPI_ENV for development (#2427)
## AI Disclaimer Using Codex with gpt-5.6-sol. Reviewed manually.
This commit is contained in:
committed by
GitHub
parent
111c5fad66
commit
e95e501951
@@ -1,5 +1,5 @@
|
|||||||
# Enable local-only development behavior
|
# Enable development behavior for commands that import the app directly
|
||||||
ENVIRONMENT=local
|
FASTAPI_ENV=development
|
||||||
|
|
||||||
PROJECT_NAME="Full Stack FastAPI Project"
|
PROJECT_NAME="Full Stack FastAPI Project"
|
||||||
|
|
||||||
|
|||||||
@@ -10,5 +10,5 @@ api_router.include_router(utils.router)
|
|||||||
api_router.include_router(items.router)
|
api_router.include_router(items.router)
|
||||||
|
|
||||||
|
|
||||||
if settings.ENVIRONMENT == "local":
|
if settings.FASTAPI_ENV == "development":
|
||||||
api_router.include_router(private.router)
|
api_router.include_router(private.router)
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ class Settings(BaseSettings):
|
|||||||
# 60 minutes * 24 hours * 8 days = 8 days
|
# 60 minutes * 24 hours * 8 days = 8 days
|
||||||
ACCESS_TOKEN_EXPIRE_MINUTES: int = 60 * 24 * 8
|
ACCESS_TOKEN_EXPIRE_MINUTES: int = 60 * 24 * 8
|
||||||
FRONTEND_HOST: str = "http://localhost:5173"
|
FRONTEND_HOST: str = "http://localhost:5173"
|
||||||
ENVIRONMENT: Literal["local"] | None = None
|
FASTAPI_ENV: Literal["development"] | None = None
|
||||||
|
|
||||||
BACKEND_CORS_ORIGINS: Annotated[
|
BACKEND_CORS_ORIGINS: Annotated[
|
||||||
list[AnyUrl] | str, BeforeValidator(parse_cors)
|
list[AnyUrl] | str, BeforeValidator(parse_cors)
|
||||||
@@ -98,7 +98,7 @@ class Settings(BaseSettings):
|
|||||||
f'The value of {var_name} is "changethis", '
|
f'The value of {var_name} is "changethis", '
|
||||||
"for security, please change it, at least for deployments."
|
"for security, please change it, at least for deployments."
|
||||||
)
|
)
|
||||||
if self.ENVIRONMENT == "local":
|
if self.FASTAPI_ENV == "development":
|
||||||
warnings.warn(message, stacklevel=1)
|
warnings.warn(message, stacklevel=1)
|
||||||
else:
|
else:
|
||||||
raise ValueError(message)
|
raise ValueError(message)
|
||||||
|
|||||||
+1
-1
@@ -15,7 +15,7 @@ def custom_generate_unique_id(route: APIRoute) -> str:
|
|||||||
return f"{route.tags[0]}-{route.name}"
|
return f"{route.tags[0]}-{route.name}"
|
||||||
|
|
||||||
|
|
||||||
if settings.SENTRY_DSN and settings.ENVIRONMENT != "local":
|
if settings.SENTRY_DSN and settings.FASTAPI_ENV != "development":
|
||||||
sentry_sdk.init(dsn=str(settings.SENTRY_DSN), enable_tracing=True)
|
sentry_sdk.init(dsn=str(settings.SENTRY_DSN), enable_tracing=True)
|
||||||
|
|
||||||
app = FastAPI(
|
app = FastAPI(
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ services:
|
|||||||
volumes:
|
volumes:
|
||||||
- ./backend/htmlcov:/app/backend/htmlcov
|
- ./backend/htmlcov:/app/backend/htmlcov
|
||||||
environment:
|
environment:
|
||||||
ENVIRONMENT: "local"
|
FASTAPI_ENV: "development"
|
||||||
SMTP_HOST: "mailcatcher"
|
SMTP_HOST: "mailcatcher"
|
||||||
SMTP_PORT: "1025"
|
SMTP_PORT: "1025"
|
||||||
SMTP_TLS: "false"
|
SMTP_TLS: "false"
|
||||||
|
|||||||
Reference in New Issue
Block a user