3.0.11 • Published 3 years ago

beanify-autoload v3.0.11

Weekly downloads
4
License
MIT
Repository
github
Last release
3 years ago

beanify-autoload

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

Install

npm i beanify-autoload --save

with yarn

yarn add beanify-autoload

Usage

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

// ./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) {}
})
// 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
3.0.11

3 years ago

3.0.10

3 years ago

3.0.8

3 years ago

3.0.9

3 years ago

3.0.7

3 years ago

3.0.6

3 years ago

3.0.5

3 years ago

3.0.4

3 years ago

3.0.3

3 years ago

3.0.2

3 years ago

3.0.1

3 years ago

3.0.0

3 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago