0.9.7 • Published 1 year ago

@polywrap/http-resolver-plugin-js v0.9.7

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

@polywrap/http-resolver-plugin-js

HTTP Resolver Plugin allows the Polywrap JS Client to resolve wrapper URIs using HTTP/S.

Usage

import { PolywrapClient } from "@polywrap/client-js";
import {
  initTestEnvironment,
  providers,
  stopTestEnvironment,
  buildAndDeployWrapperToHttp,
} from "@polywrap/test-env-js";

import { httpResolverPlugin } from "@polywrap/http-resolver-plugin-js";

// query wrapper at HTTP URI
export async function foo({

  await initTestEnvironment();

  // deploy wrapper to local HTTP server
  let { uri } = await buildAndDeployWrapperToHttp({
    wrapperAbsPath: `/path/to/simple-storage`,
    httpProvider: providers.http,
    name: "simple-storage",
  });

  // get wrapper HTTP URI
  const wrapperUri = `http/${uri}`;

  // initialize client with the HTTP Resolver plugin
  client = new PolywrapClient({
    plugins: [
      {
        uri: "wrap://ens/http-uri-resolver.polywrap.eth",
        plugin: httpResolverPlugin({}),
      },
    ],
    interfaces: [
      {
        interface: new Uri("wrap://ens/uri-resolver.core.polywrap.eth"),
        implementations: [
          new Uri("wrap://ens/http-resolver.polywrap.eth"),
        ],
      }
    ]
  });

  // and query the wrapper over HTTP
  const response = await client.getManifest(wrapperUri)

  // we can resolve the HTTP URI in steps
  const resolveUriResult = await client.resolveUri(wrapperUri);
  const response' = await resolveUriResult.wrapper?.getManifest(client);

  await stopTestEnvironment();
})

For more usage examples see src/__tests__.

API

HTTP Resolver Plugin conforms to a generic UriResolver interface that provides tryResolveUri and getFile methods to the Polywrap client and adds HTTP resolution capability to every client method, e.g. getManifest, resolveUri.

0.9.7

1 year ago

0.10.0-pre.10

1 year ago

0.9.6

1 year ago

0.9.5

1 year ago

0.10.0-pre.8

1 year ago

0.10.0-pre.7

1 year ago

0.10.0-pre.6

1 year ago

0.10.0-pre.3

1 year ago

0.10.0-pre.4

1 year ago

0.10.0-pre.1

1 year ago

0.10.0-pre.5

1 year ago

0.9.4

2 years ago

0.9.3

2 years ago

0.9.0

2 years ago

0.9.2

2 years ago

0.9.1

2 years ago

0.10.0-pre.0

2 years ago

0.8.0

2 years ago