@midwayjs/core 3.0.14-beta.1 → 3.1.0
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/LICENSE +21 -0
- package/dist/baseFramework.d.ts +0 -2
- package/dist/baseFramework.js +34 -5
- package/dist/common/applicationManager.js +3 -1
- package/dist/interface.d.ts +2 -1
- package/dist/interface.js +2 -1
- package/package.json +2 -2
- package/CHANGELOG.md +0 -2412
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
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.
|
package/dist/baseFramework.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { CommonMiddlewareUnion, IConfigurationOptions, IMidwayApplication, IMidwayBootstrapOptions, IMidwayContainer, IMidwayContext, IMidwayFramework, CommonFilterUnion, CommonMiddleware, MiddlewareRespond } from './interface';
|
|
2
|
-
import { FrameworkType } from '@midwayjs/decorator';
|
|
3
2
|
import { ILogger, LoggerOptions, LoggerContextFormat } from '@midwayjs/logger';
|
|
4
3
|
import { MidwayEnvironmentService } from './service/environmentService';
|
|
5
4
|
import { MidwayConfigService } from './service/configService';
|
|
@@ -47,7 +46,6 @@ export declare abstract class BaseFramework<APP extends IMidwayApplication<CTX>,
|
|
|
47
46
|
getCurrentEnvironment(): string;
|
|
48
47
|
getApplication(): APP;
|
|
49
48
|
abstract applicationInitialize(options: IMidwayBootstrapOptions): any;
|
|
50
|
-
abstract getFrameworkType(): FrameworkType;
|
|
51
49
|
abstract run(): Promise<void>;
|
|
52
50
|
protected createContextLogger(ctx: CTX, name?: string): ILogger;
|
|
53
51
|
stop(): Promise<void>;
|
package/dist/baseFramework.js
CHANGED
|
@@ -86,9 +86,36 @@ class BaseFramework {
|
|
|
86
86
|
}
|
|
87
87
|
createContextLogger(ctx, name) {
|
|
88
88
|
const appLogger = this.getLogger(name !== null && name !== void 0 ? name : this.contextLoggerApplyLogger);
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
89
|
+
if (name) {
|
|
90
|
+
let ctxLoggerCache = ctx.getAttr(interface_1.REQUEST_CTX_LOGGER_CACHE_KEY);
|
|
91
|
+
if (!ctxLoggerCache) {
|
|
92
|
+
ctxLoggerCache = new Map();
|
|
93
|
+
ctx.setAttr(interface_1.REQUEST_CTX_LOGGER_CACHE_KEY, ctxLoggerCache);
|
|
94
|
+
}
|
|
95
|
+
if (!name) {
|
|
96
|
+
name = 'appLogger';
|
|
97
|
+
}
|
|
98
|
+
// if logger exists
|
|
99
|
+
if (ctxLoggerCache.has(name)) {
|
|
100
|
+
return ctxLoggerCache.get(name);
|
|
101
|
+
}
|
|
102
|
+
// create new context logger
|
|
103
|
+
const ctxLogger = appLogger.createContextLogger(ctx, {
|
|
104
|
+
contextFormat: this.contextLoggerFormat,
|
|
105
|
+
});
|
|
106
|
+
ctxLoggerCache.set(name, ctxLogger);
|
|
107
|
+
return ctxLogger;
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
// avoid maximum call stack size exceeded
|
|
111
|
+
if (ctx['_logger']) {
|
|
112
|
+
return ctx['_logger'];
|
|
113
|
+
}
|
|
114
|
+
ctx['_logger'] = appLogger.createContextLogger(ctx, {
|
|
115
|
+
contextFormat: this.contextLoggerFormat,
|
|
116
|
+
});
|
|
117
|
+
return ctx['_logger'];
|
|
118
|
+
}
|
|
92
119
|
}
|
|
93
120
|
async stop() {
|
|
94
121
|
await this.beforeStop();
|
|
@@ -117,7 +144,9 @@ class BaseFramework {
|
|
|
117
144
|
return this.getConfiguration(key);
|
|
118
145
|
},
|
|
119
146
|
getFrameworkType: () => {
|
|
120
|
-
|
|
147
|
+
if (this['getFrameworkType']) {
|
|
148
|
+
return this['getFrameworkType']();
|
|
149
|
+
}
|
|
121
150
|
},
|
|
122
151
|
getProcessType: () => {
|
|
123
152
|
return interface_1.MidwayProcessTypeEnum.APPLICATION;
|
|
@@ -241,7 +270,7 @@ class BaseFramework {
|
|
|
241
270
|
return this.informationService.getProjectName();
|
|
242
271
|
}
|
|
243
272
|
getFrameworkName() {
|
|
244
|
-
return
|
|
273
|
+
return '';
|
|
245
274
|
}
|
|
246
275
|
useMiddleware(middleware) {
|
|
247
276
|
this.middlewareManager.insertLast(middleware);
|
|
@@ -15,7 +15,9 @@ let MidwayApplicationManager = class MidwayApplicationManager {
|
|
|
15
15
|
}
|
|
16
16
|
addFramework(namespace, framework) {
|
|
17
17
|
this.globalFrameworkMap.set(namespace, framework);
|
|
18
|
-
|
|
18
|
+
if (framework['getFrameworkType']) {
|
|
19
|
+
this.globalFrameworkTypeMap.set(framework['getFrameworkType'](), framework);
|
|
20
|
+
}
|
|
19
21
|
}
|
|
20
22
|
getFramework(namespaceOrFrameworkType) {
|
|
21
23
|
if (typeof namespaceOrFrameworkType === 'string') {
|
package/dist/interface.d.ts
CHANGED
|
@@ -182,6 +182,7 @@ export interface IManagedResolverFactoryCreateOptions {
|
|
|
182
182
|
export declare const REQUEST_CTX_KEY = "ctx";
|
|
183
183
|
export declare const REQUEST_OBJ_CTX_KEY = "_req_ctx";
|
|
184
184
|
export declare const HTTP_SERVER_KEY = "_midway_http_server";
|
|
185
|
+
export declare const REQUEST_CTX_LOGGER_CACHE_KEY = "_midway_ctx_logger_cache";
|
|
185
186
|
export declare type HandlerFunction = (
|
|
186
187
|
/**
|
|
187
188
|
* decorator uuid key
|
|
@@ -330,6 +331,7 @@ export interface IMidwayBaseApplication<CTX extends IMidwayContext> {
|
|
|
330
331
|
*/
|
|
331
332
|
getEnv(): string;
|
|
332
333
|
/**
|
|
334
|
+
* @deprecated
|
|
333
335
|
* Get current framework type in MidwayFrameworkType enum
|
|
334
336
|
*/
|
|
335
337
|
getFrameworkType(): FrameworkType;
|
|
@@ -444,7 +446,6 @@ export interface IMidwayFramework<APP extends IMidwayApplication<CTX>, CTX exten
|
|
|
444
446
|
getApplicationContext(): IMidwayContainer;
|
|
445
447
|
getConfiguration(key?: string): any;
|
|
446
448
|
getCurrentEnvironment(): string;
|
|
447
|
-
getFrameworkType(): FrameworkType;
|
|
448
449
|
getFrameworkName(): string;
|
|
449
450
|
getAppDir(): string;
|
|
450
451
|
getBaseDir(): string;
|
package/dist/interface.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MIDWAY_LOGGER_WRITEABLE_DIR = exports.MidwayProcessTypeEnum = exports.HTTP_SERVER_KEY = exports.REQUEST_OBJ_CTX_KEY = exports.REQUEST_CTX_KEY = exports.ObjectLifeCycleEvent = void 0;
|
|
3
|
+
exports.MIDWAY_LOGGER_WRITEABLE_DIR = exports.MidwayProcessTypeEnum = exports.REQUEST_CTX_LOGGER_CACHE_KEY = exports.HTTP_SERVER_KEY = exports.REQUEST_OBJ_CTX_KEY = exports.REQUEST_CTX_KEY = exports.ObjectLifeCycleEvent = void 0;
|
|
4
4
|
var ObjectLifeCycleEvent;
|
|
5
5
|
(function (ObjectLifeCycleEvent) {
|
|
6
6
|
ObjectLifeCycleEvent["BEFORE_BIND"] = "beforeBind";
|
|
@@ -12,6 +12,7 @@ var ObjectLifeCycleEvent;
|
|
|
12
12
|
exports.REQUEST_CTX_KEY = 'ctx';
|
|
13
13
|
exports.REQUEST_OBJ_CTX_KEY = '_req_ctx';
|
|
14
14
|
exports.HTTP_SERVER_KEY = '_midway_http_server';
|
|
15
|
+
exports.REQUEST_CTX_LOGGER_CACHE_KEY = '_midway_ctx_logger_cache';
|
|
15
16
|
var MidwayProcessTypeEnum;
|
|
16
17
|
(function (MidwayProcessTypeEnum) {
|
|
17
18
|
MidwayProcessTypeEnum["APPLICATION"] = "APPLICATION";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@midwayjs/core",
|
|
3
|
-
"version": "3.0
|
|
3
|
+
"version": "3.1.0",
|
|
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": "2074c838e454a9673a044dbe065631dd9f944005"
|
|
49
49
|
}
|