diff --git a/backend/VERSION b/backend/VERSION new file mode 100644 index 0000000..3eefcb9 --- /dev/null +++ b/backend/VERSION @@ -0,0 +1 @@ +1.0.0 diff --git a/backend/server.py b/backend/server.py index 986fd00..dd4a8ca 100644 --- a/backend/server.py +++ b/backend/server.py @@ -67,6 +67,13 @@ app = FastAPI(title="StreamHoard") api = APIRouter(prefix="/api") bearer = HTTPBearer(auto_error=False) +APP_VERSION = (ROOT_DIR / "VERSION").read_text().strip() if (ROOT_DIR / "VERSION").is_file() else "0.0.0" + + +@api.get("/version") +async def get_version(): + return {"version": APP_VERSION} + # ---------- Auth deps ---------- async def get_current_user(creds: Optional[HTTPAuthorizationCredentials] = Depends(bearer)) -> dict: diff --git a/frontend/src/components/Navbar.jsx b/frontend/src/components/Navbar.jsx index 910e150..9934ff6 100644 --- a/frontend/src/components/Navbar.jsx +++ b/frontend/src/components/Navbar.jsx @@ -3,12 +3,14 @@ import { useAuth } from "../lib/auth"; import { useProfile } from "../lib/profile"; import { Search, LogOut, Upload, Settings as SettingsIcon } from "lucide-react"; import { useState, useEffect } from "react"; +import api from "../lib/api"; export const Navbar = () => { const { user, logout } = useAuth(); const { active } = useProfile(); const nav = useNavigate(); const [scrolled, setScrolled] = useState(false); + const [version, setVersion] = useState(""); useEffect(() => { const onScroll = () => setScrolled(window.scrollY > 20); @@ -16,6 +18,10 @@ export const Navbar = () => { return () => window.removeEventListener("scroll", onScroll); }, []); + useEffect(() => { + api.get("/version").then(({ data }) => setVersion(data.version)).catch(() => {}); + }, []); + const linkClass = ({ isActive }) => `text-sm tracking-wide transition-colors duration-300 ${isActive ? "text-white" : "text-[#8A8A8A] hover:text-white"}`; @@ -26,6 +32,7 @@ export const Navbar = () => { StreamHoard . + {version && v{version}} {user && (