Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
hapi-aerospike
Advanced tools
This is a plugin to share a common MongoDB connection pool across the whole Hapi server.
Options can be a single object with the following keys or an array of the same kind if you need multiple connections :
mongodb://user:pass@localhost:27017
),
mongodb://localhost:27017
Several objects are exposed by this plugin :
db
: connection object to the database, if an array was provided for the configuration, it will be an array of connections in the same orderlib
: mongodb library in case you need to use itObjectID
: mongodb ObjectID constructor in case you need to use itUsage example :
var Hapi = require("hapi");
var Boom = require("boom");
var dbOpts = {
"url": "mongodb://localhost:27017/test",
"settings": {
"db": {
"native_parser": false
}
}
};
var server = new Hapi.Server();
server.register({
register: require('hapi-mongodb'),
options: dbOpts
}, function (err) {
if (err) {
console.error(err);
throw err;
}
});
server.route( {
"method" : "GET",
"path" : "/users/{id}",
"handler" : usersHandler
});
function usersHandler(request, reply) {
var db = request.server.plugins['hapi-mongodb'].db;
var ObjectID = request.server.plugins['hapi-mongodb'].ObjectID;
db.collection('users').findOne({ "_id" : new ObjectID(request.params.id) }, function(err, result) {
if (err) return reply(Boom.internal('Internal MongoDB error', err));
reply(result);
});
};
server.start(function() {
console.log("Server started at " + server.info.uri);
});
Huge thanks to @dypsilon for his help into the making of this plugin.
FAQs
A simple Hapi Aerospike connection plugin.
The npm package hapi-aerospike receives a total of 1 weekly downloads. As such, hapi-aerospike popularity was classified as not popular.
We found that hapi-aerospike 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
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.