*Update api usage
This commit is contained in:
parent
bce2e9e4fc
commit
30f48f81ac
|
@ -6,10 +6,11 @@
|
||||||
"build": "bash build.sh"
|
"build": "bash build.sh"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@lumeweb/relay": "https://github.com/LumeWeb/relay.git",
|
"@types/node": "^18.11.10",
|
||||||
"esbuild": "^0.15.5"
|
"esbuild": "^0.15.5"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@lumeweb/relay-types": "https://git.lumeweb.com/LumeWeb/relay-types.git",
|
||||||
"hs-client": "^0.0.11",
|
"hs-client": "^0.0.11",
|
||||||
"hsd": "https://github.com/LumeWeb/hsd.git#spv-namestate",
|
"hsd": "https://github.com/LumeWeb/hsd.git#spv-namestate",
|
||||||
"random-key": "^0.3.2"
|
"random-key": "^0.3.2"
|
||||||
|
|
15
src/index.ts
15
src/index.ts
|
@ -1,9 +1,4 @@
|
||||||
import type {
|
import type { Plugin, PluginAPI } from "@lumeweb/relay-types";
|
||||||
Plugin,
|
|
||||||
PluginAPI,
|
|
||||||
RPCResponse,
|
|
||||||
RPCRequest,
|
|
||||||
} from "@lumeweb/relay";
|
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
import rand from "random-key";
|
import rand from "random-key";
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
|
@ -88,10 +83,10 @@ const plugin: Plugin = {
|
||||||
|
|
||||||
api.registerMethod("getnameresource", {
|
api.registerMethod("getnameresource", {
|
||||||
cacheable: true,
|
cacheable: true,
|
||||||
async handler(request: RPCRequest): Promise<RPCResponse> {
|
async handler(name: string): Promise<any> {
|
||||||
let resp;
|
let resp;
|
||||||
try {
|
try {
|
||||||
resp = await client.execute("getnameresource", request.data);
|
resp = await client.execute("getnameresource", name);
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
e = e as Error;
|
e = e as Error;
|
||||||
const eType = e.type.toLowerCase();
|
const eType = e.type.toLowerCase();
|
||||||
|
@ -107,9 +102,7 @@ const plugin: Plugin = {
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return resp;
|
||||||
data: resp,
|
|
||||||
};
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue