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

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