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

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,268 @@
1
1
  # Changelog
2
2
 
3
+ ## 5.0.0-beta.2
4
+
5
+ ### Patch Changes
6
+
7
+ - keq@5.0.0-beta.2
8
+
9
+ ## 5.0.0-beta.1
10
+
11
+ ### Major Changes
12
+
13
+ - 5175097: **BREAKING CHANGE:** group all packages under the @keq-request scope
14
+
15
+ - keq-cache => @keq-request/cache
16
+ - keq-headers => @keq-request/headers
17
+ - keq-cli => @keq-request/cli
18
+ - keq-url => @keq-request/url
19
+ - keq-exception => @keq-request/exception
20
+
21
+ - 0a04864: **Fix:** fix: update browser targets to chrome91/firefox90/safari15/edge91 to resolve esbuild 0.27 destructuring build errors.
22
+
23
+ ### Patch Changes
24
+
25
+ - 2686b8d: build with turbo
26
+ - 2686b8d: remove private dependencies
27
+ - e7eb9dc: Don't publish .turbo and jest.config.cts to npm
28
+ - 0873c7e: Incorrect build before release.
29
+ - 581815a: ensure compatibility
30
+ - 7343445: Incorrect build before release
31
+ - Updated dependencies [cbc5d17]
32
+ - Updated dependencies [153244f]
33
+ - Updated dependencies [153244f]
34
+ - Updated dependencies [153244f]
35
+ - Updated dependencies [0a2eb2f]
36
+ - Updated dependencies [153244f]
37
+ - Updated dependencies [214ae66]
38
+ - Updated dependencies [c7ffd1f]
39
+ - Updated dependencies [90311b3]
40
+ - Updated dependencies [1f367c0]
41
+ - Updated dependencies [0c7db81]
42
+ - Updated dependencies [df114d1]
43
+ - Updated dependencies [2686b8d]
44
+ - Updated dependencies [842e555]
45
+ - Updated dependencies [153244f]
46
+ - Updated dependencies [2686b8d]
47
+ - Updated dependencies [9290139]
48
+ - Updated dependencies [7873a0a]
49
+ - Updated dependencies [e7eb9dc]
50
+ - Updated dependencies [7ff2162]
51
+ - Updated dependencies [22ce01a]
52
+ - Updated dependencies [0873c7e]
53
+ - Updated dependencies [153244f]
54
+ - Updated dependencies [a7a83da]
55
+ - Updated dependencies [f194c41]
56
+ - Updated dependencies [153244f]
57
+ - Updated dependencies [153244f]
58
+ - Updated dependencies [d076b76]
59
+ - Updated dependencies [f8abc63]
60
+ - Updated dependencies [153244f]
61
+ - Updated dependencies [ca6c879]
62
+ - Updated dependencies [63161c4]
63
+ - Updated dependencies [d472648]
64
+ - Updated dependencies [b8d02ca]
65
+ - Updated dependencies [0a04864]
66
+ - Updated dependencies [581815a]
67
+ - Updated dependencies [7343445]
68
+ - Updated dependencies [153244f]
69
+ - Updated dependencies [eed26f9]
70
+ - keq@5.0.0-beta.1
71
+
72
+ ## 5.0.0-alpha.36
73
+
74
+ ### Patch Changes
75
+
76
+ - keq@5.0.0-alpha.36
77
+
78
+ ## 5.0.0-alpha.35
79
+
80
+ ### Major Changes
81
+
82
+ - 0a04864: **Fix:** fix: update browser targets to chrome91/firefox90/safari15/edge91 to resolve esbuild 0.27 destructuring build errors.
83
+
84
+ ### Patch Changes
85
+
86
+ - Updated dependencies [0a04864]
87
+ - keq@5.0.0-alpha.35
88
+
89
+ ## 5.0.0-alpha.34
90
+
91
+ ### Patch Changes
92
+
93
+ - Updated dependencies [a7a83da]
94
+ - Updated dependencies [f8abc63]
95
+ - keq@5.0.0-alpha.34
96
+
97
+ ## 5.0.0-alpha.33
98
+
99
+ ### Patch Changes
100
+
101
+ - keq@5.0.0-alpha.33
102
+
103
+ ## 5.0.0-alpha.32
104
+
105
+ ### Patch Changes
106
+
107
+ - Updated dependencies [f194c41]
108
+ - Updated dependencies [b8d02ca]
109
+ - keq@5.0.0-alpha.32
110
+
111
+ ## 5.0.0-alpha.31
112
+
113
+ ### Patch Changes
114
+
115
+ - keq@5.0.0-alpha.31
116
+
117
+ ## 5.0.0-alpha.30
118
+
119
+ ### Patch Changes
120
+
121
+ - keq@5.0.0-alpha.30
122
+
123
+ ## 5.0.0-alpha.29
124
+
125
+ ### Patch Changes
126
+
127
+ - keq@5.0.0-alpha.29
128
+
129
+ ## 5.0.0-alpha.28
130
+
131
+ ### Patch Changes
132
+
133
+ - Updated dependencies [d076b76]
134
+ - keq@5.0.0-alpha.28
135
+
136
+ ## 5.0.0-alpha.27
137
+
138
+ ### Patch Changes
139
+
140
+ - Updated dependencies [0c7db81]
141
+ - keq@5.0.0-alpha.27
142
+
143
+ ## 5.0.0-alpha.26
144
+
145
+ ### Patch Changes
146
+
147
+ - Updated dependencies [22ce01a]
148
+ - Updated dependencies [63161c4]
149
+ - keq@5.0.0-alpha.26
150
+
151
+ ## 5.0.0-alpha.25
152
+
153
+ ### Patch Changes
154
+
155
+ - Updated dependencies [214ae66]
156
+ - Updated dependencies [9290139]
157
+ - keq@5.0.0-alpha.25
158
+
159
+ ## 5.0.0-alpha.24
160
+
161
+ ### Patch Changes
162
+
163
+ - Updated dependencies [0a2eb2f]
164
+ - keq@5.0.0-alpha.24
165
+
166
+ ## 5.0.0-alpha.23
167
+
168
+ ### Patch Changes
169
+
170
+ - Updated dependencies [842e555]
171
+ - Updated dependencies [7873a0a]
172
+ - keq@5.0.0-alpha.23
173
+
174
+ ## 5.0.0-alpha.22
175
+
176
+ ### Patch Changes
177
+
178
+ - Updated dependencies [df114d1]
179
+ - keq@5.0.0-alpha.22
180
+
181
+ ## 5.0.0-alpha.21
182
+
183
+ ### Patch Changes
184
+
185
+ - Updated dependencies [90311b3]
186
+ - keq@5.0.0-alpha.21
187
+
188
+ ## 5.0.0-alpha.20
189
+
190
+ ### Patch Changes
191
+
192
+ - Updated dependencies [1f367c0]
193
+ - keq@5.0.0-alpha.20
194
+
195
+ ## 5.0.0-alpha.19
196
+
197
+ ### Patch Changes
198
+
199
+ - keq@5.0.0-alpha.19
200
+
201
+ ## 5.0.0-alpha.18
202
+
203
+ ### Patch Changes
204
+
205
+ - Updated dependencies [cbc5d17]
206
+ - keq@5.0.0-alpha.18
207
+
208
+ ## 5.0.0-alpha.17
209
+
210
+ ### Patch Changes
211
+
212
+ - Updated dependencies [d472648]
213
+ - Updated dependencies [eed26f9]
214
+ - keq@5.0.0-alpha.17
215
+
216
+ ## 5.0.0-alpha.16
217
+
218
+ ### Patch Changes
219
+
220
+ - Updated dependencies [ca6c879]
221
+ - keq@5.0.0-alpha.16
222
+
223
+ ## 5.0.0-alpha.15
224
+
225
+ ### Patch Changes
226
+
227
+ - keq@5.0.0-alpha.15
228
+
229
+ ## 5.0.0-alpha.14
230
+
231
+ ### Patch Changes
232
+
233
+ - keq@5.0.0-alpha.14
234
+
235
+ ## 5.0.0-alpha.13
236
+
237
+ ### Patch Changes
238
+
239
+ - keq@5.0.0-alpha.13
240
+
241
+ ## 5.0.0-alpha.12
242
+
243
+ ### Patch Changes
244
+
245
+ - 581815a: ensure compatibility
246
+ - Updated dependencies [581815a]
247
+ - keq@5.0.0-alpha.12
248
+
249
+ ## 5.0.0-alpha.11
250
+
251
+ ### Patch Changes
252
+
253
+ - Updated dependencies [c7ffd1f]
254
+ - keq@5.0.0-alpha.11
255
+
256
+ ## 5.0.0-alpha.10
257
+
258
+ ### Patch Changes
259
+
260
+ - e7eb9dc: Don't publish .turbo and jest.config.cts to npm
261
+ - 7343445: Incorrect build before release
262
+ - Updated dependencies [e7eb9dc]
263
+ - Updated dependencies [7343445]
264
+ - keq@5.0.0-alpha.10
265
+
3
266
  ## 5.0.0-alpha.9
4
267
 
5
268
  ### 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.2",
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.2"
35
35
  },
36
36
  "peerDependencies": {
37
- "keq": "^5.0.0-alpha.9"
37
+ "keq": "^5.0.0-beta.2"
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
- })