Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
* Copyright 2016-present, Dustin Deus (deusdustin@gmail.com)
* All rights reserved.
*
* This source code is licensed under the MIT-style license found in the
* LICENSE file in the root directory of this source tree.
*
*/
const NATS = require('nats')
module.exports = {
// General
NATS_QUEUEGROUP_PREFIX: 'queue',
// NATS conn error codes
NATS_CONN_ERROR_CODES: [
NATS.CONN_ERR,
NATS.SECURE_CONN_REQ,
NATS.NON_SECURE_CONN_REQ,
NATS.CLIENT_CERT_REQ
],
// NATS errors
NATS_TRANSPORT_ERROR: 'Could not connect to NATS!',
NATS_TRANSPORT_CLOSED: 'NATS connection closed!',
NATS_TRANSPORT_CONNECTED: 'Connected!',
NATS_PERMISSION_ERROR: 'NATS permission error',
NATS_TRANSPORT_RECONNECTING: 'NATS reconnecting ...',
NATS_TRANSPORT_RECONNECTED: 'NATS reconnected!',
NATS_TRANSPORT_DISCONNECTED: 'NATS disconnected!',
// Hemera request types
REQUEST_TYPE_PUBSUB: 'pubsub',
REQUEST_TYPE_REQUEST: 'request',
// Application errors
TOPIC_SID_REQUIRED_FOR_DELETION: 'Topic or sid is required for deletion',
const NatsTransport = require('./transport')
const DefaultExtensions = require('./extensions')
const DefaultEncoder = require('./encoder')
const DefaultDecoder = require('./decoder')
const ServerResponse = require('./serverResponse')
const ServerRequest = require('./serverRequest')
const ClientRequest = require('./clientRequest')
const ClientResponse = require('./clientResponse')
const ConfigScheme = require('./configScheme')
const Reply = require('./reply')
const Add = require('./add')
const ExtensionManager = require('./extensionManager')
const { sChildren, sRegisteredPlugins, sReplySent } = require('./symbols')
const { serverExtIterator, clientExtIterator } = require('./extensionRunner')
const natsConnCodes = [NATS.CONN_ERR, NATS.SECURE_CONN_REQ, NATS.NON_SECURE_CONN_REQ, NATS.CLIENT_CERT_REQ]
/**
* @class Hemera
*/
class Hemera {
/**
* Creates an instance of Hemera
*
* @param {Nats} transport
* @param {Config} params
*
* @memberOf Hemera
*/
constructor(transport, params) {
const config = Joi.validate(params || {}, ConfigScheme)
if (config.error) {