@keq-request/headers 5.0.0-alpha.9 → 5.0.0-beta.10

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/CHANGELOG.md CHANGED
@@ -1,5 +1,317 @@
1
1
  # Changelog
2
2
 
3
+ ## 5.0.0-beta.10
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [95908fd]
8
+ - keq@5.0.0-beta.10
9
+
10
+ ## 5.0.0-beta.9
11
+
12
+ ### Patch Changes
13
+
14
+ - keq@5.0.0-beta.9
15
+
16
+ ## 5.0.0-beta.8
17
+
18
+ ### Patch Changes
19
+
20
+ - keq@5.0.0-beta.8
21
+
22
+ ## 5.0.0-beta.7
23
+
24
+ ### Patch Changes
25
+
26
+ - keq@5.0.0-beta.7
27
+
28
+ ## 5.0.0-beta.6
29
+
30
+ ### Patch Changes
31
+
32
+ - keq@5.0.0-beta.6
33
+
34
+ ## 5.0.0-beta.5
35
+
36
+ ### Patch Changes
37
+
38
+ - keq@5.0.0-beta.5
39
+
40
+ ## 5.0.0-beta.4
41
+
42
+ ### Patch Changes
43
+
44
+ - keq@5.0.0-beta.4
45
+
46
+ ## 5.0.0-beta.3
47
+
48
+ ### Patch Changes
49
+
50
+ - keq@5.0.0-beta.3
51
+
52
+ ## 5.0.0-beta.2
53
+
54
+ ### Patch Changes
55
+
56
+ - keq@5.0.0-beta.2
57
+
58
+ ## 5.0.0-beta.1
59
+
60
+ ### Major Changes
61
+
62
+ - 5175097: **BREAKING CHANGE:** group all packages under the @keq-request scope
63
+
64
+ - keq-cache => @keq-request/cache
65
+ - keq-headers => @keq-request/headers
66
+ - keq-cli => @keq-request/cli
67
+ - keq-url => @keq-request/url
68
+ - keq-exception => @keq-request/exception
69
+
70
+ - 0a04864: **Fix:** fix: update browser targets to chrome91/firefox90/safari15/edge91 to resolve esbuild 0.27 destructuring build errors.
71
+
72
+ ### Patch Changes
73
+
74
+ - 2686b8d: build with turbo
75
+ - 2686b8d: remove private dependencies
76
+ - e7eb9dc: Don't publish .turbo and jest.config.cts to npm
77
+ - 0873c7e: Incorrect build before release.
78
+ - 581815a: ensure compatibility
79
+ - 7343445: Incorrect build before release
80
+ - Updated dependencies [cbc5d17]
81
+ - Updated dependencies [153244f]
82
+ - Updated dependencies [153244f]
83
+ - Updated dependencies [153244f]
84
+ - Updated dependencies [0a2eb2f]
85
+ - Updated dependencies [153244f]
86
+ - Updated dependencies [214ae66]
87
+ - Updated dependencies [c7ffd1f]
88
+ - Updated dependencies [90311b3]
89
+ - Updated dependencies [1f367c0]
90
+ - Updated dependencies [0c7db81]
91
+ - Updated dependencies [df114d1]
92
+ - Updated dependencies [2686b8d]
93
+ - Updated dependencies [842e555]
94
+ - Updated dependencies [153244f]
95
+ - Updated dependencies [2686b8d]
96
+ - Updated dependencies [9290139]
97
+ - Updated dependencies [7873a0a]
98
+ - Updated dependencies [e7eb9dc]
99
+ - Updated dependencies [7ff2162]
100
+ - Updated dependencies [22ce01a]
101
+ - Updated dependencies [0873c7e]
102
+ - Updated dependencies [153244f]
103
+ - Updated dependencies [a7a83da]
104
+ - Updated dependencies [f194c41]
105
+ - Updated dependencies [153244f]
106
+ - Updated dependencies [153244f]
107
+ - Updated dependencies [d076b76]
108
+ - Updated dependencies [f8abc63]
109
+ - Updated dependencies [153244f]
110
+ - Updated dependencies [ca6c879]
111
+ - Updated dependencies [63161c4]
112
+ - Updated dependencies [d472648]
113
+ - Updated dependencies [b8d02ca]
114
+ - Updated dependencies [0a04864]
115
+ - Updated dependencies [581815a]
116
+ - Updated dependencies [7343445]
117
+ - Updated dependencies [153244f]
118
+ - Updated dependencies [eed26f9]
119
+ - keq@5.0.0-beta.1
120
+
121
+ ## 5.0.0-alpha.36
122
+
123
+ ### Patch Changes
124
+
125
+ - keq@5.0.0-alpha.36
126
+
127
+ ## 5.0.0-alpha.35
128
+
129
+ ### Major Changes
130
+
131
+ - 0a04864: **Fix:** fix: update browser targets to chrome91/firefox90/safari15/edge91 to resolve esbuild 0.27 destructuring build errors.
132
+
133
+ ### Patch Changes
134
+
135
+ - Updated dependencies [0a04864]
136
+ - keq@5.0.0-alpha.35
137
+
138
+ ## 5.0.0-alpha.34
139
+
140
+ ### Patch Changes
141
+
142
+ - Updated dependencies [a7a83da]
143
+ - Updated dependencies [f8abc63]
144
+ - keq@5.0.0-alpha.34
145
+
146
+ ## 5.0.0-alpha.33
147
+
148
+ ### Patch Changes
149
+
150
+ - keq@5.0.0-alpha.33
151
+
152
+ ## 5.0.0-alpha.32
153
+
154
+ ### Patch Changes
155
+
156
+ - Updated dependencies [f194c41]
157
+ - Updated dependencies [b8d02ca]
158
+ - keq@5.0.0-alpha.32
159
+
160
+ ## 5.0.0-alpha.31
161
+
162
+ ### Patch Changes
163
+
164
+ - keq@5.0.0-alpha.31
165
+
166
+ ## 5.0.0-alpha.30
167
+
168
+ ### Patch Changes
169
+
170
+ - keq@5.0.0-alpha.30
171
+
172
+ ## 5.0.0-alpha.29
173
+
174
+ ### Patch Changes
175
+
176
+ - keq@5.0.0-alpha.29
177
+
178
+ ## 5.0.0-alpha.28
179
+
180
+ ### Patch Changes
181
+
182
+ - Updated dependencies [d076b76]
183
+ - keq@5.0.0-alpha.28
184
+
185
+ ## 5.0.0-alpha.27
186
+
187
+ ### Patch Changes
188
+
189
+ - Updated dependencies [0c7db81]
190
+ - keq@5.0.0-alpha.27
191
+
192
+ ## 5.0.0-alpha.26
193
+
194
+ ### Patch Changes
195
+
196
+ - Updated dependencies [22ce01a]
197
+ - Updated dependencies [63161c4]
198
+ - keq@5.0.0-alpha.26
199
+
200
+ ## 5.0.0-alpha.25
201
+
202
+ ### Patch Changes
203
+
204
+ - Updated dependencies [214ae66]
205
+ - Updated dependencies [9290139]
206
+ - keq@5.0.0-alpha.25
207
+
208
+ ## 5.0.0-alpha.24
209
+
210
+ ### Patch Changes
211
+
212
+ - Updated dependencies [0a2eb2f]
213
+ - keq@5.0.0-alpha.24
214
+
215
+ ## 5.0.0-alpha.23
216
+
217
+ ### Patch Changes
218
+
219
+ - Updated dependencies [842e555]
220
+ - Updated dependencies [7873a0a]
221
+ - keq@5.0.0-alpha.23
222
+
223
+ ## 5.0.0-alpha.22
224
+
225
+ ### Patch Changes
226
+
227
+ - Updated dependencies [df114d1]
228
+ - keq@5.0.0-alpha.22
229
+
230
+ ## 5.0.0-alpha.21
231
+
232
+ ### Patch Changes
233
+
234
+ - Updated dependencies [90311b3]
235
+ - keq@5.0.0-alpha.21
236
+
237
+ ## 5.0.0-alpha.20
238
+
239
+ ### Patch Changes
240
+
241
+ - Updated dependencies [1f367c0]
242
+ - keq@5.0.0-alpha.20
243
+
244
+ ## 5.0.0-alpha.19
245
+
246
+ ### Patch Changes
247
+
248
+ - keq@5.0.0-alpha.19
249
+
250
+ ## 5.0.0-alpha.18
251
+
252
+ ### Patch Changes
253
+
254
+ - Updated dependencies [cbc5d17]
255
+ - keq@5.0.0-alpha.18
256
+
257
+ ## 5.0.0-alpha.17
258
+
259
+ ### Patch Changes
260
+
261
+ - Updated dependencies [d472648]
262
+ - Updated dependencies [eed26f9]
263
+ - keq@5.0.0-alpha.17
264
+
265
+ ## 5.0.0-alpha.16
266
+
267
+ ### Patch Changes
268
+
269
+ - Updated dependencies [ca6c879]
270
+ - keq@5.0.0-alpha.16
271
+
272
+ ## 5.0.0-alpha.15
273
+
274
+ ### Patch Changes
275
+
276
+ - keq@5.0.0-alpha.15
277
+
278
+ ## 5.0.0-alpha.14
279
+
280
+ ### Patch Changes
281
+
282
+ - keq@5.0.0-alpha.14
283
+
284
+ ## 5.0.0-alpha.13
285
+
286
+ ### Patch Changes
287
+
288
+ - keq@5.0.0-alpha.13
289
+
290
+ ## 5.0.0-alpha.12
291
+
292
+ ### Patch Changes
293
+
294
+ - 581815a: ensure compatibility
295
+ - Updated dependencies [581815a]
296
+ - keq@5.0.0-alpha.12
297
+
298
+ ## 5.0.0-alpha.11
299
+
300
+ ### Patch Changes
301
+
302
+ - Updated dependencies [c7ffd1f]
303
+ - keq@5.0.0-alpha.11
304
+
305
+ ## 5.0.0-alpha.10
306
+
307
+ ### Patch Changes
308
+
309
+ - e7eb9dc: Don't publish .turbo and jest.config.cts to npm
310
+ - 7343445: Incorrect build before release
311
+ - Updated dependencies [e7eb9dc]
312
+ - Updated dependencies [7343445]
313
+ - keq@5.0.0-alpha.10
314
+
3
315
  ## 5.0.0-alpha.9
