| 21 | } |
| 22 | |
| 23 | export class RTDBListRemote implements ListRemote { |
| 24 | private apiClient: Client; |
| 25 | |
| 26 | constructor( |
| 27 | private instance: string, |
| 28 | private host: string, |
| 29 | ) { |
| 30 | const url = new URL(utils.getDatabaseUrl(this.host, this.instance, "/")); |
| 31 | this.apiClient = new Client({ urlPrefix: url.origin, auth: true }); |
| 32 | } |
| 33 | |
| 34 | async listPath( |
| 35 | path: string, |
| 36 | numSubPath: number, |
| 37 | startAfter?: string, |
| 38 | timeout?: number, |
| 39 | ): Promise<string[]> { |
| 40 | const url = new URL(utils.getDatabaseUrl(this.host, this.instance, path + ".json")); |
| 41 | |
| 42 | const params: any = { |
| 43 | shallow: true, |
| 44 | limitToFirst: numSubPath, |
| 45 | }; |
| 46 | if (startAfter) { |
| 47 | params.startAfter = startAfter; |
| 48 | } |
| 49 | if (timeout) { |
| 50 | params.timeout = `${timeout}ms`; |
| 51 | } |
| 52 | |
| 53 | const t0 = Date.now(); |
| 54 | const res = await this.apiClient.get<{ [key: string]: unknown }>(url.pathname, { |
| 55 | queryParams: params, |
| 56 | }); |
| 57 | const paths = res.body ? Object.keys(res.body) : []; |
| 58 | const dt = Date.now() - t0; |
| 59 | logger.debug(`[database] sucessfully fetched ${paths.length} path at ${path} ${dt}`); |
| 60 | return paths; |
| 61 | } |
| 62 | } |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…