2.0.0 • Published 1 year ago

@nuskin/solace-sync v2.0.0

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

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:

NameDescriptionRequiredDefault ValueAccepted Values
NODE_ENVspecifies the environment in which the application is runningYes---dev, test, stage, prod
SOLACE_API_TOKENSolace rest API tokenYes---
SEMP_BASIC_AUTHEncoded Basic Auth Credentials for SEMP accessYes---

Pre-requisites

Install

yarn add @nuskin/solace-sync

Project Structure

The folder structure of this app is explained below:

NameDescription
__mocks__Contains jest mocks
__tests__Contains jest tests
srcContains source code
.gitignoreList of files and directories for Git to ignore
jest.config.jsConfiguration options for Jest
jest.util.jsConfiguration options for Jest
.eslintrcConfiguration options for ES Lint
.prettierrcConfiguration options for prettier
package.jsonContains npm dependencies as well as build scripts
.prettierignoreList of files and directories for prettier to ignore
cx.configFile needed for common pipeline to pass
yarn.lockYarn state snapshot
.gitlab-ci.ymlCI pipeline configuration
application.yamlConfiguration 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 ScriptDescription
testRuns tests with coverage using jest. Can be invoked with yarn test
lintRuns 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

1.4.1

1 year ago

1.4.0

1 year ago

2.0.0

1 year ago

1.3.7

1 year ago

1.3.6

2 years ago

1.3.5

2 years ago

1.2.0

2 years ago

1.1.0

2 years ago

1.3.4-ngei-317.3

2 years ago

1.3.4-ngei-317.2

2 years ago

1.3.4-ngei-317.1

2 years ago

1.3.4

2 years ago

1.3.3

2 years ago

1.3.2

2 years ago

1.3.1

2 years ago

1.3.0

2 years ago

1.3.4-ngei-317.5

2 years ago

1.3.4-ngei-317.4

2 years ago

1.0.0

2 years ago