Security News
RubyGems.org Adds New Maintainer Role
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
express-power
Advanced tools
Express with superpowers! Effortless clustering, logging & colors with Express.
Express with superpowers! Effortless clustering, CLI logging & colors with Express.
Install Express Power with yarn or npm:
yarn add express-power
npm install express-power
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.
Power options you can use in Power.load(options);
Option | Default Value | What it does |
---|---|---|
workers | 2 | Number of workers. |
logToFile | false | Enable logging to file. |
path | appDirectory + '/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. |
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:
Element | What it does | Proto |
---|---|---|
load | Powers Express | load(options) |
log | Power logs to console | log(text) |
italy | Colors text as Italian flag | italy(text) / text.italy |
Power options you can use in load(main, options);
Option | Default Value | What it does |
---|---|---|
workers | 2 | Number of workers. |
logToFile | false | Enable logging to file. |
path | appDirectory + '/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. |
Notice: this package uses Colors internally, which extends the String prototype.
Feel free to open an Issue or send me a direct message.
We use SemVer for versioning. For the versions available, see the tags on this repository.
This project is licensed under the MIT License - see the LICENSE.md file for details.
FAQs
Express with superpowers! Effortless clustering, logging & colors with Express.
The npm package express-power receives a total of 0 weekly downloads. As such, express-power popularity was classified as not popular.
We found that express-power demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.
Security News
Research
Socket's threat research team has detected five malicious npm packages targeting Roblox developers, deploying malware to steal credentials and personal data.