
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
Shinu is a lightweight Node.js library that makes it easy to handle signals and other process events in your application. It provides a simple interface for registering signal handlers and logging process information.
You can install Shinu using npm or yarn:
npm install shinu
or
yarn add shinu
Here's an example of how to use Shinu to handle the SIGINT signal:
const { Shinu } = require('shinu');
const shinu = new Shinu();
shinu.addHandler('SIGINT', (signal) => {
console.log(`Received ${signal}`);
process.exit(0);
});
shinu.start();
In this example, we create a new Shinu instance and add a handler for the SIGINT signal. The handler simply logs a message and exits the process. We then call the start method to begin listening for signals.
By default, Shinu includes handlers for the SIGINT, SIGTERM, and SIGQUIT signals, so you don't need to add these manually.
You can also pass options to the Shinu constructor to customize its behavior:
const { Shinu } = require('shinu');
const shinu = new Shinu({
debug: true,
handlers: [
{
signal: 'SIGUSR1',
handler: (signal) => {
console.log(`Received ${signal}`);
},
},
],
});
shinu.start();
In this example, we pass an options object to the Shinu constructor to enable debug logging and add a custom signal handler for SIGUSR1.
new Shinu(options: IShinuOptions)Creates a new Shinu instance with the specified options.
const shinu = new Shinu({
debug: true,
handlers: [
{
signal: 'SIGUSR1',
handler: (signal) => {
console.log(`Received ${signal}`);
},
},
],
});
options.debugType: boolean
Default: false
Enables debug mode. When debug mode is enabled, Shinu will log detailed process information for each signal received.
options.handlersType: IHandler[]
Default: []
An array of signal handlers to register when the Shinu instance is started.
options.loggerType: (message: string) => void
Default: console.log
A function that will be called to log messages. You can use your own logger or replace the default console.log method.
options.handleUncaughtExceptionType: boolean
Default: false
Enables handling of uncaught exceptions. When this option is enabled, Shinu will log any uncaught exceptions and exit the process.
options.handleUnhandledRejectionType: boolean
Default: false
Enables handling of unhandled rejections. When this option is enabled, Shinu will log any unhandled rejections and exit the process.
shinu.addHandler(signal: signals, handler: handler)Adds a handler function for the specified signal.
shinu.addHandler('SIGUSR1', (signal) => {
console.log(`Received ${signal}`);
});
shinu.removeHandler(signal: signals, handler?: handler)Removes the specified handler function for the specified signal. If no handler function is provided, removes all handlers for the signal.
shinu.removeHandler('SIGUSR1');
shinu.removeAllHandlers()Removes all registered signal handlers.
shinu.removeAllHandlers();
shinu.start()Starts listening for registered signals and runs any associated handlers.
shinu.start();
shinu.isHandlerAdded(signal: signals, handler: handler)Returns true if the specified handler function is registered for the specified signal, false otherwise.
const isHandlerAdded = shinu.isHandlerAdded('SIGUSR1', myHandlerFunction);
This project is licensed under the MIT License. See the LICENSE file for details.
FAQs
Shinu in japanese means Die, and this library pevents your process from dying
We found that shinu 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
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.