mirror of
https://github.com/supabase/supabase.git
synced 2026-07-05 12:14:27 +08:00
36 lines
1.1 KiB
TypeScript
36 lines
1.1 KiB
TypeScript
import { ResponseError } from 'types'
|
|
import { API_URL } from 'lib/constants'
|
|
import { get } from 'lib/common/fetch'
|
|
import { IRootStore } from '../RootStore'
|
|
import { constructHeaders } from 'lib/api/apiHelpers'
|
|
import PostgresMetaInterface, { IPostgresMetaInterface } from '../common/PostgresMetaInterface'
|
|
|
|
export interface IDatabaseStore extends IPostgresMetaInterface<any> {
|
|
getPoolingConfiguration: (projectRef: string) => Promise<any | { error: ResponseError }>
|
|
}
|
|
|
|
export default class DatabaseStore extends PostgresMetaInterface<any> {
|
|
constructor(
|
|
rootStore: IRootStore,
|
|
dataUrl: string,
|
|
headers?: {
|
|
[prop: string]: any
|
|
},
|
|
options?: { identifier: string }
|
|
) {
|
|
super(rootStore, dataUrl, headers, options)
|
|
}
|
|
|
|
async getPoolingConfiguration(projectRef: string) {
|
|
try {
|
|
// Need to use project ref -> shouldn;t need to pass it in via argument
|
|
const url = `${API_URL}/props/pooling/${projectRef}/config`
|
|
const response = await get(url, { headers: this.headers })
|
|
if (response.error) throw response.error
|
|
return response
|
|
} catch (error: any) {
|
|
return { error }
|
|
}
|
|
}
|
|
}
|