Skip to content

Commit

Permalink
Merge branch '1.0.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
yinfxs committed Nov 28, 2017
2 parents 281e6ea + 7c5aac9 commit 2ec33f3
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 12 deletions.
12 changes: 1 addition & 11 deletions lib/application.js
Expand Up @@ -25,7 +25,6 @@ class App extends Koa {
constructor(opts) {
super();
this._koaUse = super.use;

opts = opts || {};
opts.name = opts.name || 'ibird';
opts = Object.assign({
Expand Down Expand Up @@ -135,21 +134,12 @@ class App extends Koa {
if (!addon || !addon.namespace) throw new Error(`'namespace' must be provided`);
options = options || { autoMountRoutes: false, autoUseMiddleware: false, alias: {} };
this._addons[addon.namespace] = addon;

// 触发加载函数
if (typeof addon.onLoad === 'function') {
addon.onLoad(this);
}

// 注册自定义事件
if (addon.pub && Object.keys(addon.pub).length > 0) {
for (let key in addon.pub) {
const prefix = `${addon.namespace}:`;
key = key.startsWith(prefix) ? key : `${prefix}${key}`;
let value = addon.pub[key];
value = typeof value === 'function' ? value(this) : value;
this.emit(key, value);
}
}
// 自动挂载中间件
if (options.autoUseMiddleware && addon.middleware && Object.keys(addon.middleware).length > 0) {
for (const key in addon.middleware) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "ibird",
"version": "1.0.0-alpha.6",
"version": "1.0.0-alpha.7",
"description": "A lightweight and flexible web development framework.",
"main": "lib/index.js",
"repository": {
Expand Down

0 comments on commit 2ec33f3

Please sign in to comment.