npm.io
3.1.2 • Published 5 years ago

hapi-method-loader

Licence
MIT
Version
3.1.2
Deps
2
Size
17 kB
Vulns
0
Weekly
0

hapi-method-loader Build Status

Automatically loads methods from a directory.

Installation

npm install hapi-method-loader

Usage
server.register({
  register: require('hapi-method-loader'),
  // options: {}
});
Options
  • cwd - Defaults to process.cwd()
  • methods - Relative to cwd. Defaults to methods
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';
    }
  }
};

Keywords