Skip to content

Commit

Permalink
core: add option to disable default plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
goto-bus-stop committed Dec 31, 2016
1 parent 4aa9495 commit 300fc1d
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions src/Uwave.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,18 @@ import users from './plugins/users';
mongoose.Promise = Promise;

type UwaveOptions = {
mongoose: ?string|Object,
useDefaultPlugins: ?bool,
mongo: ?string|Object,
redis: ?string|Object|Redis
};

export default class UWaveServer extends EventEmitter {
_sources = {};

options = {
useDefaultPlugins: true
};

/**
* Registers middleware on a route
*
Expand All @@ -42,12 +47,14 @@ export default class UWaveServer extends EventEmitter {
this.attachRedisEvents();
this.attachMongooseEvents();

this.use(models());
this.use(booth());
this.use(chat());
this.use(motd());
this.use(playlists());
this.use(users());
if (this.options.useDefaultPlugins) {
this.use(models());
this.use(booth());
this.use(chat());
this.use(motd());
this.use(playlists());
this.use(users());
}

process.nextTick(() => {
this.emit('started');
Expand Down Expand Up @@ -84,6 +91,8 @@ export default class UWaveServer extends EventEmitter {
} else {
this.redis = new Redis({ lazyConnect: true });
}

Object.assign(this.options, options);
}

use(plugin) {
Expand Down

0 comments on commit 300fc1d

Please sign in to comment.