4
316
 
5
317
  ### Patch Changes
@@ -0,0 +1,46 @@
1
+ import { KeqMiddleware } from "keq";
2
+
3
+ //#region src/index.d.ts
4
+ /**
5
+ * Set a header.
6
+ * If it already exists, the original value will be overwritten.
7
+ *
8
+ * 设置一个Header
9
+ * 如果Header已经存在,则会覆盖原来的值
10
+ */
11
+ declare function setHeader(key: string, value: string): KeqMiddleware;
12
+ /**
13
+ * Set headers.
14
+ * If it already exists, the original value will be overwritten.
15
+ *
16
+ * 设置多个Header
17
+ * 如果Header已经存在,则会覆盖原来的值
18
+ */
19
+ declare function setHeaders(headers: Record<string, string>): KeqMiddleware;
20
+ /**
21
+ * Append a header
22
+ *
23
+ * 追加一个Header
24
+ */
25
+ declare function appendHeader(key: string, value: string): KeqMiddleware;
26
+ /**
27
+ * Append headers
28
+ *
29
+ * 追加多个Header
30
+ */
31
+ declare function appendHeaders(headers: Record<string, string>): KeqMiddleware;
32
+ /**
33
+ * Set a header, if it isn't existed.
34
+ *
35
+ * 添加一个Header,如果Header的Key已存在,则不添加
36
+ */
37
+ declare function insertHeader(key: string, value: string): KeqMiddleware;
38
+ /**
39
+ * Set headers, if it isn't existed.
40
+ *
41
+ * 添加多个Header,已存在的Header将被忽略
42
+ */
43
+ declare function insertHeaders(headers: Record<string, string>): KeqMiddleware;
44
+ //#endregion
45
+ export { appendHeader, appendHeaders, insertHeader, insertHeaders, setHeader, setHeaders };
46
+ //# sourceMappingURL=index.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;AASA;;;;;iBAAgB,SAAA,CAAU,GAAA,UAAa,KAAA,WAAgB,aAAA;;;;AAcvD;;;;iBAAgB,UAAA,CAAW,OAAA,EAAS,MAAA,mBAAyB,aAAA;;;;;AAe7D;iBAAgB,YAAA,CAAa,GAAA,UAAa,KAAA,WAAgB,aAAA;;;;;;iBAY1C,aAAA,CAAc,OAAA,EAAS,MAAA,mBAAyB,aAAA;;AAAhE;;;;iBAegB,YAAA,CAAa,GAAA,UAAa,KAAA,WAAgB,aAAA;;;;;AAA1D;iBAcgB,aAAA,CAAc,OAAA,EAAS,MAAA,mBAAyB,aAAA"}
package/dist/index.d.ts CHANGED
@@ -1,4 +1,6 @@
1
- import type { KeqMiddleware } from 'keq';
1
+ import { KeqMiddleware } from "keq";
2
+
3
+ //#region src/index.d.ts
2
4
  /**
3
5
  * Set a header.
4
6
  * If it already exists, the original value will be overwritten.
@@ -6,7 +8,7 @@ import type { KeqMiddleware } from 'keq';
6
8
  * 设置一个Header
7
9
  * 如果Header已经存在,则会覆盖原来的值
8
10
  */
