@midwayjs/core 3.0.13 → 3.0.14-beta.1
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/CHANGELOG.md +2412 -0
- package/dist/baseFramework.d.ts +1 -1
- package/dist/baseFramework.js +2 -2
- package/dist/common/serviceFactory.d.ts +1 -1
- package/dist/config/config.default.d.ts +3 -0
- package/dist/config/config.default.js +7 -1
- package/dist/context/container.d.ts +1 -1
- package/dist/context/container.js +4 -4
- package/dist/context/requestContainer.d.ts +1 -1
- package/dist/context/requestContainer.js +1 -1
- package/dist/interface.d.ts +2 -1
- package/dist/service/configService.d.ts +12 -3
- package/dist/service/configService.js +38 -8
- package/dist/service/decoratorService.d.ts +1 -1
- package/dist/service/decoratorService.js +2 -2
- package/dist/service/lifeCycleService.js +4 -0
- package/dist/service/loggerService.d.ts +2 -14
- package/dist/service/loggerService.js +4 -79
- package/dist/setup.js +22 -21
- package/dist/util/index.js +2 -1
- package/package.json +2 -2
- package/LICENSE +0 -21
package/dist/baseFramework.d.ts
CHANGED
|
@@ -77,7 +77,7 @@ export declare abstract class BaseFramework<APP extends IMidwayApplication<CTX>,
|
|
|
77
77
|
createLogger(name: string, option?: LoggerOptions): ILogger;
|
|
78
78
|
getProjectName(): string;
|
|
79
79
|
getFrameworkName(): string;
|
|
80
|
-
useMiddleware(
|
|
80
|
+
useMiddleware(middleware: CommonMiddlewareUnion<CTX, ResOrNext, Next>): void;
|
|
81
81
|
getMiddleware(): ContextMiddlewareManager<CTX, ResOrNext, Next>;
|
|
82
82
|
useFilter(Filter: CommonFilterUnion<CTX, ResOrNext, Next>): void;
|
|
83
83
|
protected createMiddlewareManager(): ContextMiddlewareManager<CTX, ResOrNext, Next>;
|
package/dist/baseFramework.js
CHANGED
|
@@ -243,8 +243,8 @@ class BaseFramework {
|
|
|
243
243
|
getFrameworkName() {
|
|
244
244
|
return this.getFrameworkType().name;
|
|
245
245
|
}
|
|
246
|
-
useMiddleware(
|
|
247
|
-
this.middlewareManager.insertLast(
|
|
246
|
+
useMiddleware(middleware) {
|
|
247
|
+
this.middlewareManager.insertLast(middleware);
|
|
248
248
|
}
|
|
249
249
|
getMiddleware() {
|
|
250
250
|
return this.middlewareManager;
|
|
@@ -8,7 +8,7 @@ export declare abstract class ServiceFactory<T> {
|
|
|
8
8
|
get<U = T>(id?: string): U;
|
|
9
9
|
createInstance(config: any, clientName?: any): Promise<T | void>;
|
|
10
10
|
abstract getName(): string;
|
|
11
|
-
protected abstract createClient(config: any, clientName: any): Promise<T | void
|
|
11
|
+
protected abstract createClient(config: any, clientName: any): Promise<T | void> | (T | void);
|
|
12
12
|
protected destroyClient(client: T): Promise<void>;
|
|
13
13
|
stop(): Promise<void>;
|
|
14
14
|
}
|
|
@@ -2,6 +2,9 @@ import { MidwayAppInfo, ServiceFactoryConfigOption } from '../interface';
|
|
|
2
2
|
import type { LoggerOptions } from '@midwayjs/logger';
|
|
3
3
|
declare const _default: (appInfo: MidwayAppInfo) => {
|
|
4
4
|
midwayLogger?: ServiceFactoryConfigOption<LoggerOptions>;
|
|
5
|
+
debug?: {
|
|
6
|
+
recordConfigMergeOrder?: boolean;
|
|
7
|
+
};
|
|
5
8
|
};
|
|
6
9
|
export default _default;
|
|
7
10
|
//# sourceMappingURL=config.default.d.ts.map
|
|
@@ -6,12 +6,15 @@ const path_1 = require("path");
|
|
|
6
6
|
exports.default = (appInfo) => {
|
|
7
7
|
var _a;
|
|
8
8
|
const isDevelopment = (0, util_1.isDevelopmentEnvironment)((0, util_1.getCurrentEnvironment)());
|
|
9
|
+
const logRoot = (_a = process.env[interface_1.MIDWAY_LOGGER_WRITEABLE_DIR]) !== null && _a !== void 0 ? _a : appInfo.root;
|
|
9
10
|
return {
|
|
10
11
|
midwayLogger: {
|
|
11
12
|
default: {
|
|
12
|
-
dir: (0, path_1.join)(
|
|
13
|
+
dir: (0, path_1.join)(logRoot, 'logs', appInfo.name),
|
|
13
14
|
level: isDevelopment ? 'info' : 'warn',
|
|
14
15
|
consoleLevel: isDevelopment ? 'info' : 'warn',
|
|
16
|
+
auditFileDir: (0, path_1.join)(logRoot, 'logs', appInfo.name, '.audit'),
|
|
17
|
+
errorDir: (0, path_1.join)(logRoot, 'logs', appInfo.name),
|
|
15
18
|
},
|
|
16
19
|
clients: {
|
|
17
20
|
coreLogger: {
|
|
@@ -23,6 +26,9 @@ exports.default = (appInfo) => {
|
|
|
23
26
|
},
|
|
24
27
|
},
|
|
25
28
|
},
|
|
29
|
+
debug: {
|
|
30
|
+
recordConfigMergeOrder: isDevelopment,
|
|
31
|
+
},
|
|
26
32
|
};
|
|
27
33
|
};
|
|
28
34
|
//# sourceMappingURL=config.default.js.map
|
|
@@ -36,7 +36,7 @@ export declare class MidwayContainer implements IMidwayContainer, IModuleStore {
|
|
|
36
36
|
protected getIdentifier(target: any): string;
|
|
37
37
|
protected getManagedResolverFactory(): ManagedResolverFactory;
|
|
38
38
|
stop(): Promise<void>;
|
|
39
|
-
ready():
|
|
39
|
+
ready(): void;
|
|
40
40
|
get<T>(identifier: {
|
|
41
41
|
new (...args: any[]): T;
|
|
42
42
|
}, args?: any[], objectContext?: ObjectContext): T;
|
|
@@ -293,10 +293,10 @@ class MidwayContainer {
|
|
|
293
293
|
definition.scope = (options === null || options === void 0 ? void 0 : options.scope) || decorator_1.ScopeEnum.Request;
|
|
294
294
|
definition.createFrom = options === null || options === void 0 ? void 0 : options.createFrom;
|
|
295
295
|
if (definition.srcPath) {
|
|
296
|
-
debug(`[core]: bind id "${definition.name} (${definition.srcPath})"`);
|
|
296
|
+
debug(`[core]: bind id "${definition.name} (${definition.srcPath}) ${identifier}"`);
|
|
297
297
|
}
|
|
298
298
|
else {
|
|
299
|
-
debug(`[core]: bind id "${definition.name}"`);
|
|
299
|
+
debug(`[core]: bind id "${definition.name}" ${identifier}`);
|
|
300
300
|
}
|
|
301
301
|
// inject properties
|
|
302
302
|
const props = (0, decorator_1.getPropertyInject)(target);
|
|
@@ -397,8 +397,8 @@ class MidwayContainer {
|
|
|
397
397
|
await this.getManagedResolverFactory().destroyCache();
|
|
398
398
|
this.registry.clearAll();
|
|
399
399
|
}
|
|
400
|
-
|
|
401
|
-
|
|
400
|
+
ready() {
|
|
401
|
+
this.loadDefinitions();
|
|
402
402
|
}
|
|
403
403
|
get(identifier, args, objectContext) {
|
|
404
404
|
var _a;
|
|
@@ -6,7 +6,7 @@ export declare class MidwayRequestContainer extends MidwayContainer {
|
|
|
6
6
|
init(): void;
|
|
7
7
|
get<T = any>(identifier: any, args?: any): T;
|
|
8
8
|
getAsync<T = any>(identifier: any, args?: any): Promise<T>;
|
|
9
|
-
ready():
|
|
9
|
+
ready(): void;
|
|
10
10
|
getContext(): {};
|
|
11
11
|
}
|
|
12
12
|
//# sourceMappingURL=requestContainer.d.ts.map
|
package/dist/interface.d.ts
CHANGED
|
@@ -248,7 +248,7 @@ export interface IFileDetector {
|
|
|
248
248
|
}
|
|
249
249
|
export interface IConfigService {
|
|
250
250
|
add(configFilePaths: any[]): any;
|
|
251
|
-
addObject(obj: object): any;
|
|
251
|
+
addObject(obj: object, reverse?: boolean): any;
|
|
252
252
|
load(): any;
|
|
253
253
|
getConfiguration(configKey?: string): any;
|
|
254
254
|
clearAllConfig(): any;
|
|
@@ -424,6 +424,7 @@ export interface IMidwayBootstrapOptions {
|
|
|
424
424
|
globalConfig?: Array<{
|
|
425
425
|
[environmentName: string]: Record<string, any>;
|
|
426
426
|
}> | Record<string, any>;
|
|
427
|
+
lazyInitializeFramework?: boolean;
|
|
427
428
|
}
|
|
428
429
|
export interface IConfigurationOptions {
|
|
429
430
|
logger?: ILogger;
|
|
@@ -1,23 +1,32 @@
|
|
|
1
1
|
import { IConfigService, MidwayAppInfo } from '../interface';
|
|
2
2
|
import { MidwayEnvironmentService } from './environmentService';
|
|
3
3
|
import { MidwayInformationService } from './informationService';
|
|
4
|
+
interface ConfigMergeInfo {
|
|
5
|
+
value: any;
|
|
6
|
+
env: string;
|
|
7
|
+
extraPath?: string;
|
|
8
|
+
}
|
|
4
9
|
export declare class MidwayConfigService implements IConfigService {
|
|
5
10
|
private envDirMap;
|
|
6
11
|
private aliasMap;
|
|
12
|
+
private configMergeOrder;
|
|
7
13
|
protected configuration: any;
|
|
8
14
|
protected isReady: boolean;
|
|
9
15
|
protected externalObject: Record<string, unknown>[];
|
|
10
16
|
protected appInfo: MidwayAppInfo;
|
|
11
17
|
protected environmentService: MidwayEnvironmentService;
|
|
12
18
|
protected informationService: MidwayInformationService;
|
|
13
|
-
protected init():
|
|
19
|
+
protected init(): void;
|
|
14
20
|
add(configFilePaths: any[]): void;
|
|
15
|
-
addObject(obj: Record<string, unknown
|
|
21
|
+
addObject(obj: Record<string, unknown>, reverse?: boolean): void;
|
|
16
22
|
private getEnvSet;
|
|
17
23
|
private getConfigEnv;
|
|
18
|
-
load():
|
|
24
|
+
load(): void;
|
|
19
25
|
getConfiguration(configKey?: string): any;
|
|
26
|
+
getConfigMergeOrder(): Array<ConfigMergeInfo>;
|
|
20
27
|
private loadConfig;
|
|
21
28
|
clearAllConfig(): void;
|
|
29
|
+
clearConfigMergeOrder(): void;
|
|
22
30
|
}
|
|
31
|
+
export {};
|
|
23
32
|
//# sourceMappingURL=configService.d.ts.map
|
|
@@ -26,10 +26,11 @@ let MidwayConfigService = class MidwayConfigService {
|
|
|
26
26
|
prod: 'production',
|
|
27
27
|
unittest: 'test',
|
|
28
28
|
};
|
|
29
|
+
this.configMergeOrder = [];
|
|
29
30
|
this.isReady = false;
|
|
30
31
|
this.externalObject = [];
|
|
31
32
|
}
|
|
32
|
-
|
|
33
|
+
init() {
|
|
33
34
|
this.appInfo = {
|
|
34
35
|
pkg: this.informationService.getPkg(),
|
|
35
36
|
name: this.informationService.getProjectName(),
|
|
@@ -72,9 +73,19 @@ let MidwayConfigService = class MidwayConfigService {
|
|
|
72
73
|
}
|
|
73
74
|
}
|
|
74
75
|
}
|
|
75
|
-
addObject(obj) {
|
|
76
|
+
addObject(obj, reverse = false) {
|
|
76
77
|
if (this.isReady) {
|
|
77
|
-
|
|
78
|
+
this.configMergeOrder.push({
|
|
79
|
+
env: 'default',
|
|
80
|
+
extraPath: '',
|
|
81
|
+
value: obj,
|
|
82
|
+
});
|
|
83
|
+
if (reverse) {
|
|
84
|
+
this.configuration = (0, extend_1.extend)(true, obj, this.configuration);
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
(0, extend_1.extend)(true, this.configuration, obj);
|
|
88
|
+
}
|
|
78
89
|
}
|
|
79
90
|
else {
|
|
80
91
|
this.externalObject.push(obj);
|
|
@@ -96,7 +107,7 @@ let MidwayConfigService = class MidwayConfigService {
|
|
|
96
107
|
}
|
|
97
108
|
return splits.pop();
|
|
98
109
|
}
|
|
99
|
-
|
|
110
|
+
load() {
|
|
100
111
|
if (this.isReady)
|
|
101
112
|
return;
|
|
102
113
|
// get default
|
|
@@ -105,8 +116,9 @@ let MidwayConfigService = class MidwayConfigService {
|
|
|
105
116
|
const currentEnvSet = this.getEnvSet(this.environmentService.getCurrentEnvironment());
|
|
106
117
|
// merge set
|
|
107
118
|
const target = {};
|
|
108
|
-
|
|
109
|
-
|
|
119
|
+
const defaultSetLength = defaultSet.size;
|
|
120
|
+
for (const [idx, filename] of [...defaultSet, ...currentEnvSet].entries()) {
|
|
121
|
+
let config = this.loadConfig(filename);
|
|
110
122
|
if (decorator_1.Types.isFunction(config)) {
|
|
111
123
|
// eslint-disable-next-line prefer-spread
|
|
112
124
|
config = config.apply(null, [this.appInfo, target]);
|
|
@@ -120,6 +132,13 @@ let MidwayConfigService = class MidwayConfigService {
|
|
|
120
132
|
else {
|
|
121
133
|
debug('[config]: Loaded config %j', config);
|
|
122
134
|
}
|
|
135
|
+
this.configMergeOrder.push({
|
|
136
|
+
env: idx < defaultSetLength
|
|
137
|
+
? 'default'
|
|
138
|
+
: this.environmentService.getCurrentEnvironment(),
|
|
139
|
+
extraPath: filename,
|
|
140
|
+
value: config,
|
|
141
|
+
});
|
|
123
142
|
(0, extend_1.extend)(true, target, config);
|
|
124
143
|
}
|
|
125
144
|
if (this.externalObject.length) {
|
|
@@ -127,6 +146,11 @@ let MidwayConfigService = class MidwayConfigService {
|
|
|
127
146
|
if (externalObject) {
|
|
128
147
|
debug('[config]: Loaded external object %j', externalObject);
|
|
129
148
|
(0, extend_1.extend)(true, target, externalObject);
|
|
149
|
+
this.configMergeOrder.push({
|
|
150
|
+
env: 'default',
|
|
151
|
+
extraPath: '',
|
|
152
|
+
value: externalObject,
|
|
153
|
+
});
|
|
130
154
|
}
|
|
131
155
|
}
|
|
132
156
|
}
|
|
@@ -139,7 +163,10 @@ let MidwayConfigService = class MidwayConfigService {
|
|
|
139
163
|
}
|
|
140
164
|
return this.configuration;
|
|
141
165
|
}
|
|
142
|
-
|
|
166
|
+
getConfigMergeOrder() {
|
|
167
|
+
return this.configMergeOrder;
|
|
168
|
+
}
|
|
169
|
+
loadConfig(configFilename) {
|
|
143
170
|
let exports = typeof configFilename === 'string'
|
|
144
171
|
? require(configFilename)
|
|
145
172
|
: configFilename;
|
|
@@ -151,6 +178,9 @@ let MidwayConfigService = class MidwayConfigService {
|
|
|
151
178
|
clearAllConfig() {
|
|
152
179
|
this.configuration.clear();
|
|
153
180
|
}
|
|
181
|
+
clearConfigMergeOrder() {
|
|
182
|
+
this.configMergeOrder.length = 0;
|
|
183
|
+
}
|
|
154
184
|
};
|
|
155
185
|
__decorate([
|
|
156
186
|
(0, decorator_1.Inject)(),
|
|
@@ -164,7 +194,7 @@ __decorate([
|
|
|
164
194
|
(0, decorator_1.Init)(),
|
|
165
195
|
__metadata("design:type", Function),
|
|
166
196
|
__metadata("design:paramtypes", []),
|
|
167
|
-
__metadata("design:returntype",
|
|
197
|
+
__metadata("design:returntype", void 0)
|
|
168
198
|
], MidwayConfigService.prototype, "init", null);
|
|
169
199
|
MidwayConfigService = __decorate([
|
|
170
200
|
(0, decorator_1.Provide)(),
|
|
@@ -6,7 +6,7 @@ export declare class MidwayDecoratorService {
|
|
|
6
6
|
private parameterDecoratorMap;
|
|
7
7
|
private aspectService;
|
|
8
8
|
constructor(applicationContext: IMidwayContainer);
|
|
9
|
-
protected init():
|
|
9
|
+
protected init(): void;
|
|
10
10
|
registerPropertyHandler(decoratorKey: string, fn: HandlerFunction): void;
|
|
11
11
|
registerMethodHandler(decoratorKey: string, fn: MethodHandlerFunction): void;
|
|
12
12
|
registerParameterHandler(decoratorKey: string, fn: ParameterHandlerFunction): void;
|
|
@@ -22,7 +22,7 @@ let MidwayDecoratorService = class MidwayDecoratorService {
|
|
|
22
22
|
this.methodDecoratorMap = new Map();
|
|
23
23
|
this.parameterDecoratorMap = new Map();
|
|
24
24
|
}
|
|
25
|
-
|
|
25
|
+
init() {
|
|
26
26
|
// add custom method decorator listener
|
|
27
27
|
this.applicationContext.onBeforeBind(Clzz => {
|
|
28
28
|
// find custom method decorator metadata, include method decorator information array
|
|
@@ -150,7 +150,7 @@ __decorate([
|
|
|
150
150
|
(0, decorator_1.Init)(),
|
|
151
151
|
__metadata("design:type", Function),
|
|
152
152
|
__metadata("design:paramtypes", []),
|
|
153
|
-
__metadata("design:returntype",
|
|
153
|
+
__metadata("design:returntype", void 0)
|
|
154
154
|
], MidwayDecoratorService.prototype, "init", null);
|
|
155
155
|
MidwayDecoratorService = __decorate([
|
|
156
156
|
(0, decorator_1.Provide)(),
|
|
@@ -58,6 +58,10 @@ let MidwayLifeCycleService = class MidwayLifeCycleService {
|
|
|
58
58
|
await this.frameworkService.runFramework();
|
|
59
59
|
// exec onServerReady()
|
|
60
60
|
await this.runContainerLifeCycle(lifecycleInstanceList, 'onServerReady');
|
|
61
|
+
// clear config merge cache
|
|
62
|
+
if (!this.configService.getConfiguration('debug.recordConfigMergeOrder')) {
|
|
63
|
+
this.configService.clearConfigMergeOrder();
|
|
64
|
+
}
|
|
61
65
|
}
|
|
62
66
|
async stop() {
|
|
63
67
|
// stop lifecycle
|
|
@@ -6,22 +6,10 @@ export declare class MidwayLoggerService extends ServiceFactory<ILogger> {
|
|
|
6
6
|
readonly applicationContext: IMidwayContainer;
|
|
7
7
|
configService: MidwayConfigService;
|
|
8
8
|
constructor(applicationContext: IMidwayContainer);
|
|
9
|
-
protected init():
|
|
10
|
-
protected
|
|
11
|
-
midwayLogger: {
|
|
12
|
-
default: {};
|
|
13
|
-
clients: {};
|
|
14
|
-
};
|
|
15
|
-
};
|
|
16
|
-
protected createClient(config: any, name?: string): Promise<void>;
|
|
9
|
+
protected init(): void;
|
|
10
|
+
protected createClient(config: any, name?: string): void;
|
|
17
11
|
getName(): string;
|
|
18
12
|
createLogger(name: any, config: any): ILogger;
|
|
19
13
|
getLogger(name: string): ILogger;
|
|
20
|
-
transformEggLogger(options: any): {
|
|
21
|
-
midwayLogger: {
|
|
22
|
-
default: {};
|
|
23
|
-
clients: {};
|
|
24
|
-
};
|
|
25
|
-
};
|
|
26
14
|
}
|
|
27
15
|
//# sourceMappingURL=loggerService.d.ts.map
|
|
@@ -14,60 +14,18 @@ const decorator_1 = require("@midwayjs/decorator");
|
|
|
14
14
|
const configService_1 = require("./configService");
|
|
15
15
|
const serviceFactory_1 = require("../common/serviceFactory");
|
|
16
16
|
const logger_1 = require("@midwayjs/logger");
|
|
17
|
-
const levelTransform = level => {
|
|
18
|
-
if (!level) {
|
|
19
|
-
return undefined;
|
|
20
|
-
}
|
|
21
|
-
switch (level) {
|
|
22
|
-
case 'NONE':
|
|
23
|
-
case Infinity: // egg logger 的 none 是这个等级
|
|
24
|
-
return 'none';
|
|
25
|
-
case 0:
|
|
26
|
-
case 'DEBUG':
|
|
27
|
-
case 'debug':
|
|
28
|
-
return 'debug';
|
|
29
|
-
case 1:
|
|
30
|
-
case 'INFO':
|
|
31
|
-
case 'info':
|
|
32
|
-
return 'info';
|
|
33
|
-
case 2:
|
|
34
|
-
case 'WARN':
|
|
35
|
-
case 'warn':
|
|
36
|
-
return 'warn';
|
|
37
|
-
case 3:
|
|
38
|
-
case 'ERROR':
|
|
39
|
-
case 'error':
|
|
40
|
-
return 'error';
|
|
41
|
-
default:
|
|
42
|
-
return 'silly';
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
17
|
let MidwayLoggerService = class MidwayLoggerService extends serviceFactory_1.ServiceFactory {
|
|
46
18
|
constructor(applicationContext) {
|
|
47
19
|
super();
|
|
48
20
|
this.applicationContext = applicationContext;
|
|
49
21
|
}
|
|
50
|
-
|
|
22
|
+
init() {
|
|
51
23
|
var _a;
|
|
52
|
-
|
|
53
|
-
if (eggLoggerConfig) {
|
|
54
|
-
this.configService.addObject(eggLoggerConfig);
|
|
55
|
-
}
|
|
56
|
-
await this.initClients(this.configService.getConfiguration('midwayLogger'));
|
|
24
|
+
this.initClients(this.configService.getConfiguration('midwayLogger'));
|
|
57
25
|
// alias inject logger
|
|
58
26
|
(_a = this.applicationContext) === null || _a === void 0 ? void 0 : _a.registerObject('logger', this.getLogger('appLogger'));
|
|
59
27
|
}
|
|
60
|
-
|
|
61
|
-
if (this.configService.getConfiguration('customLogger')) {
|
|
62
|
-
// use egg module
|
|
63
|
-
return this.transformEggLogger(this.configService.getConfiguration());
|
|
64
|
-
}
|
|
65
|
-
else {
|
|
66
|
-
// it will be use other logger
|
|
67
|
-
return;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
async createClient(config, name) {
|
|
28
|
+
createClient(config, name) {
|
|
71
29
|
logger_1.loggers.createLogger(name, config);
|
|
72
30
|
}
|
|
73
31
|
getName() {
|
|
@@ -79,32 +37,6 @@ let MidwayLoggerService = class MidwayLoggerService extends serviceFactory_1.Ser
|
|
|
79
37
|
getLogger(name) {
|
|
80
38
|
return logger_1.loggers.getLogger(name);
|
|
81
39
|
}
|
|
82
|
-
transformEggLogger(options) {
|
|
83
|
-
var _a, _b, _c;
|
|
84
|
-
const transformLoggerConfig = {
|
|
85
|
-
midwayLogger: {
|
|
86
|
-
default: {},
|
|
87
|
-
clients: {},
|
|
88
|
-
},
|
|
89
|
-
};
|
|
90
|
-
if (options.midwayLogger && !options.midwayLogger.default) {
|
|
91
|
-
transformLoggerConfig.midwayLogger.default = {
|
|
92
|
-
dir: options.logger.dir,
|
|
93
|
-
level: levelTransform(options.logger.level),
|
|
94
|
-
consoleLevel: levelTransform(options.logger.consoleLevel),
|
|
95
|
-
};
|
|
96
|
-
}
|
|
97
|
-
const eggCustomLogger = options['customLogger'];
|
|
98
|
-
for (const name in eggCustomLogger) {
|
|
99
|
-
transformLoggerConfig.midwayLogger.clients[name] = {
|
|
100
|
-
fileLogName: (_a = eggCustomLogger[name]) === null || _a === void 0 ? void 0 : _a.file,
|
|
101
|
-
level: levelTransform((_b = eggCustomLogger[name]) === null || _b === void 0 ? void 0 : _b.level),
|
|
102
|
-
consoleLevel: levelTransform((_c = eggCustomLogger[name]) === null || _c === void 0 ? void 0 : _c.consoleLevel),
|
|
103
|
-
};
|
|
104
|
-
cleanUndefinedProperty(transformLoggerConfig.midwayLogger.clients[name]);
|
|
105
|
-
}
|
|
106
|
-
return transformLoggerConfig;
|
|
107
|
-
}
|
|
108
40
|
};
|
|
109
41
|
__decorate([
|
|
110
42
|
(0, decorator_1.Inject)(),
|
|
@@ -114,7 +46,7 @@ __decorate([
|
|
|
114
46
|
(0, decorator_1.Init)(),
|
|
115
47
|
__metadata("design:type", Function),
|
|
116
48
|
__metadata("design:paramtypes", []),
|
|
117
|
-
__metadata("design:returntype",
|
|
49
|
+
__metadata("design:returntype", void 0)
|
|
118
50
|
], MidwayLoggerService.prototype, "init", null);
|
|
119
51
|
MidwayLoggerService = __decorate([
|
|
120
52
|
(0, decorator_1.Provide)(),
|
|
@@ -122,11 +54,4 @@ MidwayLoggerService = __decorate([
|
|
|
122
54
|
__metadata("design:paramtypes", [Object])
|
|
123
55
|
], MidwayLoggerService);
|
|
124
56
|
exports.MidwayLoggerService = MidwayLoggerService;
|
|
125
|
-
function cleanUndefinedProperty(obj) {
|
|
126
|
-
Object.keys(obj).forEach(key => {
|
|
127
|
-
if (obj[key] === undefined) {
|
|
128
|
-
delete obj[key];
|
|
129
|
-
}
|
|
130
|
-
});
|
|
131
|
-
}
|
|
132
57
|
//# sourceMappingURL=loggerService.js.map
|
package/dist/setup.js
CHANGED
|
@@ -53,18 +53,16 @@ async function initializeGlobalApplicationContext(globalOptions) {
|
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
// init default config
|
|
56
|
-
const configService =
|
|
56
|
+
const configService = applicationContext.get(_1.MidwayConfigService);
|
|
57
57
|
configService.add([
|
|
58
58
|
{
|
|
59
59
|
default: config_default_1.default,
|
|
60
60
|
},
|
|
61
61
|
]);
|
|
62
62
|
// init aop support
|
|
63
|
-
|
|
63
|
+
applicationContext.get(_1.MidwayAspectService, [applicationContext]);
|
|
64
64
|
// init decorator service
|
|
65
|
-
|
|
66
|
-
applicationContext,
|
|
67
|
-
]);
|
|
65
|
+
applicationContext.get(_1.MidwayDecoratorService, [applicationContext]);
|
|
68
66
|
if (!globalOptions.imports) {
|
|
69
67
|
globalOptions.imports = [
|
|
70
68
|
(0, _1.safeRequire)((0, path_1.join)(globalOptions.baseDir, 'configuration')),
|
|
@@ -77,7 +75,7 @@ async function initializeGlobalApplicationContext(globalOptions) {
|
|
|
77
75
|
applicationContext.load(configurationModule);
|
|
78
76
|
}
|
|
79
77
|
// bind user code module
|
|
80
|
-
|
|
78
|
+
applicationContext.ready();
|
|
81
79
|
if (globalOptions.globalConfig) {
|
|
82
80
|
if (Array.isArray(globalOptions.globalConfig)) {
|
|
83
81
|
configService.add(globalOptions.globalConfig);
|
|
@@ -87,23 +85,26 @@ async function initializeGlobalApplicationContext(globalOptions) {
|
|
|
87
85
|
}
|
|
88
86
|
}
|
|
89
87
|
// merge config
|
|
90
|
-
|
|
88
|
+
configService.load();
|
|
91
89
|
debug('[core]: Current config = %j', configService.getConfiguration());
|
|
92
|
-
// init logger
|
|
93
|
-
await applicationContext.getAsync(_1.MidwayLoggerService, [applicationContext]);
|
|
94
90
|
// middleware support
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
91
|
+
applicationContext.get(_1.MidwayMiddlewareService, [applicationContext]);
|
|
92
|
+
// it will be delay framework initialize in egg cluster mode
|
|
93
|
+
if (!globalOptions.lazyInitializeFramework) {
|
|
94
|
+
// init logger
|
|
95
|
+
await applicationContext.getAsync(_1.MidwayLoggerService, [
|
|
96
|
+
applicationContext,
|
|
97
|
+
]);
|
|
98
|
+
// framework/config/plugin/logger/app decorator support
|
|
99
|
+
await applicationContext.getAsync(_1.MidwayFrameworkService, [
|
|
100
|
+
applicationContext,
|
|
101
|
+
globalOptions,
|
|
102
|
+
]);
|
|
103
|
+
// lifecycle support
|
|
104
|
+
await applicationContext.getAsync(_1.MidwayLifeCycleService, [
|
|
105
|
+
applicationContext,
|
|
106
|
+
]);
|
|
107
|
+
}
|
|
107
108
|
return applicationContext;
|
|
108
109
|
}
|
|
109
110
|
exports.initializeGlobalApplicationContext = initializeGlobalApplicationContext;
|
package/dist/util/index.js
CHANGED
|
@@ -190,7 +190,8 @@ exports.deprecatedOutput = deprecatedOutput;
|
|
|
190
190
|
const transformRequestObjectByType = (originValue, targetType) => {
|
|
191
191
|
if (targetType === undefined ||
|
|
192
192
|
targetType === null ||
|
|
193
|
-
targetType === Object
|
|
193
|
+
targetType === Object ||
|
|
194
|
+
typeof originValue === 'undefined') {
|
|
194
195
|
return originValue;
|
|
195
196
|
}
|
|
196
197
|
switch (targetType) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@midwayjs/core",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.14-beta.1",
|
|
4
4
|
"description": "midway core",
|
|
5
5
|
"main": "dist/index",
|
|
6
6
|
"typings": "dist/index.d.ts",
|
|
@@ -45,5 +45,5 @@
|
|
|
45
45
|
"engines": {
|
|
46
46
|
"node": ">=12"
|
|
47
47
|
},
|
|
48
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "a603d2348d6141f8f723901498f03a162a037708"
|
|
49
49
|
}
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2013 - Now midwayjs
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|