Solace Event Portal V1 OpenAPI Client for NodeJS

Requirements

  • node 16.x

Install

npm install @solace-labs/ep-v1-openapi-node

Configure OpenAPI Object

import { OpenAPI } from "@solace-labs/ep-v1-openapi-node";

// to use a different base url than specified in the spec:
OpenAPI.BASE = "{base-url}";
OpenAPI.WITH_CREDENTIALS = true;
OpenAPI.CREDENTIALS = "include";
OpenAPI.TOKEN = "{token}";

Example: Create an Application Domain

TODO: write me

import {
  ApplicationDomainResponse,
  ApplicationDomainsService,
} from "@solace-labs/ep-openapi-node";

const applicationDomainResponse: ApplicationDomainResponse =
  await ApplicationDomainsService.createApplicationDomain({
    requestBody: {
      name: "my-application-domain",
    },
  });

Advanced Usage

Use of fetch-with-proxy

Node fetch replaced with fetch-with-proxy.

See node-fetch-with-proxy for details.

Use of a resolver

OpenAPIConfig:

export type OpenAPIConfig = {
  BASE: string | Resolver<string>;
  VERSION: string;
  WITH_CREDENTIALS: boolean;
  CREDENTIALS: 'include' | 'omit' | 'same-origin';
  TOKEN?: string | Resolver<string>;
  USERNAME?: string | Resolver<string>;
  PASSWORD?: string | Resolver<string>;
  HEADERS?: Headers | Resolver<Headers>;
  ENCODE_PATH?: (path: string) => string;
};

Configure OpenAPI Object using a Resolver for the BASE Url:

const getBase = async(): Promise<string> => {
 // set your base ...
 const myBase = ..., or
 const myBase = await ...
 return myBase;
}

// make use of it
OpenAPI.BASE = async() => { return await getBase(); }