9
- export declare function setHeader(key: string, value: string): KeqMiddleware;
11
+ declare function setHeader(key: string, value: string): KeqMiddleware;
10
12
  /**
11
13
  * Set headers.
12
14
  * If it already exists, the original value will be overwritten.
@@ -14,29 +16,31 @@ export declare function setHeader(key: string, value: string): KeqMiddleware;
14
16
  * 设置多个Header
15
17
  * 如果Header已经存在,则会覆盖原来的值
16
18
  */
17
- export declare function setHeaders(headers: Record<string, string>): KeqMiddleware;
19
+ declare function setHeaders(headers: Record<string, string>): KeqMiddleware;
18
20
  /**
19
21
  * Append a header
20
22
  *
21
23
  * 追加一个Header
22
24
  */
23
- export declare function appendHeader(key: string, value: string): KeqMiddleware;
25
+ declare function appendHeader(key: string, value: string): KeqMiddleware;
24
26
  /**
25
27
  * Append headers
26
28
  *
27
29
  * 追加多个Header
28
30
  */
29
- export declare function appendHeaders(headers: Record<string, string>): KeqMiddleware;
31
+ declare function appendHeaders(headers: Record<string, string>): KeqMiddleware;
30
32
  /**
31
33
  * Set a header, if it isn't existed.
32
34
  *
33
35
  * 添加一个Header,如果Header的Key已存在,则不添加
34
36
  */
35
- export declare function insertHeader(key: string, value: string): KeqMiddleware;
37
+ declare function insertHeader(key: string, value: string): KeqMiddleware;
36
38
  /**
37
39
  * Set headers, if it isn't existed.
38
40
  *
39
41
  * 添加多个Header,已存在的Header将被忽略
40
42
  */
41
- export declare function insertHeaders(headers: Record<string, string>): KeqMiddleware;
43
+ declare function insertHeaders(headers: Record<string, string>): KeqMiddleware;
44
+ //#endregion
45
+ export { appendHeader, appendHeaders, insertHeader, insertHeaders, setHeader, setHeaders };
42
46
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,KAAK,CAAA;AAExC;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,aAAa,CAKnE;AAED;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,aAAa,CAQzE;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,aAAa,CAKtE;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,aAAa,CAO5E;AAGD;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,aAAa,CAOtE;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,aAAa,CAU5E"}
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;AASA;;;;;iBAAgB,SAAA,CAAU,GAAA,UAAa,KAAA,WAAgB,aAAA;;;;AAcvD;;;;iBAAgB,UAAA,CAAW,OAAA,EAAS,MAAA,mBAAyB,aAAA;;;;;AAe7D;iBAAgB,YAAA,CAAa,GAAA,UAAa,KAAA,WAAgB,aAAA;;;;;;iBAY1C,aAAA,CAAc,OAAA,EAAS,MAAA,mBAAyB,aAAA;;AAAhE;;;;iBAegB,YAAA,CAAa,GAAA,UAAa,KAAA,WAAgB,aAAA;;;;;AAA1D;iBAcgB,aAAA,CAAc,OAAA,EAAS,MAAA,mBAAyB,aAAA"}
package/dist/index.js CHANGED
@@ -1,86 +1,81 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/index.ts
21
- var index_exports = {};
22
- __export(index_exports, {
23
- appendHeader: () => appendHeader,
24
- appendHeaders: () => appendHeaders,
25
- insertHeader: () => insertHeader,
26
- insertHeaders: () => insertHeaders,
27
- setHeader: () => setHeader,
28
- setHeaders: () => setHeaders
29
- });
30
- module.exports = __toCommonJS(index_exports);
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ //#region src/index.ts
3
+ /**
4
+ * Set a header.
5
+ * If it already exists, the original value will be overwritten.
6
+ *
7
+ * 设置一个Header
8
+ * 如果Header已经存在,则会覆盖原来的值
9
+ */
31
10
  function setHeader(key, value) {
32
- return async function setHeader2(ctx, next) {
33
- ctx.request.headers.set(key, value);
34
- await next();
35
- };
11
+ return async function setHeader(ctx, next) {
12
+ ctx.request.headers.set(key, value);
13
+ await next();
14
+ };
36
15
  }
