from starlette.requests import Request
from starlette.responses import JSONResponse

from api.route import Route
from core.configuration.feature_flags import FeatureFlags
from core.configuration.feature_flags_enum import FeatureFlagsEnum
from version import VERSION


@Route.get(f"/api/version")
async def version(r: Request):
    feature = await FeatureFlags.has_feature(FeatureFlagsEnum.version_endpoint)
    if not feature:
        return JSONResponse("DISABLED", status_code=403)

    return JSONResponse(VERSION)
