Module containing util functions for RabbitMq
- Source:
Members
-
<inner> service :Object
-
Type:
- Object
- Source:
Properties:
Name Type Description buildRabbitMqUrl(String)
function build amqp connection string
validateJson(String)
function validate string is in valid JSON format
cleanData(String)
function change $type to type
Methods
-
<inner> buildRabbitMqUrl(config)
-
Builds the RabbitMqUrl connection string
Parameters:
Name Type Description config
String configuration for connection string
- Source:
Returns:
amqpConnString - returns amqp connection string
- Type
- String
Example
var util = require('rabbit.util.js'); var config = { rabbitmqserver: 'localhost', rabbitmqport: 5672, rabbitmqusername: 'User_Name', rabbitmqpassword: 'Pass_Word', subscribequeue: 'Your.Target.Queue', vhost: 'YOUR-VHOST' }; var connString = util.buildRabbitMqUrl(config) console.log(connString);
-
<inner> cleanData(data)
-
parses through string and replaces "$type" by "type"
Parameters:
Name Type Description data
String string to replace "$type" by "type"
- Source:
Returns:
- Type
- string | void | XML
Example
var util = require('rabbit.util.js') var testString = 'foo $type Bar'; console.log(util.cleanData(testString)); // will print 'foo type Bar'
-
<inner> IsJsonString(str)
-
Checks string to see if it is valid JSON
Parameters:
Name Type Description str
String string to check if is valid JSON
- Source:
Returns:
- true if string is JSON formatted, false if string is not JSON formatted
- Type
- boolean
Example
var util = require('rabbit.util.js') var testString = '{"employee":"John"}'; console.log(util.IsJsonString(testString)); // will print true because the string is valid JSON