grupo

0.0.2 • Public • Published

Grupo!

NPM Version

Run your application as cluster mode in middleware! 🃏

Installation

This is a Node.js module available through the npm registry. Installation is done using the npm install command:

$ npm install grupo

API

import grupo from "grupo";

grupo(options)

Grupo has options as parameter and has own logger in it. You can enable and disable it as you wish by using options. Run your application in cluster mode and choose how many thread you need.

Options

Grupo accepts these properties in the options object.

interface options {
  instance?: number;
  log?: boolean;
}

instance

Instance is counter for how many thread you wan't to use, of course is limit how much you have.

// Will use 3 thread
// The default value is 0, so will use all cores
app.use(
  grupo({
    instance: 3,
  })
);

log

Log is an boolean that turn off and on logs about your cluster.

// Will print logs about cluster
// The default value is true
app.use(
  grupo({
    log: false,
  })
);

Examples

express/connect

var express = require("express");
var grupo = require("grupo");

var app = express();

app.use(grupo(3000));

app.get("/", function (req, res) {
  res.send("hello, world!");
});

app.listen(3000)

vanilla http server

var finalhandler = require("finalhandler");
var http = require("http");
var grupo = require("grupo");

// create "middleware"
var logger = grupo(3000);

http.createServer(function (req, res) {
  var done = finalhandler(req, res);
  logger(req, res, function (err) {
    if (err) return done(err);

    // respond to request
    res.setHeader("content-type", "text/plain");
    res.end("hello, world!");
  });
});

License

MIT

/grupo/

    Package Sidebar

    Install

    npm i grupo

    Weekly Downloads

    1

    Version

    0.0.2

    License

    MIT

    Unpacked Size

    7.46 kB

    Total Files

    7

    Last publish

    Collaborators

    • jacky5341