MCPcopy Create free account
hub / github.com/Effect-TS/effect / schemaBodyForm

Function schemaBodyForm

packages/effect/src/http/HttpServerRequest.ts:314–333  ·  view source on GitHub ↗
(
  schema: Schema.ConstraintCodec<A, I, RD, unknown>,
  options?: ParseOptions | undefined
)

Source from the content-addressed store, hash-verified

312 * @since 4.0.0
313 */
314export const schemaBodyForm = <A, I extends Partial<Multipart.Persisted>, RD>(
315 schema: Schema.ConstraintCodec<A, I, RD, unknown>,
316 options?: ParseOptions | undefined
317) => {
318 const parseMultipart = Multipart.schemaPersisted(schema)
319 const parseUrlParams = HttpIncomingMessage.schemaBodyUrlParams(
320 schema as Schema.ConstraintCodec<A, any, RD, unknown>,
321 options
322 )
323 return Effect.flatMap(HttpServerRequest, (request): Effect.Effect<
324 A,
325 Multipart.MultipartError | Schema.SchemaError | HttpServerError,
326 RD | HttpServerRequest | Scope.Scope | FileSystem.FileSystem | Path.Path
327 > => {
328 if (isMultipart(request)) {
329 return Effect.flatMap(request.multipart, (_) => parseMultipart(_, options))
330 }
331 return parseUrlParams(request)
332 })
333}
334
335/**
336 * Reads the current request body as URL-encoded parameters and decodes them with

Callers

nothing calls this directly

Calls 1

isMultipartFunction · 0.85

Tested by

no test coverage detected