@midwayjs/core 3.0.0-beta.13 → 3.0.0-beta.17

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.
Files changed (37) hide show
  1. package/dist/common/applicationManager.d.ts +1 -2
  2. package/dist/common/applicationManager.js +14 -10
  3. package/dist/common/dataListener.d.ts +11 -0
  4. package/dist/common/dataListener.js +43 -0
  5. package/dist/common/fileDetector.js +1 -1
  6. package/dist/common/webRouterCollector.js +1 -1
  7. package/dist/context/container.js +15 -11
  8. package/dist/context/managedResolverFactory.js +7 -0
  9. package/dist/context/requestContainer.js +2 -0
  10. package/dist/definitions/functionDefinition.d.ts +1 -0
  11. package/dist/definitions/functionDefinition.js +1 -0
  12. package/dist/definitions/objectCreator.js +6 -6
  13. package/dist/definitions/objectDefinition.d.ts +1 -0
  14. package/dist/definitions/objectDefinition.js +1 -0
  15. package/dist/error/framework.d.ts +4 -0
  16. package/dist/error/framework.js +9 -1
  17. package/dist/error/http.d.ts +3 -4
  18. package/dist/error/http.js +5 -4
  19. package/dist/error/index.d.ts +1 -1
  20. package/dist/error/index.js +4 -1
  21. package/dist/functional/configuration.d.ts +2 -0
  22. package/dist/functional/configuration.js +10 -0
  23. package/dist/index.d.ts +2 -0
  24. package/dist/index.js +4 -1
  25. package/dist/interface.d.ts +46 -31
  26. package/dist/service/aspectService.js +1 -1
  27. package/dist/service/configService.d.ts +3 -1
  28. package/dist/service/configService.js +23 -17
  29. package/dist/service/environmentService.d.ts +1 -1
  30. package/dist/service/loggerService.d.ts +1 -1
  31. package/dist/service/middlewareService.d.ts +1 -1
  32. package/dist/service/middlewareService.js +6 -6
  33. package/dist/setup.js +5 -3
  34. package/dist/util/extend.d.ts +2 -0
  35. package/dist/util/extend.js +55 -0
  36. package/package.json +10 -11
  37. package/CHANGELOG.md +0 -2252
@@ -6,7 +6,6 @@ export declare class MidwayApplicationManager {
6
6
  addFramework(namespace: any, framework: IMidwayFramework<any, any, any>): void;
7
7
  getFramework(namespaceOrFrameworkType: string | FrameworkType): IMidwayFramework<any, any, any, unknown, unknown>;
8
8
  getApplication(namespaceOrFrameworkType: string | FrameworkType): IMidwayApplication;
9
- getApplications(namespaces: Array<string | FrameworkType>): IMidwayApplication[];
10
- getWebLikeApplication(): IMidwayApplication[];
9
+ getApplications(namespaces?: Array<string | FrameworkType>): IMidwayApplication[];
11
10
  }
12
11
  //# sourceMappingURL=applicationManager.d.ts.map
@@ -46,16 +46,20 @@ let MidwayApplicationManager = class MidwayApplicationManager {
46
46
  }
47
47
  }
48
48
  getApplications(namespaces) {
49
- return namespaces
50
- .map(namespace => {
51
- return this.getApplication(namespace);
52
- })
53
- .filter(app => {
54
- return !!app;
55
- });
56
- }
57
- getWebLikeApplication() {
58
- return this.getApplications(['express', 'koa', 'egg', 'faas']);
49
+ if (!namespaces) {
50
+ return Array.from(this.globalFrameworkMap.values()).map(framework => {
51
+ return framework.getApplication();
52
+ });
53
+ }
54
+ else {
55
+ return namespaces
56
+ .map(namespace => {
57
+ return this.getApplication(namespace);
58
+ })
59
+ .filter(app => {
60
+ return !!app;
61
+ });
62
+ }
59
63
  }
60
64
  };
