core-services/uBroker/index.js
function addService(service, serviceObject){

    client.get('uServices', function(err, reply) {

        if (reply == null){
            //extend this object
            //add a key with service name and value service channel
            //this is the first service i should activate it
            var newObjectToPush = JSON.parse('{"' + service + '": []}');//found a fancy way to make this
            serviceObject.status = 1;
            newObjectToPush[service].push(serviceObject);

            extend(uServices, newObjectToPush);

            setAndPublish('uServices',uServices,'uServicesChannel', 'UPDATE')

        } else {
            uServices = JSON.parse(reply);
            if (typeof(uServices[service]) !== 'undefined') {

                var uService = uServices[service];
                uService.push(serviceObject);
                //save the new uServices
                uServices[service] = uService;

                setAndPublish('uServices',uServices,'uServicesChannel', 'UPDATE')

            } else {
                //extend this object
                //add a key with service name and value service channel
                var stringObject = '{"' + service + '": []}'; //found a fancy way to make this
                var objectToPush = JSON.parse(stringObject);
                objectToPush[service].push(serviceObject);
                extend(uServices, objectToPush);

                setAndPublish('uServices',uServices,'uServicesChannel', 'UPDATE')
            }
        }
    });
}
function addService(service, serviceObject){

    client.get('uServices', function(err, reply) {

        if (reply == null){
            //extend this object
            //add a key with service name and value service channel
            //this is the first service i should activate it
            var newObjectToPush = JSON.parse('{"' + service + '": []}');//found a fancy way to make this
            serviceObject.status = 1;
            newObjectToPush[service].push(serviceObject);

            extend(uServices, newObjectToPush);

            setAndPublish('uServices',uServices,'uServicesChannel', 'UPDATE')

        } else {
            uServices = JSON.parse(reply);
            if (typeof(uServices[service]) !== 'undefined') {

                var uService = uServices[service];
                uService.push(serviceObject);
                //save the new uServices
                uServices[service] = uService;

                setAndPublish('uServices',uServices,'uServicesChannel', 'UPDATE')

            } else {
                //extend this object
                //add a key with service name and value service channel
                var stringObject = '{"' + service + '": []}'; //found a fancy way to make this
                var objectToPush = JSON.parse(stringObject);
                objectToPush[service].push(serviceObject);
                extend(uServices, objectToPush);

                setAndPublish('uServices',uServices,'uServicesChannel', 'UPDATE')
            }
        }
    });
}
function addService ( service , serviceObject ) { client . get ( 'uServices' , function ( err , reply ) { if ( reply == null ) { //extend this object //add a key with service name and value service channel //this is the first service i should activate it var newObjectToPush = JSON . parse ( '{"' + service + '": []}' ) ; //found a fancy way to make this serviceObject . status = 1 ; newObjectToPush [ service ] . push ( serviceObject ) ; extend ( uServices , newObjectToPush ) ; setAndPublish ( 'uServices' , uServices , 'uServicesChannel' , 'UPDATE' ) } else { uServices = JSON . parse ( reply ) ; if ( typeof ( uServices [ service ] ) !== 'undefined' ) { var uService = uServices [ service ] ; uService . push ( serviceObject ) ; //save the new uServices uServices [ service ] = uService ; setAndPublish ( 'uServices' , uServices , 'uServicesChannel' , 'UPDATE' ) } else { //extend this object //add a key with service name and value service channel var stringObject = '{"' + service + '": []}' ; //found a fancy way to make this var objectToPush = JSON . parse ( stringObject ) ; objectToPush [ service ] . push ( serviceObject ) ; extend ( uServices , objectToPush ) ; setAndPublish ( 'uServices' , uServices , 'uServicesChannel' , 'UPDATE' ) } } } ) ; }
Receive a service name and an object and stored it redis
@addService
@param service {String}
@param serviceObject {Object}
Receive a service name and an object and stored it redis