16
+ /**
17
+ * Set headers.
18
+ * If it already exists, the original value will be overwritten.
19
+ *
20
+ * 设置多个Header
21
+ * 如果Header已经存在,则会覆盖原来的值
22
+ */
37
23
  function setHeaders(headers) {
38
- return async function setHeaders2(ctx, next) {
39
- for (const key in headers) {
40
- ctx.request.headers.set(key, headers[key]);
41
- }
42
- await next();
43
- };
24
+ return async function setHeaders(ctx, next) {
25
+ for (const key in headers) ctx.request.headers.set(key, headers[key]);
26
+ await next();
27
+ };
44
28
  }
29
+ /**
30
+ * Append a header
31
+ *
32
+ * 追加一个Header
33
+ */
45
34
  function appendHeader(key, value) {
46
- return async function appendHeader2(ctx, next) {
47
- ctx.request.headers.append(key, value);
48
- await next();
49
- };
35
+ return async function appendHeader(ctx, next) {
36
+ ctx.request.headers.append(key, value);
37
+ await next();
38
+ };
50
39
  }
40
+ /**
41
+ * Append headers
42
+ *
43
+ * 追加多个Header
44
+ */
51
45
  function appendHeaders(headers) {
52
- return async function appendHeaders2(ctx, next) {
53
- for (const key in headers) {
54
- ctx.request.headers.append(key, headers[key]);
55
- }
56
- await next();
57
- };
46
+ return async function appendHeaders(ctx, next) {
47
+ for (const key in headers) ctx.request.headers.append(key, headers[key]);
48
+ await next();
49
+ };
58
50
  }
51
+ /**
52
+ * Set a header, if it isn't existed.
53
+ *
54
+ * 添加一个Header,如果Header的Key已存在,则不添加
55
+ */
59
56
  function insertHeader(key, value) {
60
- return async function insertHeader2(ctx, next) {
61
- if (!ctx.request.headers.has(key)) {
62
- ctx.request.headers.set(key, value);
63
- }
64
- await next();
65
- };
57
+ return async function insertHeader(ctx, next) {
58
+ if (!ctx.request.headers.has(key)) ctx.request.headers.set(key, value);
59
+ await next();
60
+ };
66
61
  }
62
+ /**
63
+ * Set headers, if it isn't existed.
64
+ *
65
+ * 添加多个Header,已存在的Header将被忽略
66
+ */
67
67
  function insertHeaders(headers) {
68
- return async function insertHeaders2(ctx, next) {
69
- for (const key in headers) {
70
- if (!ctx.request.headers.has(key)) {
71
- ctx.request.headers.set(key, headers[key]);
72
- }
73
- }
74
- await next();
75
- };
68
+ return async function insertHeaders(ctx, next) {
69
+ for (const key in headers) if (!ctx.request.headers.has(key)) ctx.request.headers.set(key, headers[key]);
70
+ await next();
71
+ };
76
72
  }
