@eggjs/onerror 4.0.0-beta.35 → 4.0.0-beta.36

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.
@@ -4,251 +4,251 @@
4
4
  <meta charset="UTF-8" />
5
5
  <title></title>
6
6
  <style>
7
- /* http://prismjs.com/download.html?themes=prism&languages=markup+css+clike+javascript&plugins=line-highlight+line-numbers+toolbar+show-language */
8
- /**
9
- * prism.js default theme for JavaScript, CSS and HTML
10
- * Based on dabblet (http://dabblet.com)
11
- * @author Lea Verou
12
- */
13
- code[class*='language-'],
14
- pre[class*='language-'] {
15
- color: black;
16
- background: none;
17
- text-shadow: 0 1px white;
18
- font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
19
- text-align: left;
20
- white-space: pre;
21
- word-spacing: normal;
22
- word-break: normal;
23
- word-wrap: normal;
24
- line-height: 1.5;
25
- -moz-tab-size: 4;
26
- -o-tab-size: 4;
27
- tab-size: 4;
28
- -webkit-hyphens: none;
29
- -moz-hyphens: none;
30
- -ms-hyphens: none;
31
- hyphens: none;
32
- }
33
- pre[class*='language-']::-moz-selection,
34
- pre[class*='language-'] ::-moz-selection,
35
- code[class*='language-']::-moz-selection,
36
- code[class*='language-'] ::-moz-selection {
37
- text-shadow: none;
38
- background: #98d8b7;
39
- }
40
- pre[class*='language-']::selection,
41
- pre[class*='language-'] ::selection,
42
- code[class*='language-']::selection,
43
- code[class*='language-'] ::selection {
44
- text-shadow: none;
45
- background: #98d8b7;
46
- }
47
- @media print {
48
- code[class*='language-'],
49
- pre[class*='language-'] {
50
- text-shadow: none;
51
- }
52
- }
53
- /* Code blocks */
54
- pre[class*='language-'] {
55
- padding: 1em;
56
- margin: 0.5em 0;
57
- overflow: auto;
58
- }
59
- :not(pre) > code[class*='language-'],
60
- pre[class*='language-'] {
61
- background: #f5f2f0;
62
- }
63
- /* Inline code */
64
- :not(pre) > code[class*='language-'] {
65
- padding: 0.1em;
66
- border-radius: 0.3em;
67
- white-space: normal;
68
- }
69
- .token.comment,
70
- .token.prolog,
71
- .token.doctype,
72
- .token.cdata {
73
- color: slategray;
74
- }
75
- .token.punctuation {
76
- color: #999;
77
- }
78
- .namespace {
79
- opacity: 0.7;
80
- }
81
- .token.property,
82
- .token.tag,
83
- .token.boolean,
84
- .token.number,
85
- .token.constant,
86
- .token.symbol,
87
- .token.deleted {
88
- color: #905;
89
- }
90
- .token.selector,
91
- .token.attr-name,
92
- .token.string,
93
- .token.char,
94
- .token.builtin,
95
- .token.inserted {
96
- color: #690;
97
- }
98
- .token.operator,
99
- .token.entity,
100
- .token.url,
101
- .language-css .token.string,
102
- .style .token.string {
103
- color: #a67f59;
104
- background: hsla(0, 0%, 100%, 0.5);
105
- }
106
- .token.atrule,
107
- .token.attr-value,
108
- .token.keyword {
109
- color: #07a;
110
- }
111
- .token.function {
112
- color: #dd4a68;
113
- }
114
- .token.regex,
115
- .token.important,
116
- .token.variable {
117
- color: #e90;
118
- }
119
- .token.important,
120
- .token.bold {
121
- font-weight: bold;
122
- }
123
- .token.italic {
124
- font-style: italic;
125
- }
126
- .token.entity {
127
- cursor: help;
128
- }
129
- pre[data-line] {
130
- position: relative;
131
- padding: 1em 0 1em 3em;
132
- }
133
- .line-highlight {
134
- position: absolute;
135
- left: 0;
136
- right: 0;
137
- padding: inherit 0;
138
- margin-top: 1em; /* Same as .prism’s padding-top */
139
- background: hsla(24, 20%, 50%, 0.08);
140
- background: linear-gradient(to right, hsla(24, 20%, 50%, 0.1) 70%, hsla(24, 20%, 50%, 0));
141
- pointer-events: none;
142
- line-height: inherit;
143
- white-space: pre;
144
- }
145
- .line-highlight:before,
146
- .line-highlight[data-end]:after {
147
- content: attr(data-start);
148
- position: absolute;
149
- top: 0.4em;
150
- left: 0.6em;
151
- min-width: 1em;
152
- padding: 0 0.5em;
153
- background-color: hsla(24, 20%, 50%, 0.4);
154
- color: hsl(24, 20%, 95%);
155
- font: bold 65%/1.5 sans-serif;
156
- text-align: center;
157
- vertical-align: 0.3em;
158
- border-radius: 999px;
159
- text-shadow: none;
160
- box-shadow: 0 1px white;
161
- }
162
- .line-highlight[data-end]:after {
163
- content: attr(data-end);
164
- top: auto;
165
- bottom: 0.4em;
166
- }
167
- pre.line-numbers {
168
- position: relative;
169
- padding-left: 3.8em;
170
- counter-reset: linenumber;
171
- }
172
- pre.line-numbers > code {
173
- position: relative;
174
- }
175
- .line-numbers .line-numbers-rows {
176
- position: absolute;
177
- pointer-events: none;
178
- top: 0;
179
- font-size: 100%;
180
- left: -3.8em;
181
- width: 3em; /* works for line-numbers below 1000 lines */
182
- letter-spacing: -1px;
183
- border-right: 1px solid #999;
184
- -webkit-user-select: none;
185
- -moz-user-select: none;
186
- -ms-user-select: none;
187
- user-select: none;
188
- }
189
- .line-numbers-rows > span {
190
- pointer-events: none;
191
- display: block;
192
- counter-increment: linenumber;
193
- }
194
- .line-numbers-rows > span:before {
195
- content: counter(linenumber);
196
- color: #999;
197
- display: block;
198
- padding-right: 0.8em;
199
- text-align: right;
200
- }
201
- pre.code-toolbar {
202
- position: relative;
203
- }
204
- pre.code-toolbar > .toolbar {
205
- position: absolute;
206
- top: 0.3em;
207
- right: 0.2em;
208
- transition: opacity 0.3s ease-in-out;
209
- opacity: 0;
210
- }
211
- pre.code-toolbar:hover > .toolbar {
212
- opacity: 1;
213
- }
214
- pre.code-toolbar > .toolbar .toolbar-item {
215
- display: inline-block;
216
- }
217
- pre.code-toolbar > .toolbar a {
218
- cursor: pointer;
219
- }
220
- pre.code-toolbar > .toolbar button {
221
- background: none;
222
- border: 0;
223
- color: inherit;
224
- font: inherit;
225
- line-height: normal;
226
- overflow: visible;
227
- padding: 0;
228
- -webkit-user-select: none; /* for button */
229
- -moz-user-select: none;
230
- -ms-user-select: none;
231
- }
232
- pre.code-toolbar > .toolbar a,
233
- pre.code-toolbar > .toolbar button,
234
- pre.code-toolbar > .toolbar span {
235
- color: #bbb;
236
- font-size: 0.8em;
237
- padding: 0 0.5em;
238
- background: #f5f2f0;
239
- background: rgba(224, 224, 224, 0.2);
240
- box-shadow: 0 2px 0 0 rgba(0, 0, 0, 0.2);
241
- border-radius: 0.5em;
242
- }
243
- pre.code-toolbar > .toolbar a:hover,
244
- pre.code-toolbar > .toolbar a:focus,
245
- pre.code-toolbar > .toolbar button:hover,
246
- pre.code-toolbar > .toolbar button:focus,
247
- pre.code-toolbar > .toolbar span:hover,
248
- pre.code-toolbar > .toolbar span:focus {
249
- color: inherit;
250
- text-decoration: none;
251
- }
7
+ /* http://prismjs.com/download.html?themes=prism&languages=markup+css+clike+javascript&plugins=line-highlight+line-numbers+toolbar+show-language */
8
+ /**
9
+ * prism.js default theme for JavaScript, CSS and HTML
10
+ * Based on dabblet (http://dabblet.com)
11
+ * @author Lea Verou
12
+ */
13
+ code[class*='language-'],
14
+ pre[class*='language-'] {
15
+ color: black;
16
+ background: none;
17
+ text-shadow: 0 1px white;
18
+ font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
19
+ text-align: left;
20
+ white-space: pre;
21
+ word-spacing: normal;
22
+ word-break: normal;
23
+ word-wrap: normal;
24
+ line-height: 1.5;
25
+ -moz-tab-size: 4;
26
+ -o-tab-size: 4;
27
+ tab-size: 4;
28
+ -webkit-hyphens: none;
29
+ -moz-hyphens: none;
30
+ -ms-hyphens: none;
31
+ hyphens: none;
32
+ }
33
+ pre[class*='language-']::-moz-selection,
34
+ pre[class*='language-'] ::-moz-selection,
35
+ code[class*='language-']::-moz-selection,
36
+ code[class*='language-'] ::-moz-selection {
37
+ text-shadow: none;
38
+ background: #98d8b7;
39
+ }
40
+ pre[class*='language-']::selection,
41
+ pre[class*='language-'] ::selection,
42
+ code[class*='language-']::selection,
43
+ code[class*='language-'] ::selection {
44
+ text-shadow: none;
45
+ background: #98d8b7;
46
+ }
47
+ @media print {
48
+ code[class*='language-'],
49
+ pre[class*='language-'] {
50
+ text-shadow: none;
51
+ }
52
+ }
53
+ /* Code blocks */
54
+ pre[class*='language-'] {
55
+ padding: 1em;
56
+ margin: 0.5em 0;
57
+ overflow: auto;
58
+ }
59
+ :not(pre) > code[class*='language-'],
60
+ pre[class*='language-'] {
61
+ background: #f5f2f0;
62
+ }
63
+ /* Inline code */
64
+ :not(pre) > code[class*='language-'] {
65
+ padding: 0.1em;
66
+ border-radius: 0.3em;
67
+ white-space: normal;
68
+ }
69
+ .token.comment,
70
+ .token.prolog,
71
+ .token.doctype,
72
+ .token.cdata {
73
+ color: slategray;
74
+ }
75
+ .token.punctuation {
76
+ color: #999;
77
+ }
78
+ .namespace {
79
+ opacity: 0.7;
80
+ }
81
+ .token.property,
82
+ .token.tag,
83
+ .token.boolean,
84
+ .token.number,
85
+ .token.constant,
86
+ .token.symbol,
87
+ .token.deleted {
88
+ color: #905;
89
+ }
90
+ .token.selector,
91
+ .token.attr-name,
92
+ .token.string,
93
+ .token.char,
94
+ .token.builtin,
95
+ .token.inserted {
96
+ color: #690;
97
+ }
98
+ .token.operator,
99
+ .token.entity,
100
+ .token.url,
101
+ .language-css .token.string,
102
+ .style .token.string {
103
+ color: #a67f59;
104
+ background: hsla(0, 0%, 100%, 0.5);
105
+ }
106
+ .token.atrule,
107
+ .token.attr-value,
108
+ .token.keyword {
109
+ color: #07a;
110
+ }
111
+ .token.function {
112
+ color: #dd4a68;
113
+ }
114
+ .token.regex,
115
+ .token.important,
116
+ .token.variable {
117
+ color: #e90;
118
+ }
119
+ .token.important,
120
+ .token.bold {
121
+ font-weight: bold;
122
+ }
123
+ .token.italic {
124
+ font-style: italic;
125
+ }
126
+ .token.entity {
127
+ cursor: help;
128
+ }
129
+ pre[data-line] {
130
+ position: relative;
131
+ padding: 1em 0 1em 3em;
132
+ }
133
+ .line-highlight {
134
+ position: absolute;
135
+ left: 0;
136
+ right: 0;
137
+ padding: inherit 0;
138
+ margin-top: 1em; /* Same as .prism’s padding-top */
139
+ background: hsla(24, 20%, 50%, 0.08);
140
+ background: linear-gradient(to right, hsla(24, 20%, 50%, 0.1) 70%, hsla(24, 20%, 50%, 0));
141
+ pointer-events: none;
142
+ line-height: inherit;
143
+ white-space: pre;
144
+ }
145
+ .line-highlight:before,
146
+ .line-highlight[data-end]:after {
147
+ content: attr(data-start);
148
+ position: absolute;
149
+ top: 0.4em;
150
+ left: 0.6em;
151
+ min-width: 1em;
152
+ padding: 0 0.5em;
153
+ background-color: hsla(24, 20%, 50%, 0.4);
154
+ color: hsl(24, 20%, 95%);
155
+ font: bold 65%/1.5 sans-serif;
156
+ text-align: center;
157
+ vertical-align: 0.3em;
158
+ border-radius: 999px;
159
+ text-shadow: none;
160
+ box-shadow: 0 1px white;
161
+ }
162
+ .line-highlight[data-end]:after {
163
+ content: attr(data-end);
164
+ top: auto;
165
+ bottom: 0.4em;
166
+ }
167
+ pre.line-numbers {
168
+ position: relative;
169
+ padding-left: 3.8em;
170
+ counter-reset: linenumber;
171
+ }
172
+ pre.line-numbers > code {
173
+ position: relative;
174
+ }
175
+ .line-numbers .line-numbers-rows {
176
+ position: absolute;
177
+ pointer-events: none;
178
+ top: 0;
179
+ font-size: 100%;
180
+ left: -3.8em;
181
+ width: 3em; /* works for line-numbers below 1000 lines */
182
+ letter-spacing: -1px;
183
+ border-right: 1px solid #999;
184
+ -webkit-user-select: none;
185
+ -moz-user-select: none;
186
+ -ms-user-select: none;
187
+ user-select: none;
188
+ }
189
+ .line-numbers-rows > span {
190
+ pointer-events: none;
191
+ display: block;
192
+ counter-increment: linenumber;
193
+ }
194
+ .line-numbers-rows > span:before {
195
+ content: counter(linenumber);
196
+ color: #999;
197
+ display: block;
198
+ padding-right: 0.8em;
199
+ text-align: right;
200
+ }
201
+ pre.code-toolbar {
202
+ position: relative;
203
+ }
204
+ pre.code-toolbar > .toolbar {
205
+ position: absolute;
206
+ top: 0.3em;
207
+ right: 0.2em;
208
+ transition: opacity 0.3s ease-in-out;
209
+ opacity: 0;
210
+ }
211
+ pre.code-toolbar:hover > .toolbar {
212
+ opacity: 1;
213
+ }
214
+ pre.code-toolbar > .toolbar .toolbar-item {
215
+ display: inline-block;
216
+ }
217
+ pre.code-toolbar > .toolbar a {
218
+ cursor: pointer;
219
+ }
220
+ pre.code-toolbar > .toolbar button {
221
+ background: none;
222
+ border: 0;
223
+ color: inherit;
224
+ font: inherit;
225
+ line-height: normal;
226
+ overflow: visible;
227
+ padding: 0;
228
+ -webkit-user-select: none; /* for button */
229
+ -moz-user-select: none;
230
+ -ms-user-select: none;
231
+ }
232
+ pre.code-toolbar > .toolbar a,
233
+ pre.code-toolbar > .toolbar button,
234
+ pre.code-toolbar > .toolbar span {
235
+ color: #bbb;
236
+ font-size: 0.8em;
237
+ padding: 0 0.5em;
238
+ background: #f5f2f0;
239
+ background: rgba(224, 224, 224, 0.2);
240
+ box-shadow: 0 2px 0 0 rgba(0, 0, 0, 0.2);
241
+ border-radius: 0.5em;
242
+ }
243
+ pre.code-toolbar > .toolbar a:hover,
244
+ pre.code-toolbar > .toolbar a:focus,
245
+ pre.code-toolbar > .toolbar button:hover,
246
+ pre.code-toolbar > .toolbar button:focus,
247
+ pre.code-toolbar > .toolbar span:hover,
248
+ pre.code-toolbar > .toolbar span:focus {
249
+ color: inherit;
250
+ text-decoration: none;
251
+ }
252
252
  </style>
