
Research
/Security News
Weaponizing Discord for Command and Control Across npm, PyPI, and RubyGems.org
Socket researchers uncover how threat actors weaponize Discord across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.
hapi-mongoose2
Advanced tools
Mongoose plugin for hapi-based servers. Supports connecting to one or multiple databases and look up and register models by connection. The plugin options are:
options
- a connection
or an array of connection
s where:
connection
- an object containing:
uri
- a mongo uri stringalias
- (optional) a database name alias used to namespace connections when multiple are created. otherwise ignored.loadSchemasFrom
- (optional) one of:
mongoose.Schema
object or a function with the signature async function(server)
returning a schema.Mongoose.Schema
elements.options
- (optional) options passed to mongoose
createConnection method. unknown properties are allowed:
auth
- an object with auth credentials
user
password
autoIndex
bufferCommands
connections
- an array of connection
objects as described above.decorations
- (optional) an array of interfaces to be decorated using server.decorate
method. allowed values are server
, request
.Connection and models are accessible under the server.app.mongo
property. When multiple connections are created the database name or alias
is used as namespace for accessing each database properties. Same applies for decorated interfaces.
Models are named as the filename matching the schema pattern. Model name first letter is capitalized by default. e.g. Animal
.
const plugin = {
plugin: require('hapi-mongoose2'),
options: {
connections: [
{
uri: 'mongodb://localhost:27017/myapp'
},
{
alias: 'safebox',
uri: 'mongodb://localhost:27017/secrets',
loadSchemasFrom: [
'src/schemas',
'!.{md,json}'
],
options: {
auth: {
user: 'admin',
password: 'pa55w0rd'
},
autoIndex: false,
bufferCommands: true
}
}
],
decorations: ['request', 'server']
}
};
const server = new Hapi.server();
await server.register(plugin);
// Using database `secrets` from:
// 1 - `server.app` object
// 2 - `request` decorated object
// 3 - `server` decorated object
const { Admin } = server.app.mongo.safebox.models;
await Admin.create({ name: 'Quentin', last: 'Tarantino' });
server.route({
method: 'GET',
path: '/',
handler: function (request) {
const { Admin } = request.mongo.safebox.models;
return Admin.findOne({ name: 'Quentin' }).exec();
}
});
await server.mongo.safebox.connection.close();
mongoose
needs to be installed alongside this plugin in order to work.
FAQs
mongoose plugin for hapi-based servers
The npm package hapi-mongoose2 receives a total of 8 weekly downloads. As such, hapi-mongoose2 popularity was classified as not popular.
We found that hapi-mongoose2 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
Socket researchers uncover how threat actors weaponize Discord across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.
Security News
Socket now integrates with Bun 1.3’s Security Scanner API to block risky packages at install time and enforce your organization’s policies in local dev and CI.
Research
The Socket Threat Research Team is tracking weekly intrusions into the npm registry that follow a repeatable adversarial playbook used by North Korean state-sponsored actors.