hapi-method-loader

3.1.2 • Public • Published

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';
    }
  }
};

Readme

Keywords

Package Sidebar

Install

npm i hapi-method-loader

Weekly Downloads

20

Version

3.1.2

License

MIT

Unpacked Size

17.2 kB

Total Files

18

Last publish

Collaborators

  • jga
  • dawnerd
  • ecwillis
  • orthagonal1
  • alaguna
  • aleperez92