mirror of
https://github.com/elisiariocouto/leggen.git
synced 2025-12-13 13:42:19 +00:00
feat: Consolidate version display to use health endpoint.
This commit is contained in:
@@ -30,16 +30,7 @@ export function SiteHeader() {
|
|||||||
refetchInterval: 30000,
|
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 (
|
return (
|
||||||
<header className="flex h-16 shrink-0 items-center gap-2 border-b transition-[width,height] ease-linear pt-safe-top">
|
<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">
|
<div className="ml-auto flex items-center space-x-3">
|
||||||
{/* Version display */}
|
{/* Version display */}
|
||||||
<div className="flex items-center space-x-1">
|
<div className="flex items-center space-x-1">
|
||||||
{versionLoading ? (
|
{healthLoading ? (
|
||||||
<span className="text-xs text-muted-foreground">v...</span>
|
<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?</span>
|
||||||
) : (
|
) : (
|
||||||
<span className="text-xs text-muted-foreground">
|
<span className="text-xs text-muted-foreground">
|
||||||
v{versionData.version}
|
v{healthStatus.version || "?"}
|
||||||
</span>
|
</span>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Connection status */}
|
{/* Connection status */}
|
||||||
<div className="flex items-center space-x-1">
|
<div className="flex items-center space-x-1">
|
||||||
{healthLoading ? (
|
{healthLoading ? (
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ import type {
|
|||||||
NotificationService,
|
NotificationService,
|
||||||
NotificationServicesResponse,
|
NotificationServicesResponse,
|
||||||
HealthData,
|
HealthData,
|
||||||
VersionData,
|
|
||||||
AccountUpdate,
|
AccountUpdate,
|
||||||
TransactionStats,
|
TransactionStats,
|
||||||
} from "../types/api";
|
} from "../types/api";
|
||||||
@@ -168,14 +167,7 @@ export const apiClient = {
|
|||||||
return response.data.data;
|
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
|
// Analytics endpoints
|
||||||
getTransactionStats: async (days?: number): Promise<TransactionStats> => {
|
getTransactionStats: async (days?: number): Promise<TransactionStats> => {
|
||||||
|
|||||||
@@ -197,6 +197,7 @@ export interface NotificationServicesResponse {
|
|||||||
export interface HealthData {
|
export interface HealthData {
|
||||||
status: string;
|
status: string;
|
||||||
config_loaded?: boolean;
|
config_loaded?: boolean;
|
||||||
|
version?: string;
|
||||||
message?: string;
|
message?: string;
|
||||||
error?: string;
|
error?: string;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -82,15 +82,6 @@ def create_app() -> FastAPI:
|
|||||||
app.include_router(sync.router, prefix="/api/v1", tags=["sync"])
|
app.include_router(sync.router, prefix="/api/v1", tags=["sync"])
|
||||||
app.include_router(notifications.router, prefix="/api/v1", tags=["notifications"])
|
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")
|
@app.get("/api/v1/health")
|
||||||
async def health():
|
async def health():
|
||||||
"""Health check endpoint for API connectivity"""
|
"""Health check endpoint for API connectivity"""
|
||||||
@@ -99,11 +90,18 @@ def create_app() -> FastAPI:
|
|||||||
|
|
||||||
config_loaded = config._config is not None
|
config_loaded = config._config is not None
|
||||||
|
|
||||||
|
# Get version dynamically
|
||||||
|
try:
|
||||||
|
version = metadata.version("leggen")
|
||||||
|
except metadata.PackageNotFoundError:
|
||||||
|
version = "dev"
|
||||||
|
|
||||||
return APIResponse(
|
return APIResponse(
|
||||||
success=True,
|
success=True,
|
||||||
data={
|
data={
|
||||||
"status": "healthy",
|
"status": "healthy",
|
||||||
"config_loaded": config_loaded,
|
"config_loaded": config_loaded,
|
||||||
|
"version": version,
|
||||||
"message": "API is running and responsive",
|
"message": "API is running and responsive",
|
||||||
},
|
},
|
||||||
message="Health check successful",
|
message="Health check successful",
|
||||||
|
|||||||
Reference in New Issue
Block a user