253
253
 
254
254
  <style>
@@ -1,6 +1,10 @@
1
- import type { Context, Application } from 'egg';
2
- import type { OnerrorError } from 'koa-onerror';
3
- export declare function detectErrorMessage(ctx: Context, err: OnerrorError): string;
4
- export declare function detectStatus(err: OnerrorError): number;
5
- export declare function accepts(ctx: Context): 'json' | 'js' | 'html';
6
- export declare function isProd(app: Application): boolean;
1
+ import { OnerrorError } from "koa-onerror";
2
+ import { Application, Context } from "egg";
3
+
4
+ //#region src/lib/utils.d.ts
5
+ declare function detectErrorMessage(ctx: Context, err: OnerrorError): string;
6
+ declare function detectStatus(err: OnerrorError): number;
7
+ declare function accepts(ctx: Context): "json" | "js" | "html";
8
+ declare function isProd(app: Application): boolean;
9
+ //#endregion
10
+ export { accepts, detectErrorMessage, detectStatus, isProd };
package/dist/lib/utils.js CHANGED
@@ -1,29 +1,21 @@
1
- export function detectErrorMessage(ctx, err) {
2
- // detect json parse error
3
- if (err.status === 400 &&
4
- err.name === 'SyntaxError' &&
5
- ctx.request.is('application/json', 'application/vnd.api+json', 'application/csp-report')) {
6
- return 'Problems parsing JSON';
7
- }
8
- return err.message;
1
+ //#region src/lib/utils.ts
2
+ function detectErrorMessage(ctx, err) {
3
+ if (err.status === 400 && err.name === "SyntaxError" && ctx.request.is("application/json", "application/vnd.api+json", "application/csp-report")) return "Problems parsing JSON";
4
+ return err.message;
9
5
  }
10
- export function detectStatus(err) {
11
- // detect status
12
- let status = err.status || 500;
13
- if (status < 200) {
14
- // invalid status consider as 500, like urllib will return -1 status
15
- status = 500;
16
- }
17
- return status;
6
+ function detectStatus(err) {
7
+ let status = err.status || 500;
8
+ if (status < 200) status = 500;
9
+ return status;
18
10
  }
19
- export function accepts(ctx) {
20
- if (ctx.acceptJSON)
21
- return 'json';
22
- if (ctx.acceptJSONP)
23
- return 'js';
24
- return 'html';
11
+ function accepts(ctx) {
12
+ if (ctx.acceptJSON) return "json";
13
+ if (ctx.acceptJSONP) return "js";
14
+ return "html";
25
15
  }
26
- export function isProd(app) {
27
- return app.config.env !== 'local' && app.config.env !== 'unittest';
16
+ function isProd(app) {
17
+ return app.config.env !== "local" && app.config.env !== "unittest";
28
18
  }
29
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidXRpbHMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvbGliL3V0aWxzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUdBLE1BQU0sVUFBVSxrQkFBa0IsQ0FBQyxHQUFZLEVBQUUsR0FBaUI7SUFDaEUsMEJBQTBCO0lBQzFCLElBQ0UsR0FBRyxDQUFDLE1BQU0sS0FBSyxHQUFHO1FBQ2xCLEdBQUcsQ0FBQyxJQUFJLEtBQUssYUFBYTtRQUMxQixHQUFHLENBQUMsT0FBTyxDQUFDLEVBQUUsQ0FBQyxrQkFBa0IsRUFBRSwwQkFBMEIsRUFBRSx3QkFBd0IsQ0FBQyxFQUN4RixDQUFDO1FBQ0QsT0FBTyx1QkFBdUIsQ0FBQztJQUNqQyxDQUFDO0lBQ0QsT0FBTyxHQUFHLENBQUMsT0FBTyxDQUFDO0FBQ3JCLENBQUM7QUFFRCxNQUFNLFVBQVUsWUFBWSxDQUFDLEdBQWlCO0lBQzVDLGdCQUFnQjtJQUNoQixJQUFJLE1BQU0sR0FBRyxHQUFHLENBQUMsTUFBTSxJQUFJLEdBQUcsQ0FBQztJQUMvQixJQUFJLE1BQU0sR0FBRyxHQUFHLEVBQUUsQ0FBQztRQUNqQixvRUFBb0U7UUFDcEUsTUFBTSxHQUFHLEdBQUcsQ0FBQztJQUNmLENBQUM7SUFDRCxPQUFPLE1BQU0sQ0FBQztBQUNoQixDQUFDO0FBRUQsTUFBTSxVQUFVLE9BQU8sQ0FBQyxHQUFZO0lBQ2xDLElBQUksR0FBRyxDQUFDLFVBQVU7UUFBRSxPQUFPLE1BQU0sQ0FBQztJQUNsQyxJQUFJLEdBQUcsQ0FBQyxXQUFXO1FBQUUsT0FBTyxJQUFJLENBQUM7SUFDakMsT0FBTyxNQUFNLENBQUM7QUFDaEIsQ0FBQztBQUVELE1BQU0sVUFBVSxNQUFNLENBQUMsR0FBZ0I7SUFDckMsT0FBTyxHQUFHLENBQUMsTUFBTSxDQUFDLEdBQUcsS0FBSyxPQUFPLElBQUksR0FBRyxDQUFDLE1BQU0sQ0FBQyxHQUFHLEtBQUssVUFBVSxDQUFDO0FBQ3JFLENBQUMifQ==
19
+
20
+ //#endregion
21
+ export { accepts, detectErrorMessage, detectStatus, isProd };
package/dist/types.d.ts CHANGED
@@ -1,6 +1,8 @@
1
- import type { OnerrorConfig } from './config/config.default.ts';
2
- declare module 'egg' {
3
- interface EggAppConfig {
4
- onerror: OnerrorConfig;
5
- }
6
- }
1
+ import { OnerrorConfig } from "./config/config.default.js";
2
+
3
+ //#region src/types.d.ts
4
+ declare module "egg" {
5
+ interface EggAppConfig {
6
+ onerror: OnerrorConfig;
7
+ }
8
+ }
package/dist/types.js CHANGED
@@ -1,2 +1 @@
1
- export {};
2
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHlwZXMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvdHlwZXMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiJ9
1
+ export { };