This package has been deprecated

Author message:

Removing

mf-microservice

0.0.10 • Public • Published

What is Microservice?

Microservice is apart of Microframework modules.

This module give you abilities to create microservice from any local object/module. All public functions will be available to call from external.

Installation

Installation

npm install mf-microserivce

This module require Node.js > 0.12.x

Usage

Require mf-microservice

const microService = require('mf-microservice');

Prepare your object or using any existed object

//Example object
var example = {
    getName: function () {
        return { name: 'example' };
    },
    getVersion: function () {
        return { version: '1.0.1' };
    },
    _protected: function () {
        return { message: 'This function shouldn\'t available' };
    },
    getParams: function () {
        var data = [];
        for(i in arguments){
            data.push(arguments[i]);
        } 
        return data;
    }
}

Use Microservice to provide service from the object

//Implement microservice with cluster support
var app = microService(example);

if (cluster.isMaster) {
    for (var i = 0; i < 4; i++) {
        cluster.fork();
    }
    cluster.on('exit', (worker, code, signal) => {
        console.log(`Worker ${worker.process.pid} died`);
    });
} else {
    app.server.listen(8080);
}

License

This module public under MIT License

Package Sidebar

Install

npm i mf-microservice

Weekly Downloads

0

Version

0.0.10

License

MIT

Last publish

Collaborators

  • tad88dev