61
65
  MidwayApplicationManager = __decorate([
@@ -0,0 +1,11 @@
1
+ export declare abstract class DataListener<T> {
2
+ private innerData;
3
+ protected init(): Promise<void>;
4
+ abstract initData(): T;
5
+ abstract onData(callback: (data: T) => void): any;
6
+ protected setData(data: T): void;
7
+ getData(): T;
8
+ stop(): Promise<void>;
9
+ protected destroyListener(): Promise<void>;
10
+ }
11
+ //# sourceMappingURL=dataListener.d.ts.map
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.DataListener = void 0;
13
+ const decorator_1 = require("@midwayjs/decorator");
14
+ class DataListener {
15
+ async init() {
16
+ this.innerData = await this.initData();
17
+ await this.onData(this.setData.bind(this));
18
+ }
19
+ setData(data) {
20
+ this.innerData = data;
21
+ }
22
+ getData() {
23
+ return this.innerData;
24
+ }
25
+ async stop() {
26
+ await this.destroyListener();
27
+ }
28
+ async destroyListener() { }
29
+ }
30
+ __decorate([
31
+ (0, decorator_1.Init)(),
32
+ __metadata("design:type", Function),
33
+ __metadata("design:paramtypes", []),
34
+ __metadata("design:returntype", Promise)
35
+ ], DataListener.prototype, "init", null);
36
+ __decorate([
37
+ (0, decorator_1.Destroy)(),
38
+ __metadata("design:type", Function),
39
+ __metadata("design:paramtypes", []),
40
+ __metadata("design:returntype", Promise)
41
+ ], DataListener.prototype, "stop", null);
42
+ exports.DataListener = DataListener;
43
+ //# sourceMappingURL=dataListener.js.map
@@ -47,7 +47,7 @@ class DirectoryFileDetector extends AbstractFileDetector {
47
47
  continue;
48
48
  }
49
49
  }
50
- else if ((0, decorator_1.isRegExp)(resolveFilter.pattern)) {
50
+ else if (decorator_1.Types.isRegExp(resolveFilter.pattern)) {
51
51
  if (resolveFilter.pattern.test(file)) {
52
52
  const exports = resolveFilter.ignoreRequire
53
53
  ? undefined
@@ -232,7 +232,7 @@ class WebRouterCollector {
232
232
  return urlMatchList
233
233
  .map(item => {
234
234
  const urlString = item.url.toString();
235
- const weightArr = (0, decorator_1.isRegExp)(item.url)
235
+ const weightArr = decorator_1.Types.isRegExp(item.url)
236
236
  ? urlString.split('\\/')
237
237
  : urlString.split('/');
238
238
  let weight = 0;
@@ -144,16 +144,16 @@ class ContainerConfiguration {
144
144
  }
145
145
  getConfigurationExport(exports) {
146
146
  const mods = [];
147
- if ((0, decorator_1.isClass)(exports) ||
148
- (0, decorator_1.isFunction)(exports) ||
147
+ if (decorator_1.Types.isClass(exports) ||
148
+ decorator_1.Types.isFunction(exports) ||
149
149
  exports instanceof configuration_1.FunctionalConfiguration) {
150
150
  mods.push(exports);
151
151
  }
152
152
  else {
153
153
  for (const m in exports) {
154
154
  const module = exports[m];
155
- if ((0, decorator_1.isClass)(module) ||
156
- (0, decorator_1.isFunction)(module) ||
155
+ if (decorator_1.Types.isClass(module) ||
156
+ decorator_1.Types.isFunction(module) ||
157
157
  module instanceof configuration_1.FunctionalConfiguration) {
158
158
  mods.push(module);
159
159
  }
@@ -240,13 +240,13 @@ class MidwayContainer {
240
240
  (_a = this.fileDetector) === null || _a === void 0 ? void 0 : _a.run(this);
241
241
  }
242
242
  bindClass(exports, options) {
243
- if ((0, decorator_1.isClass)(exports) || (0, decorator_1.isFunction)(exports)) {
243
+ if (decorator_1.Types.isClass(exports) || decorator_1.Types.isFunction(exports)) {
244
244
  this.bindModule(exports, options);
245
245
  }
246
246
  else {
247
247
  for (const m in exports) {
248
248
  const module = exports[m];
249
- if ((0, decorator_1.isClass)(module) || (0, decorator_1.isFunction)(module)) {
249
+ if (decorator_1.Types.isClass(module) || decorator_1.Types.isFunction(module)) {
250
250
  this.bindModule(module, options);
251
251
  }
252
252
  }
@@ -254,7 +254,7 @@ class MidwayContainer {
254
254
  }
255
255
  bind(identifier, target, options) {
256
256
  var _a;
257
- if ((0, decorator_1.isClass)(identifier) || (0, decorator_1.isFunction)(identifier)) {
257
+ if (decorator_1.Types.isClass(identifier) || decorator_1.Types.isFunction(identifier)) {
258
258
  return this.bindModule(identifier, target);
259
259
  }
260
260
  if (this.registry.hasDefinition(identifier)) {
@@ -262,13 +262,13 @@ class MidwayContainer {
262
262
  return;
263
263
  }
264
264
  let definition;
265
- if ((0, decorator_1.isClass)(target)) {
265
+ if (decorator_1.Types.isClass(target)) {
266
266
  definition = new objectDefinition_1.ObjectDefinition();
267
267
  definition.name = (0, decorator_1.getProviderName)(target);
268
268
  }
269
269
  else {
270
270
  definition = new functionDefinition_1.FunctionDefinition();
271
- if (!(0, decorator_1.isAsyncFunction)(target)) {
271
+ if (!decorator_1.Types.isAsyncFunction(target)) {
272
272
  definition.asynchronous = false;
273
273
  }
274
274
  definition.name = definition.id;
@@ -315,6 +315,10 @@ class MidwayContainer {
315
315
  debugBind(` register scope = ${objDefOptions.scope}`);
316
316
  definition.scope = objDefOptions.scope;
317
317
  }
318
+ if (objDefOptions.allowDowngrade) {
319
+ debugBind(` register allowDowngrade = ${objDefOptions.allowDowngrade}`);
320
+ definition.allowDowngrade = objDefOptions.allowDowngrade;
321
+ }
318
322
  this.objectCreateEventTarget.emit(interface_1.ObjectLifeCycleEvent.BEFORE_BIND, target, {
319
323
  context: this,
320
324
  definition,
@@ -327,7 +331,7 @@ class MidwayContainer {
327
331
  }
328
332
  }
329
333
  bindModule(module, options) {
330
- if ((0, decorator_1.isClass)(module)) {
334
+ if (decorator_1.Types.isClass(module)) {
331
335
  const providerId = (0, decorator_1.getProviderUUId)(module);
332
336
  if (providerId) {
333
337
  this.identifierMapping.saveClassRelation(module, options === null || options === void 0 ? void 0 : options.namespace);
@@ -343,7 +347,7 @@ class MidwayContainer {
343
347
  if (!info.scope) {
344
348
  info.scope = decorator_1.ScopeEnum.Request;
345
349
  }
346
- const uuid = (0, decorator_1.generateRandomId)();
350
+ const uuid = decorator_1.Utils.generateRandomId();
347
351
  this.identifierMapping.saveFunctionRelation(info.id, uuid);
348
352
  this.bind(uuid, module, {
349
353
  scope: info.scope,
@@ -202,6 +202,13 @@ class ManagedResolverFactory {
202
202
  if (definition.properties) {
203
203
  const keys = definition.properties.propertyKeys();
204
204
  for (const key of keys) {
205
+ if (definition.isSingletonScope() && this.context.hasDefinition(key)) {
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
+ }
205
212
  try {
206
213
  inst[key] = await this.resolveManagedAsync(definition.properties.get(key), key);
207
214
  }
@@ -13,6 +13,8 @@ class MidwayRequestContainer extends container_1.MidwayContainer {
13
13
  this.ctx = ctx;
14
14
  // register ctx
15
15
  this.registerObject(interface_1.REQUEST_CTX_KEY, ctx);
16
+ // register res
17
+ this.registerObject('res', {});
16
18
  if (ctx.logger) {
17
19
  // register contextLogger
18
20
  this.registerObject('logger', ctx.logger);
@@ -18,6 +18,7 @@ export declare class FunctionDefinition implements IObjectDefinition {
18
18
  asynchronous: boolean;
19
19
  handlerProps: any[];
20
20
  createFrom: any;
21
+ allowDowngrade: boolean;
21
22
  protected innerAutowire: boolean;
22
23
  protected innerScope: ScopeEnum;
23
24
  getAttr(key: ObjectIdentifier): any;
@@ -23,6 +23,7 @@ class FunctionDefinition {
23
23
  this.namespace = '';
24
24
  this.asynchronous = true;
25
25
  this.handlerProps = [];
26
+ this.allowDowngrade = false;
26
27
  // 函数工厂创建的对象默认不需要自动装配
27
28
  this.innerAutowire = false;
28
29
  this.innerScope = decorator_1.ScopeEnum.Singleton;
@@ -65,7 +65,7 @@ class ObjectCreator {
65
65
  let inst;
66
66
  if (this.definition.constructMethod) {
67
67
  const fn = Clzz[this.definition.constructMethod];
68
- if ((0, decorator_1.isAsyncFunction)(fn)) {
68
+ if (decorator_1.Types.isAsyncFunction(fn)) {
69
69
  inst = await fn.apply(Clzz, args);
70
70
  }
71
71
  else {
@@ -86,13 +86,13 @@ class ObjectCreator {
86
86
  const inst = obj;
87
87
  // after properties set then do init
88
88
  if (this.definition.initMethod && inst[this.definition.initMethod]) {
89
- if ((0, decorator_1.isGeneratorFunction)(inst[this.definition.initMethod]) ||
90
- (0, decorator_1.isAsyncFunction)(inst[this.definition.initMethod])) {
89
+ if (decorator_1.Types.isGeneratorFunction(inst[this.definition.initMethod]) ||
90
+ decorator_1.Types.isAsyncFunction(inst[this.definition.initMethod])) {
91
91
  throw new error_1.MidwayUseWrongMethodError('context.get', 'context.getAsync', this.definition.id);
92
92
  }
93
93
  else {
94
94
  const rt = inst[this.definition.initMethod].call(inst);
95
- if ((0, decorator_1.isPromise)(rt)) {
95
+ if (decorator_1.Types.isPromise(rt)) {
96
96
  throw new error_1.MidwayUseWrongMethodError('context.get', 'context.getAsync', this.definition.id);
97
97
  }
98
98
  }
@@ -107,7 +107,7 @@ class ObjectCreator {
107
107
  const inst = obj;
108
108
  if (this.definition.initMethod && inst[this.definition.initMethod]) {
109
109
  const initFn = inst[this.definition.initMethod];
110
- if ((0, decorator_1.isAsyncFunction)(initFn)) {
110
+ if (decorator_1.Types.isAsyncFunction(initFn)) {
111
111
  await initFn.call(inst);
112
112
  }
113
113
  else {
@@ -140,7 +140,7 @@ class ObjectCreator {
140
140
  async doDestroyAsync(obj) {
141
141
  if (this.definition.destroyMethod && obj[this.definition.destroyMethod]) {
142
142
  const fn = obj[this.definition.destroyMethod];
143
- if ((0, decorator_1.isAsyncFunction)(fn)) {
143
+ if (decorator_1.Types.isAsyncFunction(fn)) {
144
144
  await fn.call(obj);
145
145
  }
146
146
  else {
@@ -20,6 +20,7 @@ export declare class ObjectDefinition implements IObjectDefinition {
20
20
  namespace: string;
21
21
  handlerProps: any[];
22
22
  createFrom: any;
23
+ allowDowngrade: boolean;
23
24
  constructor();
24
25
  set asynchronous(asynchronous: boolean);
25
26
  isAsync(): boolean;
@@ -23,6 +23,7 @@ class ObjectDefinition {
23
23
  this.properties = new properties_1.ObjectProperties();
24
24
  this.namespace = '';
25
25
  this.handlerProps = [];
26
+ this.allowDowngrade = false;
26
27
  this.creator = new objectCreator_1.ObjectCreator(this);
27
28
  }
28
29
  set asynchronous(asynchronous) {
@@ -11,6 +11,7 @@ export declare const FrameworkErrorEnum: {
11
11
  readonly MISSING_RESOLVER: "MIDWAY_10007";
12
12
  readonly DUPLICATE_ROUTER: "MIDWAY_10008";
13
13
  readonly USE_WRONG_METHOD: "MIDWAY_10009";
14
+ readonly SINGLETON_INJECT_REQUEST: "MIDWAY_10010";
14
15
  };
15
16
  export declare class MidwayCommonError extends MidwayError {
16
17
  constructor(message: string);
@@ -42,4 +43,7 @@ export declare class MidwayDuplicateRouteError extends MidwayError {
42
43
  export declare class MidwayUseWrongMethodError extends MidwayError {
43
44
  constructor(wrongMethod: string, replacedMethod: string, describeKey?: string);
44
45
  }
46
+ export declare class MidwaySingletonInjectRequestError extends MidwayError {
47
+ constructor(singletonScopeName: string, requestScopeName: string);
48
+ }
45
49
  //# sourceMappingURL=framework.d.ts.map
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MidwayUseWrongMethodError = exports.MidwayDuplicateRouteError = exports.MidwayResolverMissingError = exports.MidwayConfigMissingError = exports.MidwayFeatureNotImplementedError = exports.MidwayFeatureNoLongerSupportedError = exports.MidwayDefinitionNotFoundError = exports.MidwayParameterError = exports.MidwayCommonError = exports.FrameworkErrorEnum = void 0;
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;
4
4
  const base_1 = require("./base");
5
5
  exports.FrameworkErrorEnum = (0, base_1.registerErrorCode)('midway', {
6
6
  UNKNOWN: 10000,
@@ -13,6 +13,7 @@ exports.FrameworkErrorEnum = (0, base_1.registerErrorCode)('midway', {
13
13
  MISSING_RESOLVER: 10007,
14
14
  DUPLICATE_ROUTER: 10008,
15
15
  USE_WRONG_METHOD: 10009,
16
+ SINGLETON_INJECT_REQUEST: 10010,
16
17
  });
17
18
  class MidwayCommonError extends base_1.MidwayError {
18
19
  constructor(message) {
@@ -84,4 +85,11 @@ class MidwayUseWrongMethodError extends base_1.MidwayError {
84
85
  }
85
86
  }
86
87
  exports.MidwayUseWrongMethodError = MidwayUseWrongMethodError;
88
+ class MidwaySingletonInjectRequestError extends base_1.MidwayError {
89
+ 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
+ super(text, exports.FrameworkErrorEnum.SINGLETON_INJECT_REQUEST);
92
+ }
93
+ }
94
+ exports.MidwaySingletonInjectRequestError = MidwaySingletonInjectRequestError;
87
95
  //# sourceMappingURL=framework.js.map
@@ -109,7 +109,7 @@ export declare class PayloadTooLargeError extends MidwayHttpError {
109
109
  export declare class UnsupportedMediaTypeError extends MidwayHttpError {
110
110
  constructor(resOrMessage?: ResOrMessage);
111
111
  }
112
- export declare class UnprocessableError extends MidwayHttpError {
112
+ export declare class UnprocessableEntityError extends MidwayHttpError {
113
113
  constructor(resOrMessage?: ResOrMessage);
114
114
  }
115
115
  /**
@@ -121,7 +121,7 @@ export declare class InternalServerErrorError extends MidwayHttpError {
121
121
  /**
122
122
  * 501 http error, Means that the server doesn't recognize the request method or it lacks the ability to fulfill the request.
123
123
  */
124
- declare class NotImplementedError extends MidwayHttpError {
124
+ export declare class NotImplementedError extends MidwayHttpError {
125
125
  constructor(resOrMessage?: ResOrMessage);
126
126
  }
127
127
  /**
@@ -153,12 +153,11 @@ export declare const httpError: {
153
153
  GoneError: typeof GoneError;
154
154
  PayloadTooLargeError: typeof PayloadTooLargeError;
155
155
  UnsupportedMediaTypeError: typeof UnsupportedMediaTypeError;
156
- UnprocessableError: typeof UnprocessableError;
156
+ UnprocessableEntityError: typeof UnprocessableEntityError;
157
157
  InternalServerErrorError: typeof InternalServerErrorError;
158
158
  NotImplementedError: typeof NotImplementedError;
159
159
  BadGatewayError: typeof BadGatewayError;
160
160
  ServiceUnavailableError: typeof ServiceUnavailableError;
161
161
  GatewayTimeoutError: typeof GatewayTimeoutError;
162
162
  };
163
- export {};
164
163
  //# sourceMappingURL=http.d.ts.map
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.httpError = exports.GatewayTimeoutError = exports.ServiceUnavailableError = exports.BadGatewayError = exports.InternalServerErrorError = exports.UnprocessableError = exports.UnsupportedMediaTypeError = exports.PayloadTooLargeError = exports.GoneError = exports.ConflictError = exports.RequestTimeoutError = exports.NotAcceptableError = exports.ForbiddenError = exports.NotFoundError = exports.UnauthorizedError = exports.BadRequestError = exports.HttpStatus = void 0;
3
+ exports.httpError = exports.GatewayTimeoutError = exports.ServiceUnavailableError = exports.BadGatewayError = exports.NotImplementedError = exports.InternalServerErrorError = exports.UnprocessableEntityError = exports.UnsupportedMediaTypeError = exports.PayloadTooLargeError = exports.GoneError = exports.ConflictError = exports.RequestTimeoutError = exports.NotAcceptableError = exports.ForbiddenError = exports.NotFoundError = exports.UnauthorizedError = exports.BadRequestError = exports.HttpStatus = void 0;
4
4
  const base_1 = require("./base");
5
5
  var HttpStatus;
6
6
  (function (HttpStatus) {
@@ -143,12 +143,12 @@ class UnsupportedMediaTypeError extends base_1.MidwayHttpError {
143
143
  }
144
144
  }
145
145
  exports.UnsupportedMediaTypeError = UnsupportedMediaTypeError;
146
- class UnprocessableError extends base_1.MidwayHttpError {
146
+ class UnprocessableEntityError extends base_1.MidwayHttpError {
147
147
  constructor(resOrMessage = 'Unprocessable Entity') {
148
148
  super(resOrMessage, HttpStatus.UNPROCESSABLE_ENTITY);
149
149
  }
150
150
  }
151
- exports.UnprocessableError = UnprocessableError;
151
+ exports.UnprocessableEntityError = UnprocessableEntityError;
152
152
  /**
153
153
  * 500 http error, Is a generic error and users receive this error message when there is no more suitable specific message.
154
154
  */
@@ -166,6 +166,7 @@ class NotImplementedError extends base_1.MidwayHttpError {
166
166
  super(resOrMessage, HttpStatus.NOT_IMPLEMENTED);
167
167
  }
168
168
  }
169
+ exports.NotImplementedError = NotImplementedError;
169
170
  /**
170
171
  * 502 http error, Means that the server was acting as a gateway or proxy and it received an invalid answer from the upstream server.
171
172
  */
@@ -204,7 +205,7 @@ exports.httpError = {
204
205
  GoneError,
205
206
  PayloadTooLargeError,
206
207
  UnsupportedMediaTypeError,
207
- UnprocessableError,
208
+ UnprocessableEntityError,
208
209
  InternalServerErrorError,
209
210
  NotImplementedError,
210
211
  BadGatewayError,
@@ -1,4 +1,4 @@
1
1
  export * from './base';
2
- export * from './http';
2
+ export { HttpStatus, httpError } from './http';
3
3
  export * from './framework';
4
4
  //# sourceMappingURL=index.d.ts.map
@@ -10,7 +10,10 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
10
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
11
  };
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.httpError = exports.HttpStatus = void 0;
13
14
  __exportStar(require("./base"), exports);
14
- __exportStar(require("./http"), exports);
15
+ var http_1 = require("./http");
16
+ Object.defineProperty(exports, "HttpStatus", { enumerable: true, get: function () { return http_1.HttpStatus; } });
17
+ Object.defineProperty(exports, "httpError", { enumerable: true, get: function () { return http_1.httpError; } });
15
18
  __exportStar(require("./framework"), exports);
16
19
  //# sourceMappingURL=index.js.map
@@ -4,10 +4,12 @@ export declare class FunctionalConfiguration {
4
4
  private readyHandler;
5
5
  private stopHandler;
6
6
  private configLoadHandler;
7
+ private serverReadyHandler;
7
8
  private options;
8
9
  constructor(options: InjectionConfigurationOptions);
9
10
  onConfigLoad(configLoadHandler: ((container: IMidwayContainer, app: IMidwayApplication) => any) | IMidwayContainer, app?: IMidwayApplication): any;
10
11
  onReady(readyHandler: ((container: IMidwayContainer, app: IMidwayApplication) => void) | IMidwayContainer, app?: IMidwayApplication): any;
12
+ onServerReady(serverReadyHandler: ((container: IMidwayContainer, app: IMidwayApplication) => void) | IMidwayContainer, app?: IMidwayApplication): any;
11
13
  onStop(stopHandler: ((container: IMidwayContainer, app: IMidwayApplication) => void) | IMidwayContainer, app?: IMidwayApplication): any;
12
14
  getConfigurationOptions(): InjectionConfigurationOptions;
13
15
  }
@@ -7,6 +7,7 @@ class FunctionalConfiguration {
7
7
  this.readyHandler = () => { };
8
8
  this.stopHandler = () => { };
9
9
  this.configLoadHandler = () => { };
10
+ this.serverReadyHandler = () => { };
10
11
  }
11
12
  onConfigLoad(configLoadHandler, app) {
12
13
  if (typeof configLoadHandler === 'function') {
@@ -26,6 +27,15 @@ class FunctionalConfiguration {
26
27
  }
27
28
  return this;
28
29
  }
30
+ onServerReady(serverReadyHandler, app) {
31
+ if (typeof serverReadyHandler === 'function') {
32
+ this.serverReadyHandler = serverReadyHandler;
33
+ }
34
+ else {
35
+ return this.serverReadyHandler(serverReadyHandler, app);
36
+ }
37
+ return this;
38
+ }
29
39
  onStop(stopHandler, app) {
30
40
  if (typeof stopHandler === 'function') {
31
41
  this.stopHandler = stopHandler;
package/dist/index.d.ts CHANGED
@@ -5,6 +5,7 @@ export { BaseFramework } from './baseFramework';
5
5
  export * from './context/providerWrapper';
6
6
  export * from './common/constants';
7
7
  export { safelyGet, safeRequire, delegateTargetPrototypeMethod, delegateTargetMethod, delegateTargetProperties, deprecatedOutput, transformRequestObjectByType, pathMatching, wrapMiddleware, } from './util/';
8
+ export { extend } from './util/extend';
8
9
  export * from './util/pathFileUtil';
9
10
  export * from './util/webRouterParam';
10
11
  export * from './common/webRouterCollector';
@@ -22,6 +23,7 @@ export { MidwayDecoratorService } from './service/decoratorService';
22
23
  export * from './service/pipelineService';
23
24
  export * from './util/contextUtil';
24
25
  export * from './common/serviceFactory';
26
+ export * from './common/dataListener';
25
27
  export * from './common/fileDetector';
26
28
  export * from './common/webGenerator';
27
29
  export * from './common/middlewareManager';
package/dist/index.js CHANGED
@@ -10,7 +10,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
10
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
11
  };
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
- exports.MidwayFrameworkType = exports.MidwayDecoratorService = exports.MidwayMiddlewareService = exports.MidwayLifeCycleService = exports.MidwayAspectService = exports.MidwayFrameworkService = exports.MidwayLoggerService = exports.MidwayInformationService = exports.MidwayEnvironmentService = exports.MidwayConfigService = exports.createConfiguration = exports.wrapMiddleware = exports.pathMatching = exports.transformRequestObjectByType = exports.deprecatedOutput = exports.delegateTargetProperties = exports.delegateTargetMethod = exports.delegateTargetPrototypeMethod = exports.safeRequire = exports.safelyGet = exports.BaseFramework = exports.MidwayRequestContainer = void 0;
13
+ exports.MidwayFrameworkType = exports.MidwayDecoratorService = exports.MidwayMiddlewareService = exports.MidwayLifeCycleService = exports.MidwayAspectService = exports.MidwayFrameworkService = exports.MidwayLoggerService = exports.MidwayInformationService = exports.MidwayEnvironmentService = exports.MidwayConfigService = exports.createConfiguration = exports.extend = exports.wrapMiddleware = exports.pathMatching = exports.transformRequestObjectByType = exports.deprecatedOutput = exports.delegateTargetProperties = exports.delegateTargetMethod = exports.delegateTargetPrototypeMethod = exports.safeRequire = exports.safelyGet = exports.BaseFramework = exports.MidwayRequestContainer = void 0;
14
14
  __exportStar(require("./interface"), exports);
15
15
  __exportStar(require("./context/container"), exports);
16
16
  var requestContainer_1 = require("./context/requestContainer");
@@ -29,6 +29,8 @@ Object.defineProperty(exports, "deprecatedOutput", { enumerable: true, get: func
29
29
  Object.defineProperty(exports, "transformRequestObjectByType", { enumerable: true, get: function () { return util_1.transformRequestObjectByType; } });
30
30
  Object.defineProperty(exports, "pathMatching", { enumerable: true, get: function () { return util_1.pathMatching; } });
31
31
  Object.defineProperty(exports, "wrapMiddleware", { enumerable: true, get: function () { return util_1.wrapMiddleware; } });
32
+ var extend_1 = require("./util/extend");
33
+ Object.defineProperty(exports, "extend", { enumerable: true, get: function () { return extend_1.extend; } });
32
34
  __exportStar(require("./util/pathFileUtil"), exports);
33
35
  __exportStar(require("./util/webRouterParam"), exports);
34
36
  __exportStar(require("./common/webRouterCollector"), exports);
@@ -56,6 +58,7 @@ Object.defineProperty(exports, "MidwayDecoratorService", { enumerable: true, get
56
58
  __exportStar(require("./service/pipelineService"), exports);
57
59
  __exportStar(require("./util/contextUtil"), exports);
58
60
  __exportStar(require("./common/serviceFactory"), exports);
61
+ __exportStar(require("./common/dataListener"), exports);
59
62
  __exportStar(require("./common/fileDetector"), exports);
60
63
  __exportStar(require("./common/webGenerator"), exports);
61
64
  __exportStar(require("./common/middlewareManager"), exports);