Solace Event Portal Runtime OpenAPI Client for NodeJS

Requirements

  • node 16.x

Install

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

Configure OpenAPI Object

import { OpenAPI } from "@solace-labs/ep-rt-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: Get a list of Environments

import {
  EnvironmentsResponse,
  EnvironmentsService
} from "@solace-labs/ep-rt-openapi-node";

const environmentsResponse: EnvironmentsResponse = await EnvironmentsService.getEnvironments({});

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(); }