77
- // Annotate the CommonJS export names for ESM import in node:
78
- 0 && (module.exports = {
79
- appendHeader,
80
- appendHeaders,
81
- insertHeader,
82
- insertHeaders,
83
- setHeader,
84
- setHeaders
85
- });
73
+ //#endregion
74
+ exports.appendHeader = appendHeader;
75
+ exports.appendHeaders = appendHeaders;
76
+ exports.insertHeader = insertHeader;
77
+ exports.insertHeaders = insertHeaders;
78
+ exports.setHeader = setHeader;
79
+ exports.setHeaders = setHeaders;
80
+
86
81
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type { KeqMiddleware } from 'keq'\n\n/**\n * Set a header.\n * If it already exists, the original value will be overwritten.\n *\n * 设置一个Header\n * 如果Header已经存在,则会覆盖原来的值\n */\nexport function setHeader(key: string, value: string): KeqMiddleware {\n return async function setHeader(ctx, next) {\n ctx.request.headers.set(key, value)\n await next()\n }\n}\n\n/**\n * Set headers.\n * If it already exists, the original value will be overwritten.\n *\n * 设置多个Header\n * 如果Header已经存在,则会覆盖原来的值\n */\nexport function setHeaders(headers: Record<string, string>): KeqMiddleware {\n return async function setHeaders(ctx, next) {\n for (const key in headers) {\n ctx.request.headers.set(key, headers[key])\n }\n\n await next()\n }\n}\n\n/**\n * Append a header\n *\n * 追加一个Header\n */\nexport function appendHeader(key: string, value: string): KeqMiddleware {\n return async function appendHeader(ctx, next) {\n ctx.request.headers.append(key, value)\n await next()\n }\n}\n\n/**\n * Append headers\n *\n * 追加多个Header\n */\nexport function appendHeaders(headers: Record<string, string>): KeqMiddleware {\n return async function appendHeaders(ctx, next) {\n for (const key in headers) {\n ctx.request.headers.append(key, headers[key])\n }\n await next()\n }\n}\n\n\n/**\n * Set a header, if it isn't existed.\n *\n * 添加一个Header,如果Header的Key已存在,则不添加\n */\nexport function insertHeader(key: string, value: string): KeqMiddleware {\n return async function insertHeader(ctx, next) {\n if (!ctx.request.headers.has(key)) {\n ctx.request.headers.set(key, value)\n }\n await next()\n }\n}\n\n/**\n * Set headers, if it isn't existed.\n *\n * 添加多个Header,已存在的Header将被忽略\n */\nexport function insertHeaders(headers: Record<string, string>): KeqMiddleware {\n return async function insertHeaders(ctx, next) {\n for (const key in headers) {\n if (!ctx.request.headers.has(key)) {\n ctx.request.headers.set(key, headers[key])\n }\n }\n\n await next()\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AASO,SAAS,UAAU,KAAa,OAA8B;AACnE,SAAO,eAAeA,WAAU,KAAK,MAAM;AACzC,QAAI,QAAQ,QAAQ,IAAI,KAAK,KAAK;AAClC,UAAM,KAAK;AAAA,EACb;AACF;AASO,SAAS,WAAW,SAAgD;AACzE,SAAO,eAAeC,YAAW,KAAK,MAAM;AAC1C,eAAW,OAAO,SAAS;AACzB,UAAI,QAAQ,QAAQ,IAAI,KAAK,QAAQ,GAAG,CAAC;AAAA,IAC3C;AAEA,UAAM,KAAK;AAAA,EACb;AACF;AAOO,SAAS,aAAa,KAAa,OAA8B;AACtE,SAAO,eAAeC,cAAa,KAAK,MAAM;AAC5C,QAAI,QAAQ,QAAQ,OAAO,KAAK,KAAK;AACrC,UAAM,KAAK;AAAA,EACb;AACF;AAOO,SAAS,cAAc,SAAgD;AAC5E,SAAO,eAAeC,eAAc,KAAK,MAAM;AAC7C,eAAW,OAAO,SAAS;AACzB,UAAI,QAAQ,QAAQ,OAAO,KAAK,QAAQ,GAAG,CAAC;AAAA,IAC9C;AACA,UAAM,KAAK;AAAA,EACb;AACF;AAQO,SAAS,aAAa,KAAa,OAA8B;AACtE,SAAO,eAAeC,cAAa,KAAK,MAAM;AAC5C,QAAI,CAAC,IAAI,QAAQ,QAAQ,IAAI,GAAG,GAAG;AACjC,UAAI,QAAQ,QAAQ,IAAI,KAAK,KAAK;AAAA,IACpC;AACA,UAAM,KAAK;AAAA,EACb;AACF;AAOO,SAAS,cAAc,SAAgD;AAC5E,SAAO,eAAeC,eAAc,KAAK,MAAM;AAC7C,eAAW,OAAO,SAAS;AACzB,UAAI,CAAC,IAAI,QAAQ,QAAQ,IAAI,GAAG,GAAG;AACjC,YAAI,QAAQ,QAAQ,IAAI,KAAK,QAAQ,GAAG,CAAC;AAAA,MAC3C;AAAA,IACF;AAEA,UAAM,KAAK;AAAA,EACb;AACF;","names":["setHeader","setHeaders","appendHeader","appendHeaders","insertHeader","insertHeaders"]}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["import type { KeqMiddleware } from 'keq'\n\n/**\n * Set a header.\n * If it already exists, the original value will be overwritten.\n *\n * 设置一个Header\n * 如果Header已经存在,则会覆盖原来的值\n */\nexport function setHeader(key: string, value: string): KeqMiddleware {\n return async function setHeader(ctx, next) {\n ctx.request.headers.set(key, value)\n await next()\n }\n}\n\n/**\n * Set headers.\n * If it already exists, the original value will be overwritten.\n *\n * 设置多个Header\n * 如果Header已经存在,则会覆盖原来的值\n */\nexport function setHeaders(headers: Record<string, string>): KeqMiddleware {\n return async function setHeaders(ctx, next) {\n for (const key in headers) {\n ctx.request.headers.set(key, headers[key])\n }\n\n await next()\n }\n}\n\n/**\n * Append a header\n *\n * 追加一个Header\n */\nexport function appendHeader(key: string, value: string): KeqMiddleware {\n return async function appendHeader(ctx, next) {\n ctx.request.headers.append(key, value)\n await next()\n }\n}\n\n/**\n * Append headers\n *\n * 追加多个Header\n */\nexport function appendHeaders(headers: Record<string, string>): KeqMiddleware {\n return async function appendHeaders(ctx, next) {\n for (const key in headers) {\n ctx.request.headers.append(key, headers[key])\n }\n await next()\n }\n}\n\n\n/**\n * Set a header, if it isn't existed.\n *\n * 添加一个Header,如果Header的Key已存在,则不添加\n */\nexport function insertHeader(key: string, value: string): KeqMiddleware {\n return async function insertHeader(ctx, next) {\n if (!ctx.request.headers.has(key)) {\n ctx.request.headers.set(key, value)\n }\n await next()\n }\n}\n\n/**\n * Set headers, if it isn't existed.\n *\n * 添加多个Header,已存在的Header将被忽略\n */\nexport function insertHeaders(headers: Record<string, string>): KeqMiddleware {\n return async function insertHeaders(ctx, next) {\n for (const key in headers) {\n if (!ctx.request.headers.has(key)) {\n ctx.request.headers.set(key, headers[key])\n }\n }\n\n await next()\n }\n}\n"],"mappings":";;;;;;;;;AASA,SAAgB,UAAU,KAAa,OAA8B;AACnE,QAAO,eAAe,UAAU,KAAK,MAAM;AACzC,MAAI,QAAQ,QAAQ,IAAI,KAAK,MAAM;AACnC,QAAM,MAAM;;;;;;;;;;AAWhB,SAAgB,WAAW,SAAgD;AACzE,QAAO,eAAe,WAAW,KAAK,MAAM;AAC1C,OAAK,MAAM,OAAO,QAChB,KAAI,QAAQ,QAAQ,IAAI,KAAK,QAAQ,KAAK;AAG5C,QAAM,MAAM;;;;;;;;AAShB,SAAgB,aAAa,KAAa,OAA8B;AACtE,QAAO,eAAe,aAAa,KAAK,MAAM;AAC5C,MAAI,QAAQ,QAAQ,OAAO,KAAK,MAAM;AACtC,QAAM,MAAM;;;;;;;;AAShB,SAAgB,cAAc,SAAgD;AAC5E,QAAO,eAAe,cAAc,KAAK,MAAM;AAC7C,OAAK,MAAM,OAAO,QAChB,KAAI,QAAQ,QAAQ,OAAO,KAAK,QAAQ,KAAK;AAE/C,QAAM,MAAM;;;;;;;;AAUhB,SAAgB,aAAa,KAAa,OAA8B;AACtE,QAAO,eAAe,aAAa,KAAK,MAAM;AAC5C,MAAI,CAAC,IAAI,QAAQ,QAAQ,IAAI,IAAI,CAC/B,KAAI,QAAQ,QAAQ,IAAI,KAAK,MAAM;AAErC,QAAM,MAAM;;;;;;;;AAShB,SAAgB,cAAc,SAAgD;AAC5E,QAAO,eAAe,cAAc,KAAK,MAAM;AAC7C,OAAK,MAAM,OAAO,QAChB,KAAI,CAAC,IAAI,QAAQ,QAAQ,IAAI,IAAI,CAC/B,KAAI,QAAQ,QAAQ,IAAI,KAAK,QAAQ,KAAK;AAI9C,QAAM,MAAM"}
package/dist/index.mjs CHANGED
@@ -1,56 +1,75 @@
1
- // src/index.ts
1
+ //#region src/index.ts
2
+ /**
3
+ * Set a header.
4
+ * If it already exists, the original value will be overwritten.
5
+ *
6
+ * 设置一个Header
7
+ * 如果Header已经存在,则会覆盖原来的值
8
+ */
2
9
  function setHeader(key, value) {
3
- return async function setHeader2(ctx, next) {
4
- ctx.request.headers.set(key, value);
5
- await next();
6
- };
10
+ return async function setHeader(ctx, next) {
11
+ ctx.request.headers.set(key, value);
12
+ await next();
13
+ };
7
14
  }
15
+ /**
16
+ * Set headers.
17
+ * If it already exists, the original value will be overwritten.
18
+ *
19
+ * 设置多个Header
20
+ * 如果Header已经存在,则会覆盖原来的值
21
+ */
8
22
  function setHeaders(headers) {
9
- return async function setHeaders2(ctx, next) {
10
- for (const key in headers) {
11
- ctx.request.headers.set(key, headers[key]);
12
- }
13
- await next();
14
- };
23
+ return async function setHeaders(ctx, next) {
24
+ for (const key in headers) ctx.request.headers.set(key, headers[key]);
25
+ await next();
26
+ };
15
27
  }
28
+ /**
29
+ * Append a header
30
+ *
31
+ * 追加一个Header
32
+ */
16
33
  function appendHeader(key, value) {
17
- return async function appendHeader2(ctx, next) {
18
- ctx.request.headers.append(key, value);
19
- await next();
20
- };
34
+ return async function appendHeader(ctx, next) {
35
+ ctx.request.headers.append(key, value);
36
+ await next();
37
+ };
21
38
  }
39
+ /**
40
+ * Append headers
41
+ *
42
+ * 追加多个Header
43
+ */
22
44
  function appendHeaders(headers) {
23
- return async function appendHeaders2(ctx, next) {
24
- for (const key in headers) {
25
- ctx.request.headers.append(key, headers[key]);
26
- }
27
- await next();
28
- };
45
+ return async function appendHeaders(ctx, next) {
46
+ for (const key in headers) ctx.request.headers.append(key, headers[key]);
47
+ await next();
48
+ };
29
49
  }
50
+ /**
51
+ * Set a header, if it isn't existed.
52
+ *
53
+ * 添加一个Header,如果Header的Key已存在,则不添加
54
+ */
30
55
  function insertHeader(key, value) {
31
- return async function insertHeader2(ctx, next) {
32
- if (!ctx.request.headers.has(key)) {
33
- ctx.request.headers.set(key, value);
34
- }
35
- await next();
36
- };
56
+ return async function insertHeader(ctx, next) {
57
+ if (!ctx.request.headers.has(key)) ctx.request.headers.set(key, value);
58
+ await next();
59
+ };
37
60
  }
61
+ /**
62
+ * Set headers, if it isn't existed.
63
+ *
64
+ * 添加多个Header,已存在的Header将被忽略
65
+ */
38
66
  function insertHeaders(headers) {
39
- return async function insertHeaders2(ctx, next) {
40
- for (const key in headers) {
41
- if (!ctx.request.headers.has(key)) {
42
- ctx.request.headers.set(key, headers[key]);
43
- }
44
- }
45
- await next();
46
- };
67
+ return async function insertHeaders(ctx, next) {
68
+ for (const key in headers) if (!ctx.request.headers.has(key)) ctx.request.headers.set(key, headers[key]);
69
+ await next();
70
+ };
47
71
  }
48
- export {
49
- appendHeader,
50
- appendHeaders,
51
- insertHeader,
52
- insertHeaders,
53
- setHeader,
54
- setHeaders
55
- };
72
+ //#endregion
73
+ export { appendHeader, appendHeaders, insertHeader, insertHeaders, setHeader, setHeaders };
74
+
56
75
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type { KeqMiddleware } from 'keq'\n\n/**\n * Set a header.\n * If it already exists, the original value will be overwritten.\n *\n * 设置一个Header\n * 如果Header已经存在,则会覆盖原来的值\n */\nexport function setHeader(key: string, value: string): KeqMiddleware {\n return async function setHeader(ctx, next) {\n ctx.request.headers.set(key, value)\n await next()\n }\n}\n\n/**\n * Set headers.\n * If it already exists, the original value will be overwritten.\n *\n * 设置多个Header\n * 如果Header已经存在,则会覆盖原来的值\n */\nexport function setHeaders(headers: Record<string, string>): KeqMiddleware {\n return async function setHeaders(ctx, next) {\n for (const key in headers) {\n ctx.request.headers.set(key, headers[key])\n }\n\n await next()\n }\n}\n\n/**\n * Append a header\n *\n * 追加一个Header\n */\nexport function appendHeader(key: string, value: string): KeqMiddleware {\n return async function appendHeader(ctx, next) {\n ctx.request.headers.append(key, value)\n await next()\n }\n}\n\n/**\n * Append headers\n *\n * 追加多个Header\n */\nexport function appendHeaders(headers: Record<string, string>): KeqMiddleware {\n return async function appendHeaders(ctx, next) {\n for (const key in headers) {\n ctx.request.headers.append(key, headers[key])\n }\n await next()\n }\n}\n\n\n/**\n * Set a header, if it isn't existed.\n *\n * 添加一个Header,如果Header的Key已存在,则不添加\n */\nexport function insertHeader(key: string, value: string): KeqMiddleware {\n return async function insertHeader(ctx, next) {\n if (!ctx.request.headers.has(key)) {\n ctx.request.headers.set(key, value)\n }\n await next()\n }\n}\n\n/**\n * Set headers, if it isn't existed.\n *\n * 添加多个Header,已存在的Header将被忽略\n */\nexport function insertHeaders(headers: Record<string, string>): KeqMiddleware {\n return async function insertHeaders(ctx, next) {\n for (const key in headers) {\n if (!ctx.request.headers.has(key)) {\n ctx.request.headers.set(key, headers[key])\n }\n }\n\n await next()\n }\n}\n"],"mappings":";AASO,SAAS,UAAU,KAAa,OAA8B;AACnE,SAAO,eAAeA,WAAU,KAAK,MAAM;AACzC,QAAI,QAAQ,QAAQ,IAAI,KAAK,KAAK;AAClC,UAAM,KAAK;AAAA,EACb;AACF;AASO,SAAS,WAAW,SAAgD;AACzE,SAAO,eAAeC,YAAW,KAAK,MAAM;AAC1C,eAAW,OAAO,SAAS;AACzB,UAAI,QAAQ,QAAQ,IAAI,KAAK,QAAQ,GAAG,CAAC;AAAA,IAC3C;AAEA,UAAM,KAAK;AAAA,EACb;AACF;AAOO,SAAS,aAAa,KAAa,OAA8B;AACtE,SAAO,eAAeC,cAAa,KAAK,MAAM;AAC5C,QAAI,QAAQ,QAAQ,OAAO,KAAK,KAAK;AACrC,UAAM,KAAK;AAAA,EACb;AACF;AAOO,SAAS,cAAc,SAAgD;AAC5E,SAAO,eAAeC,eAAc,KAAK,MAAM;AAC7C,eAAW,OAAO,SAAS;AACzB,UAAI,QAAQ,QAAQ,OAAO,KAAK,QAAQ,GAAG,CAAC;AAAA,IAC9C;AACA,UAAM,KAAK;AAAA,EACb;AACF;AAQO,SAAS,aAAa,KAAa,OAA8B;AACtE,SAAO,eAAeC,cAAa,KAAK,MAAM;AAC5C,QAAI,CAAC,IAAI,QAAQ,QAAQ,IAAI,GAAG,GAAG;AACjC,UAAI,QAAQ,QAAQ,IAAI,KAAK,KAAK;AAAA,IACpC;AACA,UAAM,KAAK;AAAA,EACb;AACF;AAOO,SAAS,cAAc,SAAgD;AAC5E,SAAO,eAAeC,eAAc,KAAK,MAAM;AAC7C,eAAW,OAAO,SAAS;AACzB,UAAI,CAAC,IAAI,QAAQ,QAAQ,IAAI,GAAG,GAAG;AACjC,YAAI,QAAQ,QAAQ,IAAI,KAAK,QAAQ,GAAG,CAAC;AAAA,MAC3C;AAAA,IACF;AAEA,UAAM,KAAK;AAAA,EACb;AACF;","names":["setHeader","setHeaders","appendHeader","appendHeaders","insertHeader","insertHeaders"]}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["import type { KeqMiddleware } from 'keq'\n\n/**\n * Set a header.\n * If it already exists, the original value will be overwritten.\n *\n * 设置一个Header\n * 如果Header已经存在,则会覆盖原来的值\n */\nexport function setHeader(key: string, value: string): KeqMiddleware {\n return async function setHeader(ctx, next) {\n ctx.request.headers.set(key, value)\n await next()\n }\n}\n\n/**\n * Set headers.\n * If it already exists, the original value will be overwritten.\n *\n * 设置多个Header\n * 如果Header已经存在,则会覆盖原来的值\n */\nexport function setHeaders(headers: Record<string, string>): KeqMiddleware {\n return async function setHeaders(ctx, next) {\n for (const key in headers) {\n ctx.request.headers.set(key, headers[key])\n }\n\n await next()\n }\n}\n\n/**\n * Append a header\n *\n * 追加一个Header\n */\nexport function appendHeader(key: string, value: string): KeqMiddleware {\n return async function appendHeader(ctx, next) {\n ctx.request.headers.append(key, value)\n await next()\n }\n}\n\n/**\n * Append headers\n *\n * 追加多个Header\n */\nexport function appendHeaders(headers: Record<string, string>): KeqMiddleware {\n return async function appendHeaders(ctx, next) {\n for (const key in headers) {\n ctx.request.headers.append(key, headers[key])\n }\n await next()\n }\n}\n\n\n/**\n * Set a header, if it isn't existed.\n *\n * 添加一个Header,如果Header的Key已存在,则不添加\n */\nexport function insertHeader(key: string, value: string): KeqMiddleware {\n return async function insertHeader(ctx, next) {\n if (!ctx.request.headers.has(key)) {\n ctx.request.headers.set(key, value)\n }\n await next()\n }\n}\n\n/**\n * Set headers, if it isn't existed.\n *\n * 添加多个Header,已存在的Header将被忽略\n */\nexport function insertHeaders(headers: Record<string, string>): KeqMiddleware {\n return async function insertHeaders(ctx, next) {\n for (const key in headers) {\n if (!ctx.request.headers.has(key)) {\n ctx.request.headers.set(key, headers[key])\n }\n }\n\n await next()\n }\n}\n"],"mappings":";;;;;;;;AASA,SAAgB,UAAU,KAAa,OAA8B;AACnE,QAAO,eAAe,UAAU,KAAK,MAAM;AACzC,MAAI,QAAQ,QAAQ,IAAI,KAAK,MAAM;AACnC,QAAM,MAAM;;;;;;;;;;AAWhB,SAAgB,WAAW,SAAgD;AACzE,QAAO,eAAe,WAAW,KAAK,MAAM;AAC1C,OAAK,MAAM,OAAO,QAChB,KAAI,QAAQ,QAAQ,IAAI,KAAK,QAAQ,KAAK;AAG5C,QAAM,MAAM;;;;;;;;AAShB,SAAgB,aAAa,KAAa,OAA8B;AACtE,QAAO,eAAe,aAAa,KAAK,MAAM;AAC5C,MAAI,QAAQ,QAAQ,OAAO,KAAK,MAAM;AACtC,QAAM,MAAM;;;;;;;;AAShB,SAAgB,cAAc,SAAgD;AAC5E,QAAO,eAAe,cAAc,KAAK,MAAM;AAC7C,OAAK,MAAM,OAAO,QAChB,KAAI,QAAQ,QAAQ,OAAO,KAAK,QAAQ,KAAK;AAE/C,QAAM,MAAM;;;;;;;;AAUhB,SAAgB,aAAa,KAAa,OAA8B;AACtE,QAAO,eAAe,aAAa,KAAK,MAAM;AAC5C,MAAI,CAAC,IAAI,QAAQ,QAAQ,IAAI,IAAI,CAC/B,KAAI,QAAQ,QAAQ,IAAI,KAAK,MAAM;AAErC,QAAM,MAAM;;;;;;;;AAShB,SAAgB,cAAc,SAAgD;AAC5E,QAAO,eAAe,cAAc,KAAK,MAAM;AAC7C,OAAK,MAAM,OAAO,QAChB,KAAI,CAAC,IAAI,QAAQ,QAAQ,IAAI,IAAI,CAC/B,KAAI,QAAQ,QAAQ,IAAI,KAAK,QAAQ,KAAK;AAI9C,QAAM,MAAM"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@keq-request/headers",
3
- "version": "5.0.0-alpha.9",
3
+ "version": "5.0.0-beta.10",
4
4
  "description": "Set/Append headers to request.",
5
5
  "keywords": [
6
6
  "keq",
@@ -10,7 +10,7 @@
10
10
  "append",
11
11
  "insert"
12
12
  ],
13
- "homepage": "https://github.com/keq-request/keq#readme",
13
+ "homepage": "https://keq-request.github.io",
14
14
  "bugs": {
15
15
  "url": "https://github.com/keq-request/keq/issues"
16
16
  },
@@ -30,15 +30,15 @@
30
30
  }
31
31
  },
