
Security News
Axios Maintainer Confirms Social Engineering Attack Behind npm Compromise
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.
Singular is modular applications boilerplate. It's using for dependency injection in angular-like way with dependency resolving and asynchronous lazy initialization.
##Installation
Singular could be installed with NPM:
npm i singular
Singular is made for simple configuration and initialization:
const Singular = require('singular');
const singular = new Singular({
config: {
mongo: {
host: 'localhost',
port: 27017,
base: 'testBase',
},
redis: {
host: 'localhost',
port: 6379,
},
users: {
minAge: 18,
},
},
});
singular.module(require('./mongo.js'));
singular.module(require('./redis.js'));
async function addUser(name, age) {
// Get config and initialized mongo and redis clients
const [config, db, redis] = await singular.inject('config', 'mongo', 'redis');
config.users.minAge; // => 18
// ...
}
// ...
Instantiate and configure new singular instance.
const Singular = require('singular');
const config = {
debug: true,
dir: __dirname,
};
const singular = new Singular({config});
Define factories and values using method module. You can do it with methods value or factory too.
singular.module({
// Simple value
value: 1,
// Define value factory
oneFactory() {
return 1;
},
// Define logger options
loggerOptions(app) {
return {
...app.config.logger,
verbose: !! app.config.debug
};
},
// Define logger function with loggerOptions
logger(loggerOptions) {
return function(message) {
if (loggerOptions.verbose) console.log(message);
};
}
});
Inject dependencies with inject method. Inject has aliases configure and run.
// Inject logger and log something
singular.inject((logger) => {
logger('Hello world'); // -> 'Hello world'
});
// Regular promise
singular.inject(['mongo', 'redis'])
.then(([mongo, redis]) => {
// do something with mongo and redis
});
FAQs
Application module system
We found that singular 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
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.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.