Skip to content

Commit

Permalink
chore: refact
Browse files Browse the repository at this point in the history
  • Loading branch information
npmstudy committed Nov 29, 2023
1 parent b38abb1 commit 990e380
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions packages/core/src/fn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ export class Fn extends Plugable {
log(`add ${name}: ${fn}`);
console.log(`this.rpcFunctions[${name}] exisit`);
}
// this.rpcFunctions[name] = fn;
this.fn(name, fn);
}
}
Expand Down Expand Up @@ -94,7 +93,7 @@ export class Fn extends Plugable {
}
before() {
return async (ctx, next) => {
log('pre');
log('before');
const key = ctx.path.replace('/', '').split('/').join('.');

const lastKey = key.split('.').pop();
Expand All @@ -103,18 +102,15 @@ export class Fn extends Plugable {
const supportMethods = [];
httpMethods.forEach(function (m) {
if (lastKey.indexOf(m) != -1) {
// console.log(m);
log(m);
supportMethods.push(m);
return m;
}
});
// console.log(supportMethods);

if (supportMethods.length === 0) {
// if (ctx.path.indexOf(this.prefix) != -1) {
log(ctx.path + ',没有匹配到包含get/post等开头的函数');
await next();
// }
} else if (ctx.method === supportMethods[0]) {
log('匹配到包含get/post等方法的函数');
await next();
Expand All @@ -127,7 +123,7 @@ export class Fn extends Plugable {
supportMethods[0] +
' request from client';
}
// log('beforeOne end');
log('beforeOne end');
};
}
}

0 comments on commit 990e380

Please sign in to comment.