Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

express-power

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

express-power

Express with superpowers! Effortless clustering, logging & colors with Express.

  • 1.0.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

express-power npm

Express with superpowers! Effortless clustering, CLI logging & colors with Express.

Express Power

Support us on Patreon to get priority updates on our development plan and voting power on new features.

Installation

Install Express Power with yarn or npm:

yarn add express-power express
npm install express-power express

Usage & Examples

Minimal example

const Power = require("express-power");

const worker = app => {
    app.listen(4000, () => Power.log("Listening on port 4000".green));
};

Power.load({ worker });

Extended Example

const Power = require('express-power');
const {log} = Power;

const master = () => {
    log("app started");
};

const worker = app => {
    app.use((req, res) => res.status(200).send("Hello World"));
    app.listen(4000, () => Power.log("Listening on port 4000".green));
};

let options = {
    workers: 8,
    logToFile: true,
    path: __dirname + "/power.log",
    master,
    worker,
};

Power.load(options);

In production, usage of pm2 to run your Express Power app is strongly recommended.

Options

Power options you can use in Power.load(options);

OptionDefault ValueWhat it does
workers2Number of workers.
logToFilefalseEnable logging to file.
pathappDirectory + '/power.log'Log filename.
master() => {}Function to execute before spawning master process. You can welcome the user and run pre-checks here.
worker() => {}Function to execute after spawning worker process. Your Express app should be handled here.
autoRestarttrueRestarts automatically a worker when it dies. Useful for keeping your process alive when unexpected errors occur.

Full Reference

Require Express Power this way:

const Power = require('express-power');

Now, the exported elements are:

const {load, log, italy} = Power;

Let's see them in detail:

ElementWhat it doesProto
loadPowers Expressload(options)
logPower logs to consolelog(text)
italyColors text as Italian flagitaly(text) / text.italy

Power options you can use in load(main, options);

OptionDefault ValueWhat it does
workers2Number of workers.
logToFilefalseEnable logging to file.
pathappDirectory + '/power.log'Log filename.
master() => {}Function to execute before spawning master process. You can welcome the user and run pre-checks here.
worker() => {}Function to execute after spawning worker process. Your Express app should be handled here.
autoRestarttrueRestarts automatically a worker when it dies. Useful for keeping your process alive when unexpected errors occur.

Notice: this package uses Colors internally, which extends the String prototype.

Contributing

Feel free to open an Issue or send me a direct message.

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

Authors

  • Honeyside - Honeyside

License

This project is licensed under the MIT License - see the LICENSE.md file for details.

Keywords

FAQs

Package last updated on 05 Apr 2021

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc