Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ addopts = "--cov --cov-report term-missing --cov-fail-under=85"

[tool.pytest_env]
DOMAIN = "http://localhost:8010"
FRONTEND = "http://localhost:8080"
RATE_LIMIT_REQUESTS = 2
RATE_LIMIT_WINDOW_SECONDS = 60
MAX_CODE_GENERATION_ATTEMPTS = 2
Expand Down
2 changes: 2 additions & 0 deletions source/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from source.endpoints.decode import router as decode_router
from source.endpoints.encode import router as encode_router
from source.endpoints.focal import router as focal_router
from source.endpoints.management import router as management_router
from source.endpoints.status import router as status_router
from source.settings import settings
Expand All @@ -30,6 +31,7 @@ def create_app() -> FastAPI:
application.include_router(encode_router)
application.include_router(management_router)
application.include_router(status_router)
application.include_router(focal_router)

return application

Expand Down
1 change: 0 additions & 1 deletion source/endpoints/decode.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
tags=["Encryption"],
status_code=status.HTTP_308_PERMANENT_REDIRECT,
responses={
status.HTTP_308_PERMANENT_REDIRECT: {"description": "Successful redirection to the original URL."},
status.HTTP_404_NOT_FOUND: {"description": "There's no `link` assigned to this code."},
},
)
Expand Down
11 changes: 11 additions & 0 deletions source/endpoints/focal.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from fastapi import APIRouter, Request, status
from fastapi.responses import RedirectResponse

from source.settings import settings

router = APIRouter()


@router.get("/", summary="Redirects to frontend.", status_code=status.HTTP_308_PERMANENT_REDIRECT)
async def home(request: Request) -> RedirectResponse: # pylint: disable=unused-argument
return RedirectResponse(status_code=status.HTTP_308_PERMANENT_REDIRECT, url=settings.frontend)
1 change: 1 addition & 0 deletions source/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ class Settings(BaseSettings):

# Environment variables
domain: str
frontend: str
rate_limit_requests: int
rate_limit_window_seconds: int
database_url: str
Expand Down
10 changes: 10 additions & 0 deletions tests/test_endpoints/test_focal.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from fastapi import status
from httpx import AsyncClient

from source.settings import settings


async def test_home(client: AsyncClient) -> None:
response = await client.get("/")
assert response.status_code == status.HTTP_308_PERMANENT_REDIRECT
assert response.headers["location"] == settings.frontend