Skip to content

Commit 1295ff6

Browse files
committed
refactor: change the variable name to X_API_KEY for readability
1 parent fb60183 commit 1295ff6

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

config/settings.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@
1313
ALLOW_ORIGINS: list[str] = os.getenv("ALLOW_ORIGINS", "").split(",")
1414
assert ALLOW_ORIGINS, "ALLOW_ORIGINS environment variable is not set"
1515

16-
BUILD_API_KEY: str = os.getenv("BUILD_API_KEY", "")
17-
assert BUILD_API_KEY, "BUILD_API_KEY environment variable is not set"
16+
X_API_KEY: str = os.getenv("X_API_KEY", "")
17+
assert X_API_KEY, "X_API_KEY environment variable is not set"

main.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
from starlette.status import HTTP_403_FORBIDDEN
2424

2525
from api import accent_marker, dict_query, furigana_marker, sentence_query, usage_query
26-
from config.settings import ALLOW_ORIGINS, ALLOWED_HOSTS, BUILD_API_KEY
26+
from config.settings import ALLOW_ORIGINS, ALLOWED_HOSTS, X_API_KEY
2727

2828

2929
@asynccontextmanager
@@ -74,7 +74,7 @@ async def lifespan(app: FastAPI) -> AsyncGenerator[None, None]:
7474
# API Key Header for build API key authentication
7575
api_key_header = APIKeyHeader(name="X-API-KEY", auto_error=False)
7676
async def get_api_key(api_key: str = Security(api_key_header)) -> None:
77-
if api_key != BUILD_API_KEY:
77+
if api_key != X_API_KEY:
7878
raise HTTPException(
7979
status_code=HTTP_403_FORBIDDEN, detail="Could not validate credentials"
8080
)

0 commit comments

Comments
 (0)