@midwayjs/core 3.0.4-beta.1 → 3.0.4
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 +1 -1
- package/dist/interface.d.ts +3 -4
- 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
|
}
|
|
@@ -228,7 +228,7 @@ class MidwayContainer {
|
|
|
228
228
|
configuration.load(module);
|
|
229
229
|
for (const ns of configuration.getNamespaceList()) {
|
|
230
230
|
this.namespaceSet.add(ns);
|
|
231
|
-
debug(`[core]: load configuration in namespace="${ns} complete
|
|
231
|
+
debug(`[core]: load configuration in namespace="${ns}" complete`);
|
|
232
232
|
}
|
|
233
233
|
}
|
|
234
234
|
}
|
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';
|
|
@@ -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>>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@midwayjs/core",
|
|
3
|
-
"version": "3.0.4
|
|
3
|
+
"version": "3.0.4",
|
|
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.4
|
|
24
|
+
"@midwayjs/decorator": "^3.0.4",
|
|
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": "c2a37dd026c7bf3e855f4498691f572ef61396e3"
|
|
48
48
|
}
|