diff --git a/src/index.ts b/src/index.ts index a7bb1fd..ab1b20f 100644 --- a/src/index.ts +++ b/src/index.ts @@ -41,3 +41,5 @@ async function handleResolve(aq: ActiveQuery) { aq.respond(ret); } + +export * from "./resolverRegistry.js"; diff --git a/src/resolverRegistry.ts b/src/resolverRegistry.ts new file mode 100644 index 0000000..ba9c52f --- /dev/null +++ b/src/resolverRegistry.ts @@ -0,0 +1,25 @@ +import { + DNSResult, + ResolverOptions, + DNS_RECORD_TYPE, + resolverError, +} from "@lumeweb/resolver-common"; +import { resolve } from "@lumeweb/kernel-dns-client"; + +export class ResolverRegistry { + public async resolve( + domain: string, + options: ResolverOptions = { type: DNS_RECORD_TYPE.DEFAULT }, + bypassCache: boolean = false + ): Promise { + let result: DNSResult; + + try { + result = await resolve(domain, options, bypassCache); + } catch (e: any) { + return resolverError(e); + } + + return result; + } +}