@midwayjs/core 3.0.1 → 3.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/baseFramework.d.ts +3 -5
- package/dist/baseFramework.js +8 -17
- package/dist/context/container.js +3 -3
- package/dist/context/managedResolverFactory.d.ts +3 -1
- package/dist/context/managedResolverFactory.js +29 -7
- package/dist/error/framework.d.ts +4 -0
- package/dist/error/framework.js +10 -2
- package/dist/interface.d.ts +4 -5
- package/dist/service/lifeCycleService.js +4 -4
- package/dist/setup.js +3 -2
- package/package.json +5 -5
package/dist/baseFramework.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CommonMiddlewareUnion, IConfigurationOptions, IMidwayApplication, IMidwayBootstrapOptions, IMidwayContainer, IMidwayContext, IMidwayFramework, CommonFilterUnion, CommonMiddleware, MiddlewareRespond } from './interface';
|
|
2
2
|
import { FrameworkType } from '@midwayjs/decorator';
|
|
3
|
-
import { ILogger, LoggerOptions } from '@midwayjs/logger';
|
|
3
|
+
import { ILogger, LoggerOptions, LoggerContextFormat } from '@midwayjs/logger';
|
|
4
4
|
import { MidwayEnvironmentService } from './service/environmentService';
|
|
5
5
|
import { MidwayConfigService } from './service/configService';
|
|
6
6
|
import { MidwayInformationService } from './service/informationService';
|
|
@@ -15,8 +15,8 @@ export declare abstract class BaseFramework<APP extends IMidwayApplication<CTX>,
|
|
|
15
15
|
protected logger: ILogger;
|
|
16
16
|
protected appLogger: ILogger;
|
|
17
17
|
protected defaultContext: {};
|
|
18
|
-
protected
|
|
19
|
-
protected
|
|
18
|
+
protected contextLoggerApplyLogger: string;
|
|
19
|
+
protected contextLoggerFormat: LoggerContextFormat;
|
|
20
20
|
protected middlewareManager: ContextMiddlewareManager<CTX, ResOrNext, Next>;
|
|
21
21
|
protected filterManager: FilterManager<CTX, ResOrNext, Next>;
|
|
22
22
|
protected composeMiddleware: any;
|
|
@@ -49,7 +49,6 @@ export declare abstract class BaseFramework<APP extends IMidwayApplication<CTX>,
|
|
|
49
49
|
abstract applicationInitialize(options: IMidwayBootstrapOptions): any;
|
|
50
50
|
abstract getFrameworkType(): FrameworkType;
|
|
51
51
|
abstract run(): Promise<void>;
|
|
52
|
-
setContextLoggerClass(BaseContextLogger: any): void;
|
|
53
52
|
protected createContextLogger(ctx: CTX, name?: string): ILogger;
|
|
54
53
|
stop(): Promise<void>;
|
|
55
54
|
getAppDir(): string;
|
|
@@ -78,7 +77,6 @@ export declare abstract class BaseFramework<APP extends IMidwayApplication<CTX>,
|
|
|
78
77
|
createLogger(name: string, option?: LoggerOptions): ILogger;
|
|
79
78
|
getProjectName(): string;
|
|
80
79
|
getFrameworkName(): string;
|
|
81
|
-
getDefaultContextLoggerClass(): any;
|
|
82
80
|
useMiddleware(Middleware: CommonMiddlewareUnion<CTX, ResOrNext, Next>): void;
|
|
83
81
|
getMiddleware(): ContextMiddlewareManager<CTX, ResOrNext, Next>;
|
|
84
82
|
useFilter(Filter: CommonFilterUnion<CTX, ResOrNext, Next>): void;
|
package/dist/baseFramework.js
CHANGED
|
@@ -12,7 +12,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.BaseFramework = void 0;
|
|
13
13
|
const interface_1 = require("./interface");
|
|
14
14
|
const decorator_1 = require("@midwayjs/decorator");
|
|
15
|
-
const logger_1 = require("@midwayjs/logger");
|
|
16
15
|
const requestContainer_1 = require("./context/requestContainer");
|
|
17
16
|
const environmentService_1 = require("./service/environmentService");
|
|
18
17
|
const configService_1 = require("./service/configService");
|
|
@@ -32,12 +31,11 @@ class BaseFramework {
|
|
|
32
31
|
this.composeMiddleware = null;
|
|
33
32
|
}
|
|
34
33
|
async init() {
|
|
35
|
-
var _a, _b
|
|
34
|
+
var _a, _b;
|
|
36
35
|
this.configurationOptions = (_a = this.configure()) !== null && _a !== void 0 ? _a : {};
|
|
37
|
-
this.
|
|
38
|
-
(_b = this.configurationOptions.
|
|
39
|
-
this.
|
|
40
|
-
(_c = this.configurationOptions.ContextLoggerApplyLogger) !== null && _c !== void 0 ? _c : 'appLogger';
|
|
36
|
+
this.contextLoggerApplyLogger =
|
|
37
|
+
(_b = this.configurationOptions.contextLoggerApplyLogger) !== null && _b !== void 0 ? _b : 'appLogger';
|
|
38
|
+
this.contextLoggerFormat = this.configurationOptions.contextLoggerFormat;
|
|
41
39
|
this.logger = this.loggerService.getLogger('coreLogger');
|
|
42
40
|
this.appLogger = this.loggerService.getLogger('appLogger');
|
|
43
41
|
return this;
|
|
@@ -86,12 +84,11 @@ class BaseFramework {
|
|
|
86
84
|
getApplication() {
|
|
87
85
|
return this.app;
|
|
88
86
|
}
|
|
89
|
-
setContextLoggerClass(BaseContextLogger) {
|
|
90
|
-
this.BaseContextLoggerClass = BaseContextLogger;
|
|
91
|
-
}
|
|
92
87
|
createContextLogger(ctx, name) {
|
|
93
|
-
const appLogger = this.getLogger(name !== null && name !== void 0 ? name : this.
|
|
94
|
-
return
|
|
88
|
+
const appLogger = this.getLogger(name !== null && name !== void 0 ? name : this.contextLoggerApplyLogger);
|
|
89
|
+
return appLogger.createContextLogger(ctx, {
|
|
90
|
+
contextFormat: this.contextLoggerFormat,
|
|
91
|
+
});
|
|
95
92
|
}
|
|
96
93
|
async stop() {
|
|
97
94
|
await this.beforeStop();
|
|
@@ -162,9 +159,6 @@ class BaseFramework {
|
|
|
162
159
|
};
|
|
163
160
|
return ctx;
|
|
164
161
|
},
|
|
165
|
-
setContextLoggerClass: (BaseContextLogger) => {
|
|
166
|
-
return this.setContextLoggerClass(BaseContextLogger);
|
|
167
|
-
},
|
|
168
162
|
addConfigObject: (obj) => {
|
|
169
163
|
this.configService.addObject(obj);
|
|
170
164
|
},
|
|
@@ -249,9 +243,6 @@ class BaseFramework {
|
|
|
249
243
|
getFrameworkName() {
|
|
250
244
|
return this.getFrameworkType().name;
|
|
251
245
|
}
|
|
252
|
-
getDefaultContextLoggerClass() {
|
|
253
|
-
return logger_1.MidwayContextLogger;
|
|
254
|
-
}
|
|
255
246
|
useMiddleware(Middleware) {
|
|
256
247
|
this.middlewareManager.insertLast(Middleware);
|
|
257
248
|
}
|
|
@@ -165,8 +165,6 @@ class ContainerConfiguration {
|
|
|
165
165
|
return this.namespaceList;
|
|
166
166
|
}
|
|
167
167
|
}
|
|
168
|
-
class ObjectCreateEventTarget extends EventEmitter {
|
|
169
|
-
}
|
|
170
168
|
class MidwayContainer {
|
|
171
169
|
constructor(parent) {
|
|
172
170
|
this._resolverFactory = null;
|
|
@@ -189,7 +187,7 @@ class MidwayContainer {
|
|
|
189
187
|
}
|
|
190
188
|
get objectCreateEventTarget() {
|
|
191
189
|
if (!this._objectCreateEventTarget) {
|
|
192
|
-
this._objectCreateEventTarget = new
|
|
190
|
+
this._objectCreateEventTarget = new EventEmitter();
|
|
193
191
|
}
|
|
194
192
|
return this._objectCreateEventTarget;
|
|
195
193
|
}
|
|
@@ -228,6 +226,7 @@ class MidwayContainer {
|
|
|
228
226
|
configuration.load(module);
|
|
229
227
|
for (const ns of configuration.getNamespaceList()) {
|
|
230
228
|
this.namespaceSet.add(ns);
|
|
229
|
+
debug(`[core]: load configuration in namespace="${ns}" complete`);
|
|
231
230
|
}
|
|
232
231
|
}
|
|
233
232
|
}
|
|
@@ -293,6 +292,7 @@ class MidwayContainer {
|
|
|
293
292
|
const refManaged = new managedResolverFactory_1.ManagedReference();
|
|
294
293
|
refManaged.args = propertyMeta.args;
|
|
295
294
|
refManaged.name = propertyMeta.value;
|
|
295
|
+
refManaged.injectMode = propertyMeta['injectMode'];
|
|
296
296
|
definition.properties.set(propertyMeta['targetKey'], refManaged);
|
|
297
297
|
}
|
|
298
298
|
// inject custom properties
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* 管理对象解析构建
|
|
3
3
|
*/
|
|
4
|
-
import { IManagedInstance, ObjectIdentifier } from '@midwayjs/decorator';
|
|
4
|
+
import { IManagedInstance, InjectModeEnum, ObjectIdentifier } from '@midwayjs/decorator';
|
|
5
5
|
import { IManagedResolver, IObjectDefinition, IManagedResolverFactoryCreateOptions, IMidwayContainer } from '../interface';
|
|
6
6
|
export declare class ManagedReference implements IManagedInstance {
|
|
7
7
|
type: string;
|
|
8
8
|
name: string;
|
|
9
|
+
injectMode: InjectModeEnum;
|
|
9
10
|
args?: any;
|
|
10
11
|
}
|
|
11
12
|
/**
|
|
@@ -52,5 +53,6 @@ export declare class ManagedResolverFactory {
|
|
|
52
53
|
*/
|
|
53
54
|
depthFirstSearch(identifier: string, definition: IObjectDefinition, depth?: string[]): boolean;
|
|
54
55
|
private getObjectEventTarget;
|
|
56
|
+
private checkSingletonInvokeRequest;
|
|
55
57
|
}
|
|
56
58
|
//# sourceMappingURL=managedResolverFactory.d.ts.map
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ManagedResolverFactory = exports.ManagedReference = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* 管理对象解析构建
|
|
6
|
+
*/
|
|
7
|
+
const decorator_1 = require("@midwayjs/decorator");
|
|
4
8
|
const constants_1 = require("../common/constants");
|
|
5
9
|
const interface_1 = require("../interface");
|
|
6
10
|
const util = require("util");
|
|
@@ -24,13 +28,23 @@ class RefResolver {
|
|
|
24
28
|
return constants_1.KEYS.REF_ELEMENT;
|
|
25
29
|
}
|
|
26
30
|
resolve(managed, originName) {
|
|
31
|
+
var _a;
|
|
27
32
|
const mr = managed;
|
|
33
|
+
if (mr.injectMode === decorator_1.InjectModeEnum.Class &&
|
|
34
|
+
!((_a = this.factory.context.parent) !== null && _a !== void 0 ? _a : this.factory.context).hasDefinition(mr.name)) {
|
|
35
|
+
throw new error_1.MidwayMissingImportComponentError(originName);
|
|
36
|
+
}
|
|
28
37
|
return this.factory.context.get(mr.name, mr.args, {
|
|
29
38
|
originName,
|
|
30
39
|
});
|
|
31
40
|
}
|
|
32
41
|
async resolveAsync(managed, originName) {
|
|
42
|
+
var _a;
|
|
33
43
|
const mr = managed;
|
|
44
|
+
if (mr.injectMode === decorator_1.InjectModeEnum.Class &&
|
|
45
|
+
!((_a = this.factory.context.parent) !== null && _a !== void 0 ? _a : this.factory.context).hasDefinition(mr.name)) {
|
|
46
|
+
throw new error_1.MidwayMissingImportComponentError(originName);
|
|
47
|
+
}
|
|
34
48
|
return this.factory.context.getAsync(mr.name, mr.args, {
|
|
35
49
|
originName,
|
|
36
50
|
});
|
|
@@ -113,6 +127,7 @@ class ManagedResolverFactory {
|
|
|
113
127
|
if (definition.properties) {
|
|
114
128
|
const keys = definition.properties.propertyKeys();
|
|
115
129
|
for (const key of keys) {
|
|
130
|
+
this.checkSingletonInvokeRequest(definition, key);
|
|
116
131
|
try {
|
|
117
132
|
inst[key] = this.resolveManaged(definition.properties.get(key), key);
|
|
118
133
|
}
|
|
@@ -202,13 +217,7 @@ class ManagedResolverFactory {
|
|
|
202
217
|
if (definition.properties) {
|
|
203
218
|
const keys = definition.properties.propertyKeys();
|
|
204
219
|
for (const key of keys) {
|
|
205
|
-
|
|
206
|
-
const propertyDefinition = this.context.registry.getDefinition(key);
|
|
207
|
-
if (propertyDefinition.isRequestScope() &&
|
|
208
|
-
!propertyDefinition.allowDowngrade) {
|
|
209
|
-
throw new error_1.MidwaySingletonInjectRequestError(definition.path.name, propertyDefinition.path.name);
|
|
210
|
-
}
|
|
211
|
-
}
|
|
220
|
+
this.checkSingletonInvokeRequest(definition, key);
|
|
212
221
|
try {
|
|
213
222
|
inst[key] = await this.resolveManagedAsync(definition.properties.get(key), key);
|
|
214
223
|
}
|
|
@@ -378,6 +387,19 @@ class ManagedResolverFactory {
|
|
|
378
387
|
}
|
|
379
388
|
return this.context.objectCreateEventTarget;
|
|
380
389
|
}
|
|
390
|
+
checkSingletonInvokeRequest(definition, key) {
|
|
391
|
+
if (definition.isSingletonScope()) {
|
|
392
|
+
const managedRef = definition.properties.get(key);
|
|
393
|
+
if (this.context.hasDefinition(managedRef === null || managedRef === void 0 ? void 0 : managedRef.name)) {
|
|
394
|
+
const propertyDefinition = this.context.registry.getDefinition(managedRef.name);
|
|
395
|
+
if (propertyDefinition.isRequestScope() &&
|
|
396
|
+
!propertyDefinition.allowDowngrade) {
|
|
397
|
+
throw new error_1.MidwaySingletonInjectRequestError(definition.path.name, propertyDefinition.path.name);
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
return true;
|
|
402
|
+
}
|
|
381
403
|
}
|
|
382
404
|
exports.ManagedResolverFactory = ManagedResolverFactory;
|
|
383
405
|
//# sourceMappingURL=managedResolverFactory.js.map
|
|
@@ -12,6 +12,7 @@ export declare const FrameworkErrorEnum: {
|
|
|
12
12
|
readonly DUPLICATE_ROUTER: "MIDWAY_10008";
|
|
13
13
|
readonly USE_WRONG_METHOD: "MIDWAY_10009";
|
|
14
14
|
readonly SINGLETON_INJECT_REQUEST: "MIDWAY_10010";
|
|
15
|
+
readonly MISSING_IMPORTS: "MIDWAY_10011";
|
|
15
16
|
};
|
|
16
17
|
export declare class MidwayCommonError extends MidwayError {
|
|
17
18
|
constructor(message: string);
|
|
@@ -46,4 +47,7 @@ export declare class MidwayUseWrongMethodError extends MidwayError {
|
|
|
46
47
|
export declare class MidwaySingletonInjectRequestError extends MidwayError {
|
|
47
48
|
constructor(singletonScopeName: string, requestScopeName: string);
|
|
48
49
|
}
|
|
50
|
+
export declare class MidwayMissingImportComponentError extends MidwayError {
|
|
51
|
+
constructor(originName: string);
|
|
52
|
+
}
|
|
49
53
|
//# sourceMappingURL=framework.d.ts.map
|
package/dist/error/framework.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MidwaySingletonInjectRequestError = exports.MidwayUseWrongMethodError = exports.MidwayDuplicateRouteError = exports.MidwayResolverMissingError = exports.MidwayConfigMissingError = exports.MidwayFeatureNotImplementedError = exports.MidwayFeatureNoLongerSupportedError = exports.MidwayDefinitionNotFoundError = exports.MidwayParameterError = exports.MidwayCommonError = exports.FrameworkErrorEnum = void 0;
|
|
3
|
+
exports.MidwayMissingImportComponentError = exports.MidwaySingletonInjectRequestError = exports.MidwayUseWrongMethodError = exports.MidwayDuplicateRouteError = exports.MidwayResolverMissingError = exports.MidwayConfigMissingError = exports.MidwayFeatureNotImplementedError = exports.MidwayFeatureNoLongerSupportedError = exports.MidwayDefinitionNotFoundError = exports.MidwayParameterError = exports.MidwayCommonError = exports.FrameworkErrorEnum = void 0;
|
|
4
4
|
const base_1 = require("./base");
|
|
5
5
|
exports.FrameworkErrorEnum = (0, base_1.registerErrorCode)('midway', {
|
|
6
6
|
UNKNOWN: 10000,
|
|
@@ -14,6 +14,7 @@ exports.FrameworkErrorEnum = (0, base_1.registerErrorCode)('midway', {
|
|
|
14
14
|
DUPLICATE_ROUTER: 10008,
|
|
15
15
|
USE_WRONG_METHOD: 10009,
|
|
16
16
|
SINGLETON_INJECT_REQUEST: 10010,
|
|
17
|
+
MISSING_IMPORTS: 10011,
|
|
17
18
|
});
|
|
18
19
|
class MidwayCommonError extends base_1.MidwayError {
|
|
19
20
|
constructor(message) {
|
|
@@ -87,9 +88,16 @@ class MidwayUseWrongMethodError extends base_1.MidwayError {
|
|
|
87
88
|
exports.MidwayUseWrongMethodError = MidwayUseWrongMethodError;
|
|
88
89
|
class MidwaySingletonInjectRequestError extends base_1.MidwayError {
|
|
89
90
|
constructor(singletonScopeName, requestScopeName) {
|
|
90
|
-
const text = `${singletonScopeName} with singleton scope can't implicitly inject ${requestScopeName} with request scope directly, please add @Scope(ScopeEnum.Request, { allowDowngrade: true }) in ${requestScopeName}.`;
|
|
91
|
+
const text = `${singletonScopeName} with singleton scope can't implicitly inject ${requestScopeName} with request scope directly, please add "@Scope(ScopeEnum.Request, { allowDowngrade: true })" in ${requestScopeName} or use "ctx.requestContext.getAsync(${requestScopeName})".`;
|
|
91
92
|
super(text, exports.FrameworkErrorEnum.SINGLETON_INJECT_REQUEST);
|
|
92
93
|
}
|
|
93
94
|
}
|
|
94
95
|
exports.MidwaySingletonInjectRequestError = MidwaySingletonInjectRequestError;
|
|
96
|
+
class MidwayMissingImportComponentError extends base_1.MidwayError {
|
|
97
|
+
constructor(originName) {
|
|
98
|
+
const text = `"${originName}" can't inject and maybe forgot add "{imports: [***]}" in @Configuration.`;
|
|
99
|
+
super(text, exports.FrameworkErrorEnum.MISSING_IMPORTS);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
exports.MidwayMissingImportComponentError = MidwayMissingImportComponentError;
|
|
95
103
|
//# sourceMappingURL=framework.js.map
|
package/dist/interface.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { ObjectIdentifier, IManagedInstance, IMethodAspect, ScopeEnum, FrameworkType } from '@midwayjs/decorator';
|
|
3
|
-
import { ILogger, LoggerOptions } from '@midwayjs/logger';
|
|
3
|
+
import { ILogger, LoggerOptions, LoggerContextFormat } from '@midwayjs/logger';
|
|
4
4
|
import * as EventEmitter from 'events';
|
|
5
5
|
import { ContextMiddlewareManager } from './common/middlewareManager';
|
|
6
6
|
import _default from './config/config.default';
|
|
@@ -203,7 +203,7 @@ export declare type ParameterHandlerFunction = (options: {
|
|
|
203
203
|
originArgs: Array<any>;
|
|
204
204
|
originParamType: any;
|
|
205
205
|
parameterIndex: number;
|
|
206
|
-
}) =>
|
|
206
|
+
}) => any;
|
|
207
207
|
export interface IIdentifierRelationShip {
|
|
208
208
|
saveClassRelation(module: any, namespace?: string): any;
|
|
209
209
|
saveFunctionRelation(ObjectIdentifier: any, uuid: any): any;
|
|
@@ -427,8 +427,8 @@ export interface IMidwayBootstrapOptions {
|
|
|
427
427
|
export interface IConfigurationOptions {
|
|
428
428
|
logger?: ILogger;
|
|
429
429
|
appLogger?: ILogger;
|
|
430
|
-
|
|
431
|
-
|
|
430
|
+
contextLoggerApplyLogger?: string;
|
|
431
|
+
contextLoggerFormat?: LoggerContextFormat;
|
|
432
432
|
}
|
|
433
433
|
export interface IMidwayFramework<APP extends IMidwayApplication<CTX>, CTX extends IMidwayContext, CONFIG extends IConfigurationOptions, ResOrNext = unknown, Next = unknown> {
|
|
434
434
|
app: APP;
|
|
@@ -450,7 +450,6 @@ export interface IMidwayFramework<APP extends IMidwayApplication<CTX>, CTX exten
|
|
|
450
450
|
getCoreLogger(): ILogger;
|
|
451
451
|
createLogger(name: string, options: LoggerOptions): ILogger;
|
|
452
452
|
getProjectName(): string;
|
|
453
|
-
getDefaultContextLoggerClass(): any;
|
|
454
453
|
useMiddleware(Middleware: CommonMiddlewareUnion<CTX, ResOrNext, Next>): void;
|
|
455
454
|
getMiddleware(): ContextMiddlewareManager<CTX, ResOrNext, Next>;
|
|
456
455
|
applyMiddleware(lastMiddleware?: CommonMiddleware<CTX, ResOrNext, Next>): Promise<MiddlewareRespond<CTX, ResOrNext, Next>>;
|
|
@@ -32,7 +32,7 @@ let MidwayLifeCycleService = class MidwayLifeCycleService {
|
|
|
32
32
|
}
|
|
33
33
|
else {
|
|
34
34
|
// 普通类写法
|
|
35
|
-
debug(`[core]: run ${cycle.target.name} init`);
|
|
35
|
+
debug(`[core]: Lifecycle run ${cycle.target.name} init`);
|
|
36
36
|
cycle.instance = await this.applicationContext.getAsync(cycle.target);
|
|
37
37
|
}
|
|
38
38
|
cycle.instance && lifecycleInstanceList.push(cycle);
|
|
@@ -80,7 +80,7 @@ let MidwayLifeCycleService = class MidwayLifeCycleService {
|
|
|
80
80
|
if (Array.isArray(lifecycleInstanceOrList)) {
|
|
81
81
|
for (const cycle of lifecycleInstanceOrList) {
|
|
82
82
|
if (typeof cycle.instance[lifecycle] === 'function') {
|
|
83
|
-
debug(`[core]: run ${cycle.instance.constructor.name} ${lifecycle}`);
|
|
83
|
+
debug(`[core]: Lifecycle run ${cycle.instance.constructor.name} ${lifecycle}`);
|
|
84
84
|
const result = await cycle.instance[lifecycle](this.applicationContext, this.frameworkService.getMainApp());
|
|
85
85
|
if (resultHandler) {
|
|
86
86
|
resultHandler(result);
|
|
@@ -90,7 +90,7 @@ let MidwayLifeCycleService = class MidwayLifeCycleService {
|
|
|
90
90
|
}
|
|
91
91
|
else {
|
|
92
92
|
if (typeof lifecycleInstanceOrList[lifecycle] === 'function') {
|
|
93
|
-
debug(`[core]: run ${lifecycleInstanceOrList.constructor.name} ${lifecycle}`);
|
|
93
|
+
debug(`[core]: Lifecycle run ${lifecycleInstanceOrList.constructor.name} ${lifecycle}`);
|
|
94
94
|
const result = await lifecycleInstanceOrList[lifecycle](this.applicationContext, this.frameworkService.getMainApp());
|
|
95
95
|
if (resultHandler) {
|
|
96
96
|
resultHandler(result);
|
|
@@ -101,7 +101,7 @@ let MidwayLifeCycleService = class MidwayLifeCycleService {
|
|
|
101
101
|
async runObjectLifeCycle(lifecycleInstanceList, lifecycle) {
|
|
102
102
|
for (const cycle of lifecycleInstanceList) {
|
|
103
103
|
if (typeof cycle.instance[lifecycle] === 'function') {
|
|
104
|
-
debug(`[core]: run ${cycle.instance.constructor.name} ${lifecycle}`);
|
|
104
|
+
debug(`[core]: Lifecycle run ${cycle.instance.constructor.name} ${lifecycle}`);
|
|
105
105
|
return this.applicationContext[lifecycle](cycle.instance[lifecycle].bind(cycle.instance));
|
|
106
106
|
}
|
|
107
107
|
}
|
package/dist/setup.js
CHANGED
|
@@ -11,6 +11,7 @@ const debug = util.debuglog('midway:debug');
|
|
|
11
11
|
async function initializeGlobalApplicationContext(globalOptions) {
|
|
12
12
|
var _a, _b, _c, _d;
|
|
13
13
|
debug('[core]: start "initializeGlobalApplicationContext"');
|
|
14
|
+
debug(`[core]: bootstrap options = ${util.inspect(globalOptions)}`);
|
|
14
15
|
const appDir = (_a = globalOptions.appDir) !== null && _a !== void 0 ? _a : '';
|
|
15
16
|
const baseDir = (_b = globalOptions.baseDir) !== null && _b !== void 0 ? _b : '';
|
|
16
17
|
// new container
|
|
@@ -37,14 +38,14 @@ async function initializeGlobalApplicationContext(globalOptions) {
|
|
|
37
38
|
// bind inner service
|
|
38
39
|
applicationContext.bindClass(_1.MidwayEnvironmentService);
|
|
39
40
|
applicationContext.bindClass(_1.MidwayInformationService);
|
|
41
|
+
applicationContext.bindClass(_1.MidwayAspectService);
|
|
40
42
|
applicationContext.bindClass(_1.MidwayDecoratorService);
|
|
41
43
|
applicationContext.bindClass(_1.MidwayConfigService);
|
|
42
|
-
applicationContext.bindClass(_1.MidwayAspectService);
|
|
43
44
|
applicationContext.bindClass(_1.MidwayLoggerService);
|
|
45
|
+
applicationContext.bindClass(_1.MidwayApplicationManager);
|
|
44
46
|
applicationContext.bindClass(_1.MidwayFrameworkService);
|
|
45
47
|
applicationContext.bindClass(_1.MidwayMiddlewareService);
|
|
46
48
|
applicationContext.bindClass(_1.MidwayLifeCycleService);
|
|
47
|
-
applicationContext.bindClass(_1.MidwayApplicationManager);
|
|
48
49
|
// bind preload module
|
|
49
50
|
if (globalOptions.preloadModules && globalOptions.preloadModules.length) {
|
|
50
51
|
for (const preloadModule of globalOptions.preloadModules) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@midwayjs/core",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.6",
|
|
4
4
|
"description": "midway core",
|
|
5
5
|
"main": "dist/index",
|
|
6
6
|
"typings": "dist/index.d.ts",
|
|
@@ -21,18 +21,18 @@
|
|
|
21
21
|
],
|
|
22
22
|
"license": "MIT",
|
|
23
23
|
"devDependencies": {
|
|
24
|
-
"@midwayjs/decorator": "^3.0.
|
|
24
|
+
"@midwayjs/decorator": "^3.0.6",
|
|
25
25
|
"koa": "2.13.4",
|
|
26
26
|
"midway-test-component": "*",
|
|
27
27
|
"mm": "3.2.0",
|
|
28
|
-
"sinon": "
|
|
28
|
+
"sinon": "13.0.1"
|
|
29
29
|
},
|
|
30
30
|
"peerDependencies": {
|
|
31
31
|
"@midwayjs/decorator": "*"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@midwayjs/glob": "^1.0.2",
|
|
35
|
-
"@midwayjs/logger": "^2.
|
|
35
|
+
"@midwayjs/logger": "^2.15.0",
|
|
36
36
|
"class-transformer": "^0.5.1",
|
|
37
37
|
"picomatch": "2.3.1"
|
|
38
38
|
},
|
|
@@ -44,5 +44,5 @@
|
|
|
44
44
|
"engines": {
|
|
45
45
|
"node": ">=12"
|
|
46
46
|
},
|
|
47
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "afaa5b59a2be85e915233a9268c0e05965dd5c61"
|
|
48
48
|
}
|