JSPM

dynamic-client

0.0.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 65
  • Score
    100M100P100Q64355F
  • License CC0-1.0

Dynamic JavaScript Client for APIs that have an OpenAPI Definition. Emphasis on Easy Navigation of API Paths.

Package Exports

  • dynamic-client

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (dynamic-client) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

dynamic-client

Dynamic JavaScript Client for APIs that have an OpenAPI Definition. Emphasis on Easy Navigation of API Paths.

features

  • Easy Endpoint Navigation
  • Automatic Path Grouping
  • Cross-Platform

install

npm install dynamic-client

usage

import { DynamicClient } from 'dynamic-client';

const client = new DynamicClient({
  url: "https://example.org/api",

  // optional debug level
  // set higher number for more logging
  debugLevel: 1,
});

// fetch api definition file and initialize tree structure
await client.init();

client will looks something like this

{
  _base: "https://example.org/api",
  _debug_level: 1,
  cog: {
    assets: {
      // sends a GET request to https://example.org/api/cog/assets
      get: function({ }) { ... }
    },
    tiles: {
      // sends a GET request to https://example.org/api/cog/tiles with the provided parameters (x, y, z, and url)
      // the function will automatically place the parameters in the url path or as query params
      // depending on the OpenAPI Definition
      get: function({ x, y, z, url }) { ... }
    }
  },
}

and here's a sample request to the /cog/tiles/{z}/{x}/{y}?url={url} endpoint

const result = await client.cog.tiles.get({ z: 8, x: 12, y: 4, url: "https://example.org/data/test.tif" });
// result is an array buffer