Skip to content

Commit

Permalink
fix: fix test,remove ctx decorators
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaojue committed Mar 10, 2020
1 parent 18daab0 commit 6b907a6
Show file tree
Hide file tree
Showing 6 changed files with 4 additions and 13 deletions.
3 changes: 1 addition & 2 deletions example/02-comments/services/CommentsModel/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { DarukContext, inject, injectable, provide } from '../../../../src';
import { inject, provide } from '../../../../src';
import Comments from '../../entity/comments';
import Db from '../../glues/connection';

@provide('CommentsModel')
export default class CommentsModel {
@inject('ctx') public ctx: DarukContext;
@inject('Db') public Db: Db;
public async findAllAndCount(page = 0, limit = 10) {
let connection = await this.Db.getConnection();
Expand Down
2 changes: 1 addition & 1 deletion src/core/daruk_default_options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default function getDefaultOptions(
return {
name,
rootPath,
middwareOrder: [],
middlewareOrder: [],
bodyOptions: {},
debug,
gracefulShutdown: {
Expand Down
4 changes: 1 addition & 3 deletions src/core/inversify.config.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { EventEmitter } from 'events';
import { Container, decorate, injectable } from 'inversify';
import { Container } from 'inversify';
import getDecorators from 'inversify-inject-decorators';
import Daruk from './daruk';
import { TYPES } from './types';

const darukContainer = new Container();
let { lazyInject } = getDecorators(darukContainer);
Expand Down
5 changes: 0 additions & 5 deletions src/plugins/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,6 @@ class RouterController implements PluginClass {
next: () => Promise<void>
) {
let instance = new controller();
if (darukContainer.isBound('ctx')) {
darukContainer.rebind('ctx').toConstantValue(ctx);
} else {
darukContainer.bind('ctx').toConstantValue(ctx);
}
await instance[funcName](ctx, next);
// 允许用户在 controller 销毁前执行清理逻辑
if (is.fn(instance._destroy)) {
Expand Down
1 change: 0 additions & 1 deletion test/http-server-shutdown.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
DarukContext,
DarukServer,
get,
injectable,
Next,
TYPES
} from '../src';
Expand Down
2 changes: 1 addition & 1 deletion types/daruk_options.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ type RecursivePartial<T> = {
};

export interface Options {
middwareOrder: string[];
middlewareOrder: string[];
name: string;
rootPath: string;
debug: boolean;
Expand Down

0 comments on commit 6b907a6

Please sign in to comment.