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

Function schemaBodyJson

packages/effect/src/unstable/http/HttpIncomingMessage.ts:64–70  ·  view source on GitHub ↗
(schema: S, options?: ParseOptions | undefined)

Source from the content-addressed store, hash-verified

62 * @since 4.0.0
63 */
64export const schemaBodyJson = <S extends Schema.Constraint>(schema: S, options?: ParseOptions | undefined) => {
65 const decode = Schema.decodeEffect(Schema.toCodecJson(schema))
66 return <E>(
67 self: HttpIncomingMessage<E>
68 ): Effect.Effect<S["Type"], E | Schema.SchemaError, S["DecodingServices"]> =>
69 Effect.flatMap(self.json, (u) => decode(u, options))
70}
71
72/**
73 * Creates a decoder that reads an incoming message's URL-encoded body parameters and decodes them with the supplied schema.

Callers

nothing calls this directly

Calls 2

decodeFunction · 0.50
toCodecJsonMethod · 0.45

Tested by

no test coverage detected