import getApiDynamic from "./api/getdb.dyn.js"; import getSqliteDynamic from "./sqlite/getdb.dyn.js"; import type { GetDbDynamic, GetDbStatic } from "./types/GetDb.js"; const dynamicSources: GetDbDynamic[] = [getSqliteDynamic, getApiDynamic]; export async function getDbSources(url: string): Promise { const urlObj = new URL(url); const dbSources: GetDbStatic[] = []; const promises: Promise[] = []; for (const source of dynamicSources) { if (source.protocols.includes(urlObj.protocol)) { promises.push( source .getSource(url) .catch(() => null) .then((dbSource) => { if (dbSource) dbSources.push(dbSource); }) ); } } await Promise.all(promises); return dbSources; }