
Security News
NVD Concedes Inability to Keep Pace with Surging CVE Disclosures in 2025
Security experts warn that recent classification changes obscure the true scope of the NVD backlog as CVE volume hits all-time highs.
@flexshopper/hapi-methods
Advanced tools
Plugin to autoload methods based on patterns.
hapi-methods
npm package in your project our plugin.
npm i @flexshopper/hapi-methods
const server = new Hapi.Server();
server.connection();
server.register({
register: require('hapi-methods'),
options: {
relativeTo: proccess.cwd() + '/methods',
includes: ['path/to/**/*methods.js'],
ignore: ['*.git'],
}
}, (err) => {
// continue application
});
manifest style:
registrations: [
...
{
plugin: {
register: 'hapi-methods',
options: {
relativeTo: proccess.cwd() + '/methods',
includes: ['path/to/**/*methods.js'],
ignore: ['*.git'],
}
}
}
];
Required
Type: array
The glob pattern you would like to include
Type: array
The pattern or an array of patterns to exclude
Type: string
The current working directory in which to search (defaults to process.cwd()
)
'use strict';
const internals = module.exports = {};
internals.myNewMethod = {
method: (next) => {
return next();
},
options: {
cache: {
expiresIn: 60000,
generateTimeout: 60000
}
}
};
internals.anotherMethod = {
// if method is defined as function(), 'this' value is bound to server instance
method: function(next) {
// 'this' is bound to server, thus it is equal to hapi server instance
expect(this.plugins).to.exist();
return next();
}
};
// This methods would be available as:
server.methods.methodFileName.myNewMethod();
server.methods.methodFileName.anotherMethod();
No matter what format your filenames are in, use camelcase to access the method.
For example, if a method file name is: foo-bar.js
, it has a method named myMethod() inside.
You can access this method as:
server.methods.fooBar.myMethod();
If internals.anotherMethod.method
is equal to regular function (non-arrow function)
'this' will be bound to instance of server
.
FAQs
Hapi plugin to autoload methods.
We found that @flexshopper/hapi-methods demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 7 open source maintainers 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
Security experts warn that recent classification changes obscure the true scope of the NVD backlog as CVE volume hits all-time highs.
Security Fundamentals
Attackers use obfuscation to hide malware in open source packages. Learn how to spot these techniques across npm, PyPI, Maven, and more.
Security News
Join Socket for exclusive networking events, rooftop gatherings, and one-on-one meetings during BSidesSF and RSA 2025 in San Francisco.