From 8a88a43c2043235855218ce0f7334e36d4771fea Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Thu, 18 Aug 2022 18:28:36 -0400 Subject: [PATCH] *Add mock ResolverRegistry class --- src/index.ts | 2 ++ src/resolverRegistry.ts | 25 +++++++++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 src/resolverRegistry.ts 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; + } +}