@johntalton/http-core 1.1.1 → 1.1.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/package.json +2 -2
- package/src/epilogue.js +15 -2
- package/src/index.js +18 -8
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@johntalton/http-core",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.1.
|
|
4
|
+
"version": "1.1.2",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"exports": {
|
|
7
7
|
".": "./src/index.js"
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"lint": "biome check"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@johntalton/http-util": "^7.0.
|
|
19
|
+
"@johntalton/http-util": "^7.0.3",
|
|
20
20
|
"@johntalton/sse-util": "^1.0.0"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
package/src/epilogue.js
CHANGED
|
@@ -99,6 +99,20 @@ export function epilogue(state) {
|
|
|
99
99
|
const { obj, encoding, etag, lastModified, age, supportedQueryTypes } = state
|
|
100
100
|
Response.json(stream, obj, { encoding, etag, lastModified, age, cacheControl: state.cacheControl ?? {} }, { supportedQueryTypes }, meta)
|
|
101
101
|
} break
|
|
102
|
+
case 'encoded': {
|
|
103
|
+
const { contentType, encoding, etag, lastModified, age, supportedQueryTypes } = state
|
|
104
|
+
|
|
105
|
+
Response.encoded(stream, state.obj, {
|
|
106
|
+
contentType,
|
|
107
|
+
encoding,
|
|
108
|
+
etag,
|
|
109
|
+
lastModified,
|
|
110
|
+
age,
|
|
111
|
+
cacheControl: state.cacheControl ?? {}
|
|
112
|
+
}, {
|
|
113
|
+
supportedQueryTypes
|
|
114
|
+
}, meta)
|
|
115
|
+
} break
|
|
102
116
|
case 'partial-bytes': {
|
|
103
117
|
const { contentType, contentLength, etag, lastModified, age } = state
|
|
104
118
|
|
|
@@ -112,12 +126,11 @@ export function epilogue(state) {
|
|
|
112
126
|
cacheControl: state.cacheControl ?? {} }, meta)
|
|
113
127
|
} break
|
|
114
128
|
case 'bytes': {
|
|
115
|
-
const { contentType, contentLength,
|
|
129
|
+
const { contentType, contentLength, etag, lastModified, age, acceptRanges } = state
|
|
116
130
|
|
|
117
131
|
Response.bytes(stream, state.obj, {
|
|
118
132
|
contentType,
|
|
119
133
|
contentLength,
|
|
120
|
-
encoding: encoding ?? 'identity',
|
|
121
134
|
etag,
|
|
122
135
|
lastModified,
|
|
123
136
|
age,
|
package/src/index.js
CHANGED
|
@@ -54,7 +54,7 @@ export const KNOWN_METHODS = [
|
|
|
54
54
|
CacheControlOptions
|
|
55
55
|
} from '@johntalton/http-util/headers' */
|
|
56
56
|
/** @import { AcceptStyleItem } from '@johntalton/http-util/util' */
|
|
57
|
-
/** @import { SendBody } from '@johntalton/http-util/response' */
|
|
57
|
+
/** @import { SendBody, NonEmptyArray } from '@johntalton/http-util/response' */
|
|
58
58
|
/** @import { SecFetchSite, SecFetchMode, SecFetchDest } from '@johntalton/http-util/headers' */
|
|
59
59
|
|
|
60
60
|
|
|
@@ -99,6 +99,7 @@ export const KNOWN_METHODS = [
|
|
|
99
99
|
'sse' |
|
|
100
100
|
'bytes' |
|
|
101
101
|
'partial-bytes' |
|
|
102
|
+
'encoded' |
|
|
102
103
|
'json' |
|
|
103
104
|
'error'
|
|
104
105
|
} RouteType */
|
|
@@ -182,11 +183,6 @@ export const KNOWN_METHODS = [
|
|
|
182
183
|
*/
|
|
183
184
|
/** @typedef {RouteBase & RouteRequestBase} RouteRequest */
|
|
184
185
|
|
|
185
|
-
/**
|
|
186
|
-
* @template T
|
|
187
|
-
* @typedef {[ T, ...T[] ]} NonEmptyArray
|
|
188
|
-
*/
|
|
189
|
-
|
|
190
186
|
/**
|
|
191
187
|
* @typedef {Object} PartialBytes
|
|
192
188
|
* @property {SendBody} obj
|
|
@@ -423,9 +419,8 @@ export const KNOWN_METHODS = [
|
|
|
423
419
|
* @typedef {Object} RouteBytesBase
|
|
424
420
|
* @property {'bytes'} type
|
|
425
421
|
* @property {string} contentType
|
|
426
|
-
* @property {SendBody
|
|
422
|
+
* @property {SendBody} obj
|
|
427
423
|
* @property {number|undefined} [contentLength]
|
|
428
|
-
* @property {string | undefined} [encoding]
|
|
429
424
|
* @property {IMFFixDateInput|string|undefined} [lastModified]
|
|
430
425
|
* @property {EtagItem|undefined} [etag]
|
|
431
426
|
* @property {number|undefined} [age]
|
|
@@ -447,6 +442,20 @@ export const KNOWN_METHODS = [
|
|
|
447
442
|
*/
|
|
448
443
|
/** @typedef {RouteBase & RoutePartialBytesBase} RoutePartialBytes */
|
|
449
444
|
|
|
445
|
+
/**
|
|
446
|
+
* @typedef {Object} RouteEncodedBase
|
|
447
|
+
* @property {'encoded'} type
|
|
448
|
+
* @property {SendBody} obj
|
|
449
|
+
* @property {string} contentType
|
|
450
|
+
* @property {string|undefined} [encoding]
|
|
451
|
+
* @property {EtagItem|undefined} [etag]
|
|
452
|
+
* @property {IMFFixDateInput|string|undefined} [lastModified]
|
|
453
|
+
* @property {number|undefined} [age]
|
|
454
|
+
* @property {CacheControlOptions|undefined} [cacheControl]
|
|
455
|
+
* @property {Array<string>|undefined} [supportedQueryTypes]
|
|
456
|
+
*/
|
|
457
|
+
/** @typedef {RouteBase & RouteEncodedBase} RouteEncoded */
|
|
458
|
+
|
|
450
459
|
/**
|
|
451
460
|
* @typedef {Object} RouteJSONBase
|
|
452
461
|
* @property {'json'} type
|
|
@@ -503,6 +512,7 @@ export const KNOWN_METHODS = [
|
|
|
503
512
|
RouteSSE |
|
|
504
513
|
RouteBytes |
|
|
505
514
|
RoutePartialBytes |
|
|
515
|
+
RouteEncoded |
|
|
506
516
|
RouteJSON |
|
|
507
517
|
RouteError
|
|
508
518
|
} RouteAction */
|