refactor: switch to new sdks
This commit is contained in:
parent
03503c1b77
commit
fb6b5c4b52
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"preset": [
|
||||
"@lumeweb/node-library-preset"
|
||||
]
|
||||
}
|
|
@ -1 +0,0 @@
|
|||
export declare const dnsClient: import("@lumeweb/kernel-dns-client").DnsClient;
|
|
@ -1,2 +0,0 @@
|
|||
import { createClient } from "@lumeweb/kernel-dns-client";
|
||||
export const dnsClient = createClient();
|
|
@ -1,22 +0,0 @@
|
|||
import type {
|
||||
DNSResult,
|
||||
ResolverModule as ResolverModuleBase,
|
||||
} from "@lumeweb/libresolver";
|
||||
import { DnsClient } from "@lumeweb/kernel-dns-client";
|
||||
import { ResolverOptions } from "@lumeweb/libresolver/src/types.js";
|
||||
export interface ResolverModule {
|
||||
get resolver(): DnsClient;
|
||||
set resolver(value: DnsClient);
|
||||
resolve(
|
||||
domain: string,
|
||||
options: ResolverOptions,
|
||||
bypassCache: boolean
|
||||
): Promise<DNSResult>;
|
||||
getSupportedTlds(): string[];
|
||||
getSupportedTlds(): Promise<string[]>;
|
||||
getSupportedTlds(): any;
|
||||
}
|
||||
export declare function setup(rm: ResolverModule | ResolverModuleBase): void;
|
||||
export * from "@lumeweb/libresolver/dist/util.js";
|
||||
export * from "@lumeweb/libresolver/dist/types.js";
|
||||
export { AbstractResolverModule } from "@lumeweb/libresolver/dist/resolverModule.js";
|
|
@ -1,42 +0,0 @@
|
|||
import { addHandler, handleMessage } from "libkmodule";
|
||||
import { DNS_RECORD_TYPE } from "@lumeweb/libresolver";
|
||||
import { dnsClient } from "./client.js";
|
||||
let resolver;
|
||||
export function setup(rm) {
|
||||
addHandler("resolve", handleResolve);
|
||||
addHandler("register", handleRegister);
|
||||
addHandler("getSupportedTlds", handleGetSupportedTlds);
|
||||
onmessage = handleMessage;
|
||||
resolver = rm;
|
||||
// @ts-ignore
|
||||
resolver.resolver = dnsClient;
|
||||
}
|
||||
async function handleRegister(aq) {
|
||||
await dnsClient.register();
|
||||
aq.respond();
|
||||
}
|
||||
async function handleResolve(aq) {
|
||||
if (!("domain" in aq.callerInput)) {
|
||||
aq.reject("domain required");
|
||||
return;
|
||||
}
|
||||
let ret;
|
||||
try {
|
||||
ret = await resolver.resolve(aq.callerInput.domain, aq.callerInput?.options ?? { type: DNS_RECORD_TYPE.CONTENT }, aq.callerInput?.bypassCache || false);
|
||||
}
|
||||
catch (e) {
|
||||
aq.reject(e);
|
||||
return;
|
||||
}
|
||||
if (ret.error) {
|
||||
aq.reject(ret.error);
|
||||
return;
|
||||
}
|
||||
aq.respond(ret);
|
||||
}
|
||||
function handleGetSupportedTlds(aq) {
|
||||
aq.respond(resolver.getSupportedTlds());
|
||||
}
|
||||
export * from "@lumeweb/libresolver/dist/util.js";
|
||||
export * from "@lumeweb/libresolver/dist/types.js";
|
||||
export { AbstractResolverModule } from "@lumeweb/libresolver/dist/resolverModule.js";
|
File diff suppressed because it is too large
Load Diff
37
package.json
37
package.json
|
@ -1,19 +1,32 @@
|
|||
{
|
||||
"name": "@lumeweb/kernel-libresolver",
|
||||
"version": "0.1.0",
|
||||
"main": "dist/index.js",
|
||||
"dependencies": {
|
||||
"@lumeweb/kernel-dns-client": "git+https://git.lumeweb.com/LumeWeb/kernel-dns-client.git",
|
||||
"@lumeweb/kernel-libresolver": "git+https://git.lumeweb.com/LumeWeb/kernel-libresolver.git",
|
||||
"@lumeweb/kernel-rpc-client": "git+https://git.lumeweb.com/LumeWeb/kernel-rpc-client.git",
|
||||
"@lumeweb/libkernel-universal": "git+https://git.lumeweb.com/LumeWeb/libkernel-universal.git",
|
||||
"@lumeweb/libresolver": "git+https://git.lumeweb.com/LumeWeb/libresolver.git",
|
||||
"libkmodule": "^0.2.53"
|
||||
"main": "lin/index.js",
|
||||
"type": "module",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "gitea@git.lumeweb.com:LumeWeb/kernel-libresolver.git"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@lumeweb/relay-types": "git+https://git.lumeweb.com/LumeWeb/relay-types.git",
|
||||
"@types/node": "^18.14.0",
|
||||
"prettier": "^2.8.4",
|
||||
"typescript": "^4.9.5"
|
||||
"@lumeweb/node-library-preset": "^0.2.7",
|
||||
"presetter": "*"
|
||||
},
|
||||
"readme": "ERROR: No README data found!",
|
||||
"_id": "@lumeweb/kernel-libresolver@0.1.0",
|
||||
"scripts": {
|
||||
"prepare": "presetter bootstrap",
|
||||
"build": "run build",
|
||||
"semantic-release": "semantic-release"
|
||||
},
|
||||
"dependencies": {
|
||||
"@lumeweb/kernel-dns-client": "^0.0.2-develop.1",
|
||||
"@lumeweb/libkernel": "^0.1.0-develop.14",
|
||||
"@lumeweb/libresolver": "^0.0.2-develop.1"
|
||||
},
|
||||
"files": [
|
||||
"lib"
|
||||
],
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
}
|
||||
}
|
||||
|
|
22
src/index.ts
22
src/index.ts
|
@ -1,4 +1,8 @@
|
|||
import { addHandler, ActiveQuery, handleMessage } from "libkmodule";
|
||||
import {
|
||||
addHandler,
|
||||
ActiveQuery,
|
||||
handleMessage,
|
||||
} from "@lumeweb/libkernel/module";
|
||||
|
||||
import type {
|
||||
DNSResult,
|
||||
|
@ -7,21 +11,25 @@ import type {
|
|||
import { DNS_RECORD_TYPE } from "@lumeweb/libresolver";
|
||||
import { dnsClient } from "./client.js";
|
||||
import { DnsClient } from "@lumeweb/kernel-dns-client";
|
||||
import { ResolverOptions } from "@lumeweb/libresolver/src/types.js";
|
||||
import type { ResolverOptions } from "@lumeweb/libresolver";
|
||||
|
||||
let resolver: ResolverModule | ResolverModuleBase;
|
||||
|
||||
export interface ResolverModule {
|
||||
get resolver(): DnsClient;
|
||||
|
||||
set resolver(value: DnsClient);
|
||||
|
||||
resolve(
|
||||
domain: string,
|
||||
options: ResolverOptions,
|
||||
bypassCache: boolean
|
||||
bypassCache: boolean,
|
||||
): Promise<DNSResult>;
|
||||
|
||||
getSupportedTlds(): string[];
|
||||
|
||||
getSupportedTlds(): Promise<string[]>;
|
||||
|
||||
getSupportedTlds(): any;
|
||||
}
|
||||
|
||||
|
@ -51,7 +59,7 @@ async function handleResolve(aq: ActiveQuery) {
|
|||
ret = await resolver.resolve(
|
||||
aq.callerInput.domain,
|
||||
aq.callerInput?.options ?? { type: DNS_RECORD_TYPE.CONTENT },
|
||||
aq.callerInput?.bypassCache || false
|
||||
aq.callerInput?.bypassCache || false,
|
||||
);
|
||||
} catch (e: any) {
|
||||
aq.reject(e);
|
||||
|
@ -70,6 +78,6 @@ function handleGetSupportedTlds(aq: ActiveQuery) {
|
|||
aq.respond(resolver.getSupportedTlds());
|
||||
}
|
||||
|
||||
export * from "@lumeweb/libresolver/dist/util.js";
|
||||
export * from "@lumeweb/libresolver/dist/types.js";
|
||||
export { AbstractResolverModule } from "@lumeweb/libresolver/dist/resolverModule.js";
|
||||
export * from "@lumeweb/libresolver/lib/util.js";
|
||||
export * from "@lumeweb/libresolver/lib/types.js";
|
||||
export { AbstractResolverModule } from "@lumeweb/libresolver/lib/resolverModule.js";
|
||||
|
|
|
@ -1,12 +0,0 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"target": "esnext",
|
||||
"declaration": true,
|
||||
"moduleResolution": "node",
|
||||
"outDir": "./dist",
|
||||
"strict": true,
|
||||
"allowSyntheticDefaultImports": true
|
||||
},
|
||||
"include": ["src"],
|
||||
"exclude": ["node_modules", "**/__tests__/*"]
|
||||
}
|
Loading…
Reference in New Issue