Skip to content

Commit

Permalink
chore: refact
Browse files Browse the repository at this point in the history
  • Loading branch information
npmstudy committed Nov 5, 2023
1 parent ed5c616 commit 8f7822f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/core2/demo.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Plugable from './src/base';
import { Plugable } from './src/base';
export default class Fn extends Plugable {
// public name: string;

Expand Down
2 changes: 1 addition & 1 deletion packages/core2/src/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export interface Strategy {
serverConfig;
}

export default class Plugable implements Strategy {
export class Plugable implements Strategy {
public init: any[] = [];
public load: any[] = [];
public name;
Expand Down
8 changes: 5 additions & 3 deletions packages/core2/src/fn.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import debug from 'debug';

import Plugable from './base';
import { Plugable } from './base';
import { isArrowFunction, getHttpMethods } from './utils';
const log = debug('@tomrpc/core');

Expand Down Expand Up @@ -94,8 +94,10 @@ export class Fn extends Plugable {
// console.log(supportMethods);

if (supportMethods.length === 0) {
console.log(ctx.path + ',没有匹配到包含get/post等开头的函数');
await next();
if (ctx.path.indexOf(this.prefix) != -1) {
console.log(ctx.path + ',没有匹配到包含get/post等开头的函数');
await next();
}
} else if (ctx.method === supportMethods[0]) {
log('匹配到包含get/post等方法的函数');
await next();
Expand Down

0 comments on commit 8f7822f

Please sign in to comment.