32
32
  "devDependencies": {
33
- "@types/node": "^20.19.24",
34
- "keq": "5.0.0-alpha.9"
33
+ "@types/node": "^20.19.39",
34
+ "keq": "5.0.0-beta.10"
35
35
  },
36
36
  "peerDependencies": {
37
- "keq": "^5.0.0-alpha.9"
37
+ "keq": "^5.0.0-beta.10"
38
38
  },
39
39
  "scripts": {
40
- "build": "tsup",
41
- "dev": "tsup --watch",
40
+ "build": "tsdown",
41
+ "dev": "tsdown --watch",
42
42
  "test": "jest",
43
43
  "test:update": "jest -u"
44
44
  }
@@ -0,0 +1,12 @@
1
+ import { defineConfig } from 'tsdown'
2
+
3
+ export default defineConfig({
4
+ entry: ['src/index.ts'],
5
+ format: ['cjs', 'esm'],
6
+ target: ['chrome91', 'firefox90', 'safari15', 'edge91', 'node20'],
7
+ platform: 'neutral',
8
+ tsconfig: 'tsconfig.lib.json',
9
+ dts: { sourcemap: true },
10
+ sourcemap: true,
11
+ clean: true,
12
+ })
@@ -1,18 +0,0 @@
1
-
2
- > @keq-request/headers@5.0.0-alpha.9 build /home/runner/work/keq/keq/packages/headers
3
- > tsup
4
-
5
- CLI Building entry: src/index.ts
6
- CLI Using tsconfig: tsconfig.lib.json
7
- CLI tsup v8.5.0
8
- CLI Using tsup config: /home/runner/work/keq/keq/packages/headers/tsup.config.ts
9
- CLI Target: esnext
10
- CLI Cleaning output folder
11
- CJS Build start
12
- ESM Build start
13
- CJS dist/index.js 2.44 KB
14
- CJS dist/index.js.map 3.17 KB
15
- CJS ⚡️ Build success in 33ms
16
- ESM dist/index.mjs 1.28 KB
17
- ESM dist/index.mjs.map 3.11 KB
18
- ESM ⚡️ Build success in 34ms
package/jest.config.cts DELETED
@@ -1,10 +0,0 @@
1
- import type { Config } from 'jest'
2
- import { pathsToModuleNameMapper } from 'ts-jest'
3
- import { compilerOptions } from './tsconfig.json'
4
-
5
-
6
- // eslint-disable-next-line @typescript-eslint/require-await
7
- export default async (): Promise<Config> => ({
8
- preset: 'ts-jest',
9
- moduleNameMapper: pathsToModuleNameMapper(compilerOptions.paths, { prefix: '<rootDir>/src', useESM: true }),
10
- })