@nocobase/plugin-error-handler 0.7.7-alpha.1 → 0.8.0-alpha.5

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/lib/server.d.ts CHANGED
@@ -1,7 +1,6 @@
1
1
  import { Plugin } from '@nocobase/server';
2
2
  import { ErrorHandler } from './error-handler';
3
3
  export declare class PluginErrorHandler extends Plugin {
4
- getName(): string;
5
4
  errorHandler: ErrorHandler;
6
5
  i18nNs: string;
7
6
  beforeLoad(): void;
package/lib/server.js CHANGED
@@ -64,10 +64,6 @@ class PluginErrorHandler extends _server().Plugin {
64
64
  this.i18nNs = 'error-handler';
65
65
  }
66
66
 
67
- getName() {
68
- return this.getPackageName(__dirname);
69
- }
70
-
71
67
  beforeLoad() {
72
68
  this.registerSequelizeValidationErrorHandler();
73
69
  }
@@ -118,7 +114,7 @@ class PluginErrorHandler extends _server().Plugin {
118
114
 
119
115
  _this.app.i18n.addResources('en-US', _this.i18nNs, _en_US.default);
120
116
 
121
- _this.app.middleware.unshift(_this.errorHandler.middleware());
117
+ _this.app.middleware.nodes.unshift(_this.errorHandler.middleware());
122
118
  })();
123
119
  }
124
120
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocobase/plugin-error-handler",
3
- "version": "0.7.7-alpha.1",
3
+ "version": "0.8.0-alpha.5",
4
4
  "description": "",
5
5
  "license": "Apache-2.0",
6
6
  "licenses": [
@@ -13,12 +13,12 @@
13
13
  "types": "./lib/index.d.ts",
14
14
  "dependencies": {
15
15
  "@formily/json-schema": "^2.0.15",
16
- "@nocobase/server": "0.7.7-alpha.1"
16
+ "@nocobase/server": "0.8.0-alpha.5"
17
17
  },
18
18
  "repository": {
19
19
  "type": "git",
20
20
  "url": "git+https://github.com/nocobase/nocobase.git",
21
21
  "directory": "packages/plugin-error-handler"
22
22
  },
23
- "gitHead": "f82374e6f9daaf71ba63eaf156468ea7ddc042da"
23
+ "gitHead": "335f62b0098089cc43a0488ea5c76136a655f97e"
24
24
  }
@@ -1,13 +1,15 @@
1
- import { MockServer, mockServer } from '@nocobase/test';
2
- import { PluginErrorHandler } from '../server';
3
1
  import { Database } from '@nocobase/database';
2
+ import { MockServer, mockServer } from '@nocobase/test';
4
3
  import supertest from 'supertest';
4
+ import { PluginErrorHandler } from '../server';
5
5
  describe('create with exception', () => {
6
6
  let app: MockServer;
7
7
  beforeEach(async () => {
8
- app = mockServer();
8
+ app = mockServer({
9
+ acl: false,
10
+ });
9
11
  await app.cleanDb();
10
- app.plugin(PluginErrorHandler);
12
+ app.plugin(PluginErrorHandler, { name: 'error-handler' });
11
13
  });
12
14
 
13
15
  afterEach(async () => {
@@ -25,7 +25,6 @@ export class ErrorHandler {
25
25
 
26
26
  middleware() {
27
27
  const self = this;
28
-
29
28
  return async function errorHandler(ctx, next) {
30
29
  try {
31
30
  await next();
package/src/server.ts CHANGED
@@ -7,10 +7,6 @@ import enUS from './locale/en_US';
7
7
  import zhCN from './locale/zh_CN';
8
8
 
9
9
  export class PluginErrorHandler extends Plugin {
10
- getName(): string {
11
- return this.getPackageName(__dirname);
12
- }
13
-
14
10
  errorHandler: ErrorHandler = new ErrorHandler();
15
11
  i18nNs: string = 'error-handler';
16
12
 
@@ -49,10 +45,10 @@ export class PluginErrorHandler extends Plugin {
49
45
  },
50
46
  );
51
47
  }
48
+
52
49
  async load() {
53
50
  this.app.i18n.addResources('zh-CN', this.i18nNs, zhCN);
54
51
  this.app.i18n.addResources('en-US', this.i18nNs, enUS);
55
-
56
- this.app.middleware.unshift(this.errorHandler.middleware());
52
+ this.app.middleware.nodes.unshift(this.errorHandler.middleware());
57
53
  }
58
54
  }