Coder Social home page Coder Social logo

node-rabbitmq-manager's People

Contributors

cosmincav avatar freakachoo avatar will3942 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

node-rabbitmq-manager's Issues

Users function proposal: listUsers & addUser & deleteUser

Here is a proposal to add listUsers, addUser & deleteUser functions to your Client

listUsers

Function:

Client.prototype.listUsers = function(_cb) {
    let path = '/api/users'
    this.getClient.makeRequest(path, _cb)
    return this
}

Usage:

client.listUsers(function  (err, res) {
            if (err) {
                console.log('listUsers ERR: ', err)
            } else {
                console.log(res)
            }
        })

addUser

Function:

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
}

Usage:

client.addUser({
        user: 'Johndoe',
        password: 'xxxxxx',
        tags: 'administrator',
    },
    function  (err, res) {
    if (err) {
        console.log('ERR: ', err)
    } else {
        console.log(res)
    }
})

deleteUser

Function:

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
}

Usage:

managerClient.deleteUser('Johndoe', function  (err, res) {
    if (err) {
        console.log('ERR: ', err)
    } else {
        console.log(res)
    }
})

rabbitmq-manager incompatible with some RabbitMQ HTTP API 3.7 endpoints

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.

Functions proposal: addUserVhostPermissions & removeUserVhostPermissions

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
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.