Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use egg-layer load framework circular reference #730

Merged
merged 5 commits into from
Nov 24, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
test: change all decorator to @midwayjs/decorator package
  • Loading branch information
czy88840616 committed Nov 23, 2020
commit 4745da013eeffbed54cf3209fa364413bfe2a8ae
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import { async, config, init, plugin, provide } from '../../../../../../src';
import { Async, Config, Init, Plugin, Provide } from '@midwayjs/decorator';

@async()
@provide()
@Async()
@Provide()
export class BaseService {

@config('hello')
@Config('hello')
config;

@plugin('plugin2')
@Plugin('plugin2')
plugin2;

@init()
@Init()
async init() {
await new Promise(resolve => {
setTimeout(() => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,39 +1,39 @@
import { async, config, init, inject, plugin, provide } from '../../../../../../src';
import { Async, Config, Init, Inject, Plugin, Provide } from '@midwayjs/decorator';

@provide()
@Provide()
export class A {
config = {
c: 20
};
}

@provide()
@Provide()
export class B {
config = {
c: 40
};
}

@async()
@provide()
@Async()
@Provide()
export class BaseService {

config;
plugin2;

constructor(
@inject() a,
@config('hello') config,
@inject() b,
@plugin('plugin2') plugin2
@Inject() a,
@Config('hello') config,
@Inject() b,
@Plugin('plugin2') plugin2
) {
this.config = Object.assign(config, {
c: a.config.c + b.config.c + config.c
});
this.plugin2 = plugin2;
}

@init()
@Init()
async init() {
await new Promise(resolve => {
setTimeout(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,30 @@

import { ScopeEnum } from '@midwayjs/decorator';
import {
controller,
get,
inject,
provide,
scope,
} from '../../../../../../../src/';
Controller,
Get,
Inject,
Provide,
Scope,
} from '@midwayjs/decorator';

const assert = require('assert');

@provide()
@scope(ScopeEnum.Request)
@Provide()
@Scope(ScopeEnum.Request)
export class BaseApi {
async index(ctx) {
ctx.body = 'index';
}
}

@provide()
@controller('/components/')
@Provide()
@Controller('/components/')
export class My {
@inject()
@Inject()
logger;

@get('/')
@Get('/')
async index(ctx) {
assert(this.logger.constructor.name === 'ContextLogger');
ctx.body = 'hello';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { provide, controller, get } from '../../../../../../../src/';
import { Provide, Controller, Get } from '@midwayjs/decorator';

@provide()
@controller('/')
@Provide()
@Controller('/')
export class My {
@get('/')
@Get('/')
async index(ctx) {
ctx.body = 'root_test';
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
'use strict';

import { inject, provide, scope, ScopeEnum, controller, get } from '../../../../../../../src/';
import { Inject, Provide, Scope, ScopeEnum, Controller, Get } from '@midwayjs/decorator';

const assert = require('assert');

@provide()
@scope(ScopeEnum.Request)
@Provide()
@Scope(ScopeEnum.Request)
export class BaseApi {
async index(ctx) {
ctx.body = 'index';
}
}

@provide()
@controller('/components/')
@Provide()
@Controller('/components/')
export class Api {

@inject()
@Inject()
logger;

@get('/')
@Get('/')
async index(ctx) {
assert(this.logger.constructor.name === 'ContextLogger');
ctx.body = 'hello';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { provide, controller, get } from '../../../../../../../src/';
import { Provide, Controller, Get } from '@midwayjs/decorator';

@provide()
@controller('/')
@Provide()
@Controller('/')
class My {
@get('/')
@Get('/')
async index(ctx) {
ctx.body = 'root_test';
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { provide, controller, get } from '../../../../../../../src/';
import { Provide, Controller, Get } from '@midwayjs/decorator';
import * as React from 'react';
import * as ReactDOM from 'react-dom/server';
import App from '../../shared/App';

@provide()
@controller('/')
@Provide()
@Controller('/')
export class My {
@get('/')
@Get('/')
async index(ctx) {
ctx.body = `
<!DOCTYPE html>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
'use strict';

import { inject, provide, scope, ScopeEnum, controller, get } from '../../../../../../../src/';
import { Inject, Provide, Scope, ScopeEnum, Controller, Get } from '@midwayjs/decorator';

const assert = require('assert');

@provide()
@scope(ScopeEnum.Request)
@Provide()
@Scope(ScopeEnum.Request)
export class BaseApi {
async index(ctx) {
ctx.body = 'index';
}
}

@provide()
@controller('/components/')
@Provide()
@Controller('/components/')
export class Api {

@inject()
@Inject()
logger;

@get('/')
@Get('/')
async index(ctx) {
assert(this.logger.constructor.name === 'ContextLogger');
ctx.body = 'hello';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { controller, get, provide } from '../../../../../../../src/';
import { Controller, Get, Provide } from '@midwayjs/decorator';

@provide()
@controller('/')
@Provide()
@Controller('/')
export class My {
@get('/')
@Get('/')
async index(ctx) {
ctx.body = 'root_test';
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { provide, controller, get, inject } from '../../../../../../../src';
import { Provide, Controller, Get, Inject } from '@midwayjs/decorator';

@provide()
@controller('/circular')
@Provide()
@Controller('/circular')
export class CircularController {
@inject()
@Inject()
planA: any;

@get('/test')
@Get('/test')
async test(ctx) {
ctx.body = 'success';
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
import { provide, inject, controller, get, config } from '../../../../../../../src';
import { Provide, Inject, Controller, Get, Config } from '@midwayjs/decorator';

@provide()
@controller('/config')
@Provide()
@Controller('/config')
export class ConfigController {

@inject('ctx')
@Inject('ctx')
ctx: any;

// should be 1
@config('hello.a')
@Config('hello.a')
a: number;

// should be 2
@config('hello.e.f')
@Config('hello.e.f')
c: number;

// should be undefined
@config('hello.f')
@Config('hello.f')
d: number;

@config('plugins')
@Config('plugins')
plugins: any;

b: boolean;

constructor(
// should be true
@config('plugins.plugin2') pluginFlag: boolean
@Config('plugins.plugin2') pluginFlag: boolean
) {
this.b = pluginFlag;
}

@get('/test')
@Get('/test')
async test() {
const data = {
a: this.a,
Expand All @@ -42,7 +42,7 @@ export class ConfigController {
this.ctx.body = data;
}

@get('/test2')
@Get('/test2')
async test2() {
this.ctx.body = this.plugins;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
import { provide, inject, controller, get } from '../../../../../../../src';
import { Provide, Inject, Controller, Get } from '@midwayjs/decorator';
import { BaseService } from '../../lib/service';
import { HelloService } from '../../lib/HelloService';

@provide()
@controller('/hello')
@Provide()
@Controller('/hello')
export class HelloController {
name: string[] = ['a', 'b'];

xxx = 'hjjj';

aaaa;

@inject()
@Inject()
helloService: HelloService;

@inject('baseService')
@Inject('baseService')
service: BaseService;

@get('/say')
@Get('/say')
async say(ctx) {
const arr = [];
if (this.service) {
Expand All @@ -31,7 +31,7 @@ export class HelloController {
ctx.body = arr.join(',');
}

@get('/stage')
@Get('/stage')
async doStage(ctx) {
ctx.body = await this.service.doStages();
}
Expand Down
Loading