@effect/platform 0.71.2 → 0.71.4
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/dist/cjs/HttpApi.js +6 -8
- package/dist/cjs/HttpApi.js.map +1 -1
- package/dist/cjs/HttpApiEndpoint.js +7 -9
- package/dist/cjs/HttpApiEndpoint.js.map +1 -1
- package/dist/cjs/HttpApiGroup.js +4 -6
- package/dist/cjs/HttpApiGroup.js.map +1 -1
- package/dist/cjs/HttpApiSchema.js +25 -1
- package/dist/cjs/HttpApiSchema.js.map +1 -1
- package/dist/cjs/HttpServerResponse.js +6 -1
- package/dist/cjs/HttpServerResponse.js.map +1 -1
- package/dist/cjs/internal/httpPlatform.js +2 -2
- package/dist/cjs/internal/httpPlatform.js.map +1 -1
- package/dist/cjs/internal/httpServerResponse.js +30 -13
- package/dist/cjs/internal/httpServerResponse.js.map +1 -1
- package/dist/dts/HttpApi.d.ts.map +1 -1
- package/dist/dts/HttpApiEndpoint.d.ts.map +1 -1
- package/dist/dts/HttpApiGroup.d.ts.map +1 -1
- package/dist/dts/HttpApiSchema.d.ts +5 -0
- package/dist/dts/HttpApiSchema.d.ts.map +1 -1
- package/dist/dts/HttpServerResponse.d.ts +6 -1
- package/dist/dts/HttpServerResponse.d.ts.map +1 -1
- package/dist/esm/HttpApi.js +6 -8
- package/dist/esm/HttpApi.js.map +1 -1
- package/dist/esm/HttpApiEndpoint.js +7 -9
- package/dist/esm/HttpApiEndpoint.js.map +1 -1
- package/dist/esm/HttpApiGroup.js +4 -6
- package/dist/esm/HttpApiGroup.js.map +1 -1
- package/dist/esm/HttpApiSchema.js +23 -0
- package/dist/esm/HttpApiSchema.js.map +1 -1
- package/dist/esm/HttpServerResponse.js +5 -0
- package/dist/esm/HttpServerResponse.js.map +1 -1
- package/dist/esm/internal/httpPlatform.js +2 -2
- package/dist/esm/internal/httpPlatform.js.map +1 -1
- package/dist/esm/internal/httpServerResponse.js +28 -12
- package/dist/esm/internal/httpServerResponse.js.map +1 -1
- package/package.json +2 -2
- package/src/HttpApi.ts +6 -11
- package/src/HttpApiEndpoint.ts +5 -18
- package/src/HttpApiGroup.ts +2 -9
- package/src/HttpApiSchema.ts +24 -0
- package/src/HttpServerResponse.ts +8 -1
- package/src/internal/httpPlatform.ts +6 -2
- package/src/internal/httpServerResponse.ts +50 -21
|
@@ -91,36 +91,60 @@ export const empty = (options?: ServerResponse.Options.WithContent | undefined):
|
|
|
91
91
|
new ServerResponseImpl(
|
|
92
92
|
options?.status ?? 204,
|
|
93
93
|
options?.statusText,
|
|
94
|
-
options?.headers
|
|
94
|
+
options?.headers ? Headers.fromInput(options.headers) : Headers.empty,
|
|
95
95
|
options?.cookies ?? Cookies.empty,
|
|
96
96
|
internalBody.empty
|
|
97
97
|
)
|
|
98
98
|
|
|
99
|
+
/** @internal */
|
|
100
|
+
export const redirect = (
|
|
101
|
+
location: string,
|
|
102
|
+
options?: ServerResponse.Options.WithContentType | undefined
|
|
103
|
+
): ServerResponse.HttpServerResponse => {
|
|
104
|
+
const headers = Headers.unsafeFromRecord({ location })
|
|
105
|
+
return new ServerResponseImpl(
|
|
106
|
+
options?.status ?? 301,
|
|
107
|
+
options?.statusText,
|
|
108
|
+
options?.headers ?
|
|
109
|
+
Headers.merge(
|
|
110
|
+
headers,
|
|
111
|
+
Headers.fromInput(options.headers)
|
|
112
|
+
) :
|
|
113
|
+
headers,
|
|
114
|
+
options?.cookies ?? Cookies.empty,
|
|
115
|
+
internalBody.empty
|
|
116
|
+
)
|
|
117
|
+
}
|
|
118
|
+
|
|
99
119
|
/** @internal */
|
|
100
120
|
export const uint8Array = (
|
|
101
121
|
body: Uint8Array,
|
|
102
122
|
options?: ServerResponse.Options.WithContentType
|
|
103
|
-
): ServerResponse.HttpServerResponse =>
|
|
104
|
-
|
|
123
|
+
): ServerResponse.HttpServerResponse => {
|
|
124
|
+
const headers = options?.headers ? Headers.fromInput(options.headers) : Headers.empty
|
|
125
|
+
return new ServerResponseImpl(
|
|
105
126
|
options?.status ?? 200,
|
|
106
127
|
options?.statusText,
|
|
107
|
-
|
|
128
|
+
headers,
|
|
108
129
|
options?.cookies ?? Cookies.empty,
|
|
109
|
-
internalBody.uint8Array(body, getContentType(options))
|
|
130
|
+
internalBody.uint8Array(body, getContentType(options, headers))
|
|
110
131
|
)
|
|
132
|
+
}
|
|
111
133
|
|
|
112
134
|
/** @internal */
|
|
113
135
|
export const text = (
|
|
114
136
|
body: string,
|
|
115
137
|
options?: ServerResponse.Options.WithContentType
|
|
116
|
-
): ServerResponse.HttpServerResponse =>
|
|
117
|
-
|
|
138
|
+
): ServerResponse.HttpServerResponse => {
|
|
139
|
+
const headers = options?.headers ? Headers.fromInput(options.headers) : Headers.empty
|
|
140
|
+
return new ServerResponseImpl(
|
|
118
141
|
options?.status ?? 200,
|
|
119
142
|
options?.statusText,
|
|
120
|
-
|
|
143
|
+
headers,
|
|
121
144
|
options?.cookies ?? Cookies.empty,
|
|
122
|
-
internalBody.text(body, getContentType(options))
|
|
145
|
+
internalBody.text(body, getContentType(options, headers))
|
|
123
146
|
)
|
|
147
|
+
}
|
|
124
148
|
|
|
125
149
|
/** @internal */
|
|
126
150
|
export const html: {
|
|
@@ -177,7 +201,7 @@ export const json = (
|
|
|
177
201
|
new ServerResponseImpl(
|
|
178
202
|
options?.status ?? 200,
|
|
179
203
|
options?.statusText,
|
|
180
|
-
options?.headers
|
|
204
|
+
options?.headers ? Headers.fromInput(options.headers) : Headers.empty,
|
|
181
205
|
options?.cookies ?? Cookies.empty,
|
|
182
206
|
body
|
|
183
207
|
))
|
|
@@ -190,7 +214,7 @@ export const unsafeJson = (
|
|
|
190
214
|
new ServerResponseImpl(
|
|
191
215
|
options?.status ?? 200,
|
|
192
216
|
options?.statusText,
|
|
193
|
-
options?.headers
|
|
217
|
+
options?.headers ? Headers.fromInput(options.headers) : Headers.empty,
|
|
194
218
|
options?.cookies ?? Cookies.empty,
|
|
195
219
|
internalBody.unsafeJson(body)
|
|
196
220
|
)
|
|
@@ -209,7 +233,7 @@ export const schemaJson = <A, I, R>(
|
|
|
209
233
|
new ServerResponseImpl(
|
|
210
234
|
options?.status ?? 200,
|
|
211
235
|
options?.statusText,
|
|
212
|
-
options?.headers
|
|
236
|
+
options?.headers ? Headers.fromInput(options.headers) : Headers.empty,
|
|
213
237
|
options?.cookies ?? Cookies.empty,
|
|
214
238
|
body
|
|
215
239
|
))
|
|
@@ -245,7 +269,7 @@ export const urlParams = (
|
|
|
245
269
|
new ServerResponseImpl(
|
|
246
270
|
options?.status ?? 200,
|
|
247
271
|
options?.statusText,
|
|
248
|
-
options?.headers
|
|
272
|
+
options?.headers ? Headers.fromInput(options.headers) : Headers.empty,
|
|
249
273
|
options?.cookies ?? Cookies.empty,
|
|
250
274
|
internalBody.text(UrlParams.toString(UrlParams.fromInput(body)), "application/x-www-form-urlencoded")
|
|
251
275
|
)
|
|
@@ -255,7 +279,7 @@ export const raw = (body: unknown, options?: ServerResponse.Options | undefined)
|
|
|
255
279
|
new ServerResponseImpl(
|
|
256
280
|
options?.status ?? 200,
|
|
257
281
|
options?.statusText,
|
|
258
|
-
options?.headers
|
|
282
|
+
options?.headers ? Headers.fromInput(options.headers) : Headers.empty,
|
|
259
283
|
options?.cookies ?? Cookies.empty,
|
|
260
284
|
internalBody.raw(body)
|
|
261
285
|
)
|
|
@@ -268,7 +292,7 @@ export const formData = (
|
|
|
268
292
|
new ServerResponseImpl(
|
|
269
293
|
options?.status ?? 200,
|
|
270
294
|
options?.statusText,
|
|
271
|
-
options?.headers
|
|
295
|
+
options?.headers ? Headers.fromInput(options.headers) : Headers.empty,
|
|
272
296
|
options?.cookies ?? Cookies.empty,
|
|
273
297
|
internalBody.formData(body)
|
|
274
298
|
)
|
|
@@ -277,21 +301,26 @@ export const formData = (
|
|
|
277
301
|
export const stream = <E>(
|
|
278
302
|
body: Stream.Stream<Uint8Array, E>,
|
|
279
303
|
options?: ServerResponse.Options | undefined
|
|
280
|
-
): ServerResponse.HttpServerResponse =>
|
|
281
|
-
|
|
304
|
+
): ServerResponse.HttpServerResponse => {
|
|
305
|
+
const headers = options?.headers ? Headers.fromInput(options.headers) : Headers.empty
|
|
306
|
+
return new ServerResponseImpl(
|
|
282
307
|
options?.status ?? 200,
|
|
283
308
|
options?.statusText,
|
|
284
|
-
|
|
309
|
+
headers,
|
|
285
310
|
options?.cookies ?? Cookies.empty,
|
|
286
|
-
internalBody.stream(body, getContentType(options), options?.contentLength)
|
|
311
|
+
internalBody.stream(body, getContentType(options, headers), options?.contentLength)
|
|
287
312
|
)
|
|
313
|
+
}
|
|
288
314
|
|
|
289
315
|
/** @internal */
|
|
290
|
-
export const getContentType = (
|
|
316
|
+
export const getContentType = (
|
|
317
|
+
options: ServerResponse.Options | undefined,
|
|
318
|
+
headers: Headers.Headers
|
|
319
|
+
): string | undefined => {
|
|
291
320
|
if (options?.contentType) {
|
|
292
321
|
return options.contentType
|
|
293
322
|
} else if (options?.headers) {
|
|
294
|
-
return
|
|
323
|
+
return headers["content-type"]
|
|
295
324
|
} else {
|
|
296
325
|
return
|
|
297
326
|
}
|