@eggjs/onerror 4.0.0-beta.32 → 4.0.0-beta.34

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/README.md CHANGED
@@ -16,15 +16,9 @@
16
16
 
17
17
  Default error handling plugin for egg.
18
18
 
19
- ## Install
20
-
21
- ```bash
22
- npm i @eggjs/onerror
23
- ```
24
-
25
19
  ## Usage
26
20
 
27
- `egg-onerror` is on by default in egg. But you still can configure its properties to fits your scenarios.
21
+ `onerror` plugin is enabled by default in egg. But you still can configure its properties to fits your scenarios.
28
22
 
29
23
  - `errorPageUrl: String or Function` - If user request html pages in production environment and unexpected error happened, it will redirect user to `errorPageUrl`.
30
24
  - `accepts: Function` - detect user's request accept `json` or `html`.
@@ -34,12 +28,16 @@ npm i @eggjs/onerror
34
28
  - `json: Function` - customize json error handler.
35
29
  - `jsonp: Function` - customize jsonp error handler.
36
30
 
37
- ```js
38
- // config.default.js
39
- // errorPageUrl support function
40
- exports.onerror = {
41
- errorPageUrl: (err, ctx) => ctx.errorPageUrl || '/500',
42
- };
31
+ ```ts
32
+ // config/config.default.ts
33
+ import { defineConfig } from 'egg';
34
+
35
+ export default defineConfig({
36
+ onerror: {
37
+ // errorPageUrl support function
38
+ errorPageUrl: (err, ctx) => ctx.errorPageUrl || '/500',
39
+ },
40
+ });
43
41
 
44
42
  // an accept detect function that mark all request with `x-requested-with=XMLHttpRequest` header accepts json.
45
43
  function accepts(ctx) {
package/dist/index.d.ts CHANGED
@@ -1 +1,18 @@
1
1
  import './types.ts';
2
+ import { type EggPluginFactory } from 'egg';
3
+ /**
4
+ * Onerror plugin
5
+ *
6
+ * @since 4.1.0
7
+ * Usage:
8
+ * ```ts
9
+ * // config/plugin.ts
10
+ * import onerrorPlugin from '@eggjs/onerror';
11
+ *
12
+ * export default {
13
+ * ...onerrorPlugin(),
14
+ * };
15
+ * ```
16
+ */
17
+ declare const _default: EggPluginFactory;
18
+ export default _default;
package/dist/index.js CHANGED
@@ -1,2 +1,23 @@
1
1
  import "./types.js";
2
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxZQUFZLENBQUMifQ==
2
+ import { definePluginFactory } from 'egg';
3
+ /**
4
+ * Onerror plugin
5
+ *
6
+ * @since 4.1.0
7
+ * Usage:
8
+ * ```ts
9
+ * // config/plugin.ts
10
+ * import onerrorPlugin from '@eggjs/onerror';
11
+ *
12
+ * export default {
13
+ * ...onerrorPlugin(),
14
+ * };
15
+ * ```
16
+ */
17
+ export default definePluginFactory({
18
+ name: 'onerror',
19
+ enable: true,
20
+ path: import.meta.dirname,
21
+ optionalDependencies: ['jsonp'],
22
+ });
23
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxZQUFZLENBQUM7QUFFcEIsT0FBTyxFQUFFLG1CQUFtQixFQUF5QixNQUFNLEtBQUssQ0FBQztBQUVqRTs7Ozs7Ozs7Ozs7OztHQWFHO0FBQ0gsZUFBZSxtQkFBbUIsQ0FBQztJQUNqQyxJQUFJLEVBQUUsU0FBUztJQUNmLE1BQU0sRUFBRSxJQUFJO0lBQ1osSUFBSSxFQUFFLE1BQU0sQ0FBQyxJQUFJLENBQUMsT0FBTztJQUN6QixvQkFBb0IsRUFBRSxDQUFDLE9BQU8sQ0FBQztDQUNoQyxDQUFxQixDQUFDIn0=
package/package.json CHANGED
@@ -1,16 +1,10 @@
1
1
  {
2
2
  "name": "@eggjs/onerror",
3
- "version": "4.0.0-beta.32",
3
+ "version": "4.0.0-beta.34",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
7
7
  "description": "error handler for egg",
8
- "eggPlugin": {
9
- "name": "onerror",
10
- "optionalDependencies": [
11
- "jsonp"
12
- ]
13
- },
14
8
  "homepage": "https://github.com/eggjs/egg/tree/next/plugins/onerror",
15
9
  "repository": {
16
10
  "type": "git",
@@ -33,16 +27,16 @@
33
27
  "stack-trace": "^0.0.10"
34
28
  },
35
29
  "peerDependencies": {
36
- "egg": "4.1.0-beta.32"
30
+ "egg": "4.1.0-beta.34"
37
31
  },
38
32
  "devDependencies": {
39
33
  "@types/mustache": "^4.2.5",
40
34
  "@types/stack-trace": "^0.0.33",
41
- "tsdown": "0.15.10",
35
+ "tsdown": "0.15.11",
42
36
  "typescript": "^5.9.3",
43
- "vitest": "4.0.4",
44
- "@eggjs/mock": "7.0.0-beta.32",
45
- "egg": "4.1.0-beta.32"
37
+ "vitest": "4.0.5",
38
+ "@eggjs/mock": "7.0.0-beta.34",
39
+ "egg": "4.1.0-beta.34"
46
40
  },
47
41
  "type": "module",
48
42
  "exports": {