*Add mock ResolverRegistry class

This commit is contained in:
Derrick Hammer 2022-08-18 18:28:36 -04:00
parent 1fe0496312
commit 8a88a43c20
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
2 changed files with 27 additions and 0 deletions

View File

@ -41,3 +41,5 @@ async function handleResolve(aq: ActiveQuery) {
aq.respond(ret);
}
export * from "./resolverRegistry.js";

25
src/resolverRegistry.ts Normal file
View File

@ -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<DNSResult> {
let result: DNSResult;
try {
result = await resolve(domain, options, bypassCache);
} catch (e: any) {
return resolverError(e);
}
return result;
}
}