mirror of
https://github.com/elisiariocouto/leggen.git
synced 2025-12-13 11:22:21 +00:00
feat: Consolidate version display to use health endpoint.
This commit is contained in:
@@ -30,16 +30,7 @@ export function SiteHeader() {
|
||||
refetchInterval: 30000,
|
||||
});
|
||||
|
||||
const {
|
||||
data: versionData,
|
||||
isLoading: versionLoading,
|
||||
isError: versionError,
|
||||
} = useQuery({
|
||||
queryKey: ["version"],
|
||||
queryFn: apiClient.getVersion,
|
||||
refetchInterval: 5 * 60 * 1000, // Refetch version every 5 minutes
|
||||
retry: 1, // Only retry once since version is less critical
|
||||
});
|
||||
|
||||
|
||||
return (
|
||||
<header className="flex h-16 shrink-0 items-center gap-2 border-b transition-[width,height] ease-linear pt-safe-top">
|
||||
@@ -56,17 +47,17 @@ export function SiteHeader() {
|
||||
<div className="ml-auto flex items-center space-x-3">
|
||||
{/* Version display */}
|
||||
<div className="flex items-center space-x-1">
|
||||
{versionLoading ? (
|
||||
{healthLoading ? (
|
||||
<span className="text-xs text-muted-foreground">v...</span>
|
||||
) : versionError || !versionData ? (
|
||||
) : healthError || !healthStatus ? (
|
||||
<span className="text-xs text-muted-foreground">v?</span>
|
||||
) : (
|
||||
<span className="text-xs text-muted-foreground">
|
||||
v{versionData.version}
|
||||
v{healthStatus.version || "?"}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
|
||||
|
||||
{/* Connection status */}
|
||||
<div className="flex items-center space-x-1">
|
||||
{healthLoading ? (
|
||||
|
||||
@@ -10,7 +10,6 @@ import type {
|
||||
NotificationService,
|
||||
NotificationServicesResponse,
|
||||
HealthData,
|
||||
VersionData,
|
||||
AccountUpdate,
|
||||
TransactionStats,
|
||||
} from "../types/api";
|
||||
@@ -168,14 +167,7 @@ export const apiClient = {
|
||||
return response.data.data;
|
||||
},
|
||||
|
||||
// Get version information
|
||||
getVersion: async (): Promise<VersionData> => {
|
||||
// Use the root endpoint (/) which provides version information
|
||||
const response = await api.get<VersionData>("/", {
|
||||
baseURL: import.meta.env.VITE_API_URL?.replace('/api/v1', '') || '',
|
||||
});
|
||||
return response.data;
|
||||
},
|
||||
|
||||
|
||||
// Analytics endpoints
|
||||
getTransactionStats: async (days?: number): Promise<TransactionStats> => {
|
||||
|
||||
@@ -197,6 +197,7 @@ export interface NotificationServicesResponse {
|
||||
export interface HealthData {
|
||||
status: string;
|
||||
config_loaded?: boolean;
|
||||
version?: string;
|
||||
message?: string;
|
||||
error?: string;
|
||||
}
|
||||
|
||||
@@ -82,15 +82,6 @@ def create_app() -> FastAPI:
|
||||
app.include_router(sync.router, prefix="/api/v1", tags=["sync"])
|
||||
app.include_router(notifications.router, prefix="/api/v1", tags=["notifications"])
|
||||
|
||||
@app.get("/")
|
||||
async def root():
|
||||
# Get version dynamically
|
||||
try:
|
||||
version = metadata.version("leggen")
|
||||
except metadata.PackageNotFoundError:
|
||||
version = "unknown"
|
||||
return {"message": "Leggen API is running", "version": version}
|
||||
|
||||
@app.get("/api/v1/health")
|
||||
async def health():
|
||||
"""Health check endpoint for API connectivity"""
|
||||
@@ -99,11 +90,18 @@ def create_app() -> FastAPI:
|
||||
|
||||
config_loaded = config._config is not None
|
||||
|
||||
# Get version dynamically
|
||||
try:
|
||||
version = metadata.version("leggen")
|
||||
except metadata.PackageNotFoundError:
|
||||
version = "dev"
|
||||
|
||||
return APIResponse(
|
||||
success=True,
|
||||
data={
|
||||
"status": "healthy",
|
||||
"config_loaded": config_loaded,
|
||||
"version": version,
|
||||
"message": "API is running and responsive",
|
||||
},
|
||||
message="Health check successful",
|
||||
|
||||
Reference in New Issue
Block a user