ruvector/studio/lib/pingPostgrest.ts
rUv 814f595995 feat(studio): Add complete RuVector Studio application
Major additions:
- Complete Next.js studio application with 1600+ components
- Docker support (Dockerfile.combined, docker-compose.yml)
- GCP deployment documentation and benchmarks
- SQL benchmark scripts for performance testing
- Sentry integration for monitoring
- Comprehensive test suite and mocks

Studio features:
- Dashboard and admin interfaces
- Data visualization components
- Authentication and user management
- API integration with RuVector backend
- Static data and public assets

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-06 23:04:48 +00:00

40 lines
999 B
TypeScript

import { fetchHeadWithTimeout } from 'data/fetchers'
import { API_URL } from './constants'
const DEFAULT_TIMEOUT_MILLISECONDS = 2000
/**
* Ping Postgrest for health check. Default timeout in 2s.
*
* @param restUrl project rest url
* @param apikey project internal api key
* @param options optional, include custom timeout in milliseconds
*
* @return true if ping is successful else false
*/
async function pingPostgrest(
projectRef: string,
options?: {
timeout?: number
}
) {
if (projectRef === undefined) return false
const { timeout } = options ?? {}
return pingOpenApi(projectRef, timeout)
}
export default pingPostgrest
/**
* Send a HEAD request to postgrest OpenAPI.
*
* @return true if there's no error else false
*/
async function pingOpenApi(ref: string, timeout?: number) {
const { error } = await fetchHeadWithTimeout(`${API_URL}/projects/${ref}/api/rest`, [], {
timeout: timeout ?? DEFAULT_TIMEOUT_MILLISECONDS,
})
return error === undefined
}