# beanify-autoload

> beanify-autoload

Latest version **3.0.11** (published 2021-10-08) · MIT license · 0 weekly downloads

## Install

```sh
npm install beanify-autoload
pnpm add beanify-autoload
yarn add beanify-autoload
bun add beanify-autoload
```

## Health

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

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.0.11 |
| Published | 2021-10-08 |
| First published | 2019-11-14 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 11.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | beanjs |
| Maintainers | beanjs |
| Keywords | beanify, beanify-plugin, beanify-autoload, micro-service |

## Links

- npm: https://www.npmjs.com/package/beanify-autoload
- Repository: https://github.com/beanify/beanify-autoload
- Homepage: https://github.com/beanify/beanify-autoload#readme
- Issues: https://github.com/beanify/beanify-autoload/issues
- npm.io page: https://npm.io/package/beanify-autoload

## Dependencies (1)

- [beanify](https://npm.io/package/beanify.md) ^3.0.24

## Recent versions

- 3.0.11 (latest) — 2021-10-08
- 3.0.10 — 2021-08-30
- 3.0.9 — 2021-08-28
- 3.0.8 — 2021-08-28
- 3.0.7 — 2021-03-25
- 3.0.6 — 2021-03-05
- 3.0.5 — 2021-01-04
- 3.0.4 — 2020-12-30
- 3.0.3 — 2020-12-25
- 3.0.2 — 2020-12-25
- 3.0.1 — 2020-12-22
- 3.0.0 — 2020-12-22
- 1.0.2 — 2020-04-10
- 1.0.1 — 2019-12-13
- 1.0.0 — 2019-11-14

## README

# beanify-autoload

Convenience plugin for Beanify that loads all plugins found in a directory

## Install

```bash
npm i beanify-autoload --save
```

with yarn

```bash
yarn add beanify-autoload
```

## Usage

```javascript
const Beanify = require('beanify')
const Autoload = require('beanify-autoload')

const path = require('path')

const beanify = Beanify({})

beanify
  .register(Autoload, {
    dir: path.join(__dirname, 'test')
    // dirAsScope: false
    // name: 'aaa'
    // prefix: 'bbb'
  })
  .ready(e => {
    console.log(e && e.message)
    beanify.print()
  })
```

with `route`

```javascript
// ./routes/math/tan.js
const { route } = require('beanify-autoload')

module.exports = route({
  // url:'tan' route.url will be set to the file name, automatically remove the extension
  handler (req, rep) {}
})
```

```javascript
// index.js
const Beanify = require('beanify')
const Autoload = require('beanify-autoload')

const path = require('path')

const beanify = Beanify({})

beanify
  .register(Autoload, {
    dir: path.join(__dirname, 'routes'),
    dirAsScope: true
  })
  .ready(e => {
    console.log(e && e.message)
    beanify.print()
  })
```

## Options

- `dir`: (required) - Base directory containing plugins to be loaded
- `dirAsScope`: Make each directory a new scope.default true
- `ignorePattern`: Regex matching any file that should not be loaded
- `indexPattern`: Regex to override the `index.js` naming convention
- `maxDepth`: Limits the depth at which nested plugins are loaded

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