Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
init-system
Advanced tools
Declarative startup/shutdown for your Node.js apps.
This solution has a dependency declarations similar to Linux startup systems or Makefiles. It also has inversion of control similar to middleware.
First we need to declare our services.
// services/my-service.js
module.exports = {
// The name of this service.
provides: 'myService',
// The dependencies of this service.
after: ['config', 'database'],
/*
Below is the startup and shutdown logic.
services: object
This object holds all of the dependencies
declared in "after".
provide: function(value) => Future
A function you need to call to signal
your service is created and ready for use.
*/
service: function*(services, provide) {
// Use your dependencies.
const myService = new MyService(services.config, services.database);
// Let init-system know the service is ready.
const exitCode = yield provide(myService);
// Do our shutdown logic.
myService.close();
// Pass on the exit code.
return exitCode;
}
};
Then in our main script, load them using init-system
.
// index.js
const init = require('init-system');
init.services(
// Ordering is done in the service descriptions,
// so we can simply provide an unsorted array.
[
require('./services/config.js'),
require('./services/my-service.js'),
require('./services/database.js')
],
// Node callback.
function(err, exitCode){
if(err){
console.error(`Error during application startup / shutdown: ${err}`);
} else {
console.log(`Application exitted with ${exitCode}`);
}
}
);
You can call init.services(services, [options], callback)
with an options object to change some behavior.
key | type | description |
---|---|---|
logger | function(message) | Allows you to set a logger for verbose startup / shutdown messages. |
const options = {
// Sets a logger for verbose startup / shutdown messages.
logger: function(message) {
console.log('init-system', message);
}
};
init.services(
[/* services */],
options,
function(err, exitCode) { /* callback */ }
);
FAQs
Declarative startup/shutdown for your Node.js apps.
The npm package init-system receives a total of 6 weekly downloads. As such, init-system popularity was classified as not popular.
We found that init-system 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.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.