New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

mf-microservice

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mf-microservice

API as a microservice

latest
Source
npmnpm
Version
0.0.10
Version published
Maintainers
1
Created
Source

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

Keywords

microservice

FAQs

Package last updated on 22 Dec 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts