hapi-method-loader
v3.1.2
Published
Automatically loads hapi methods
Downloads
63
Readme
hapi-method-loader
Automatically loads methods from a directory.
Installation
npm install hapi-method-loader
Usage
server.register({
register: require('hapi-method-loader'),
// options: {}
});
Options
cwd
- Defaults toprocess.cwd()
methods
- Relative tocwd
. Defaults tomethods
Methods
Each method should be a file in the methods
directory. Sub directories may be used for nested methods. File name will dictate method name.
Each method should export a method function and optionally an options object.
Example:
module.exports = {
method: function(next) {
return next(null, new Date());
},
options: {
cache: {
expiresIn: 60 * 60 * 1000
},
generateKey: function() {
return 'getTimeExample';
}
}
};