@nuskin/solace-sync

2.0.0 • Public • Published

Solace Sync Library

Purpose

This package provides a series of Configuration as Code solutions for building out resources in Solace:

  • application
    • deleteSolaceApplication
    • getSolaceApplications
    • parseConfig
    • syncApplication
  • queue
    • createQueue
    • deleteSolaceQueue
    • syncQueues
    • getSolaceQueue
    • getSolaceQueues
  • subscription
    • createQueueSubscription
    • deleteSolaceQueueSubscription
    • getSolaceQueueSubscription
    • getSolaceQueueSubscriptions
    • syncQueueSubscriptions
  • event
    • syncEvent
  • schema
    • syncSchema
  • applicationDomain

Install

yarn add @nuskin/solace-sync

Usage

'use strict';

// Import library
const solaceSync = require('@nuskin/solace-sync');

// Get list of applications on Solace
const solaceApplications = await getSolaceApplications();

// Sync applications between config and Solace
const application = await syncApplication(config, solaceApplications);

// Sync queues between config and Solace
const queues = await syncQueues(config['queues']);

// Sync queue subscriptions
const queueSubscriptions = await config['queues'].reduce(
  async (promise, queue) => {
    const accum = await promise;
    if (_.isEmpty(queue['subscriptions'])) return accum;
    const subs = await syncQueueSubscriptions(
      queue['queueName'],
      queue['subscriptions']
    );
    return _.union(accum, subs);
  },
  Promise.resolve([])
);

// Sync events between config and Solace, {source} is the path to begin search for .yaml configuration files
await syncEvents(source);

// Sync schemas between config and Solace, {source} is the path to begin search for .json configuration files
await syncSchemas(source);

Environment vars

This project uses the following environment variables:

Name Description Required Default Value Accepted Values
NODE_ENV specifies the environment in which the application is running Yes --- dev, test, stage, prod
SOLACE_API_TOKEN Solace rest API token Yes ---
SEMP_BASIC_AUTH Encoded Basic Auth Credentials for SEMP access Yes ---

Pre-requisites

Install

yarn add @nuskin/solace-sync

Project Structure

The folder structure of this app is explained below:

Name Description
__mocks__ Contains jest mocks
__tests__ Contains jest tests
src Contains source code
.gitignore List of files and directories for Git to ignore
jest.config.js Configuration options for Jest
jest.util.js Configuration options for Jest
.eslintrc Configuration options for ES Lint
.prettierrc Configuration options for prettier
package.json Contains npm dependencies as well as build scripts
.prettierignore List of files and directories for prettier to ignore
cx.config File needed for common pipeline to pass
yarn.lock Yarn state snapshot
.gitlab-ci.yml CI pipeline configuration
application.yaml Configuration file

Building the project

Running the build

All the different build steps are orchestrated via yarn scripts. yarn scripts basically allow us to call (and chain) terminal commands via npm.

yarn Script Description
test Runs tests with coverage using jest. Can be invoked with yarn test
lint Runs ESLint on project files. Can be invoked with yarn lint

Testing

The tests and assertions use Jest. Testing also utilizes eslint and prettier plugins.

"@babel/core": "7.18.5",
"@jest/globals": "28.1.1",
"@nuskin/docdash": "1.0.1",
"eslint": "8.18.0",
"eslint-config-google": "0.14.0",
"eslint-config-prettier": "8.5.0",
"eslint-plugin-jsdoc": "39.3.3",
"eslint-plugin-json": "3.1.0",
"eslint-plugin-prettier": "4.0.0",
"jest": "28.1.1",
"jest-runner-eslint": "1.0.1",
"jest-runner-prettier": "1.0.0",
"jest-sonar-reporter": "2.0.0",
"jsdoc": "3.6.10",
"prettier": "2.7.1"

Running tests using yarn Scripts

yarn test

ESLint

ESLint is a code linter that helps catch minor code quality and style issues.

ESLint rules

All rules are configured through .eslintrc.

Running ESLint

To run ESLint you can call the ESLint task.

yarn lint  // runs only ES lint

Common Issues

Readme

Keywords

none

Package Sidebar

Install

npm i @nuskin/solace-sync

Weekly Downloads

11

Version

2.0.0

License

MIT

Unpacked Size

50.8 kB

Total Files

17

Last publish

Collaborators

  • nkranendonk
  • emoore
  • nuskin-cws
  • klau
  • rellenberger
  • aallani