node-minibase / minibase

:rocket: Minimal framework for creating highly modular and composable Node.js applications powered by plugins
https://github.com/node-minibase
MIT License
9 stars 0 forks source link

Refactor and use `dush` (v2) #15

Open tunnckoCore opened 7 years ago

tunnckoCore commented 7 years ago

Make it not rely on this and use the dush as core event emitter

tunnckoCore commented 7 years ago

~~Need updates to minibase-is-registered and dush-promise plugins. And probably update minibase-create-plugin~~

/*!
 * minibase <https://github.com/tunnckoCore/minibase>
 *
 * Copyright (c) Charlike Mike Reagent <@tunnckoCore> (https://i.am.charlike.online)
 * Released under the MIT license.
 */

'use strict'

var dush = require('dush')
var extend = require('extend-shallow')
var betterUse = require('dush-better-use')

// from `dush`:
// .on
// .off
// .once
// .emit
// .use
//
// from `dush-better-use` (overrides the default `dush` .use):
// .use
//
// from `minibase-is-registered`:
// .isRegistered
//
// from `dush-methods` (registered at `minibase-is-registered`):
// .define
// .delegate
//

function MiniBase (options) {
  return dush()
    .use(function optionsPlugin (app) {
      app.options = extend({}, options)
      return app
    })
    .use(betterUse())
}

module.exports = MiniBase