cosmincav / node-rabbitmq-manager Goto Github PK
View Code? Open in Web Editor NEWNodeJs client for RabbitMQ HTTP API
License: MIT License
NodeJs client for RabbitMQ HTTP API
License: MIT License
When evaluating any NPM package, I look at the github source code to get a pulse on the project e.g. project is still active and any known blocking issues.
It would be help if you could link the npm listing to this repository https://www.npmjs.com/package/http-rabbitmq-manager
Here is a proposal to add listUsers
, addUser
& deleteUser
functions to your Client
Client.prototype.listUsers = function(_cb) {
let path = '/api/users'
this.getClient.makeRequest(path, _cb)
return this
}
client.listUsers(function (err, res) {
if (err) {
console.log('listUsers ERR: ', err)
} else {
console.log(res)
}
})
Client.prototype.addUser = function(body, _cb) {
let path = '/api/users/';
if (!body || !body.user) {
_cb({
message : 'user not provided'
})
return null
} else {
path += encodeURIComponent(body.user)
}
if (typeof body.password === 'undefined' && typeof body.password_hash === 'undefined') {
_cb({
message : 'password or password_hash not provided'
})
return null
}
const payload = {
tags: '',
}
if (typeof body.password !== 'undefined') {
payload.password = body.password
}
if (typeof body.password_hash !== 'undefined') {
payload.password_hash = body.password_hash
}
if (typeof body.tags !== 'undefined') {
payload.tags = body.tags
}
this.putClient.makeRequest(path, payload, _cb)
return this
}
client.addUser({
user: 'Johndoe',
password: 'xxxxxx',
tags: 'administrator',
},
function (err, res) {
if (err) {
console.log('ERR: ', err)
} else {
console.log(res)
}
})
Client.prototype.deleteUser = function(username, _cb) {
let path = '/api/users/';
if (typeof username === 'undefined' || username === null) {
_cb({
message : 'username not provided'
})
return null
} else {
path += encodeURIComponent(username)
}
this.deleteClient.makeRequest(path, _cb)
return this
}
managerClient.deleteUser('Johndoe', function (err, res) {
if (err) {
console.log('ERR: ', err)
} else {
console.log(res)
}
})
While attempting to integrate this into an application I'm building, I ran across a deprecated feature when using getMessages.
In < 3.7, using getMessages() results in a call on an endpoint which expects the boolean parameter 'requeue'.
However, in 3.7, RabbitMQ expects a similar string parameter 'ackmode'.
Using the library against a 3.7 instance of RabbitMQ yields a Status 400 error.
There may be other inconsistencies between versions, but this is the only I've tested.
At the very least, the documentation should be updated to indicate compatibility up to 3.6 of RabbitMQ HTTP Management API.
Client.prototype..addUserVhostPermissions = function({vhost, user, configure = '.*', write = '.*', read = '.*'}, _cb) {
if (typeof vhost === 'undefined' || vhost === null) {
_cb({
message : 'vhost not provided'
})
return null
}
if (typeof user === 'undefined' || user === null) {
_cb({
message : 'user not provided'
})
return null
}
let path = `/api/permissions/${encodeURIComponent(vhost)}/${encodeURIComponent(user)}`
const payload = {
configure,
write,
read,
}
this.putClient.makeRequest(path, payload, _cb)
return this
}
Client.prototype.removeUserVhostPermissions = function({vhost, user}, _cb) {
if (typeof vhost === 'undefined' || vhost === null) {
_cb({
message : 'vhost not provided'
})
return null
}
if (typeof user === 'undefined' || user === null) {
_cb({
message : 'user not provided'
})
return null
}
let path = `/api/permissions/${encodeURIComponent(vhost)}/${encodeURIComponent(user)}`
this.deleteClient.makeRequest(path, _cb)
return this
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.