# hapi-method-loader

> Automatically loads hapi methods

Latest version **3.1.2** (published 2021-02-19) · MIT license · 0 weekly downloads

## Install

```sh
npm install hapi-method-loader
pnpm add hapi-method-loader
yarn add hapi-method-loader
bun add hapi-method-loader
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.1.2 |
| Published | 2021-02-19 |
| First published | 2015-10-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 16.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | First+Third |
| Maintainers | jga, dawnerd, ecwillis, orthagonal1, alaguna, aleperez92 |
| Keywords | hapi, methods, auto-load |

## Links

- npm: https://www.npmjs.com/package/hapi-method-loader
- npm.io page: https://npm.io/package/hapi-method-loader

## Dependencies (2)

- [lodash](https://npm.io/package/lodash.md) ^4.17.11
- [directory-files](https://npm.io/package/directory-files.md) ^1.0.0

## Recent versions

- 3.1.2 (latest) — 2021-02-19
- 3.1.1 — 2019-09-18
- 3.1.0 — 2019-05-06
- 2.1.1 — 2018-10-08
- 2.1.0 — 2018-05-13
- 2.0.0 — 2017-11-17
- 1.3.0 — 2017-02-23
- 1.2.0 — 2017-02-02
- 1.1.0 — 2017-01-11
- 1.0.0 — 2016-12-13
- 0.2.0 — 2016-05-21
- 0.1.0 — 2016-05-02
- 0.0.5 — 2015-11-11
- 0.0.4 — 2015-10-26
- 0.0.3 — 2015-10-21
- … 2 more at https://npm.io/package/hapi-method-loader/versions

## README

## hapi-method-loader   [![Build Status](https://travis-ci.org/firstandthird/hapi-method-loader.svg?branch=master)](https://travis-ci.org/firstandthird/hapi-method-loader)

Automatically loads methods from a directory.

### Installation

`npm install hapi-method-loader`

### Usage

```js
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:

```js
module.exports = {
  method: function(next) {
    return next(null, new Date());
  },
  options: {
    cache: {
      expiresIn: 60 * 60 * 1000
    },
    generateKey: function() {
      return 'getTimeExample';
    }
  }
};
```

---
_Source: https://npm.io/package/hapi-method-loader · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
