( schema: Schema.ConstraintDecoder<A, RD>, options?: (ParseOptions & HttpIncomingMessage.JsonOptions) | undefined )
| 394 | * @since 4.0.0 |
| 395 | */ |
| 396 | export const schemaBodyFormJson = <A, RD>( |
| 397 | schema: Schema.ConstraintDecoder<A, RD>, |
| 398 | options?: (ParseOptions & HttpIncomingMessage.JsonOptions) | undefined |
| 399 | ) => { |
| 400 | const parseMultipart = Multipart.schemaJson(schema, options) |
| 401 | return (field: string) => { |
| 402 | const parseUrlParams = Schema.JsonFromUrlParamsField(field, options).pipe( |
| 403 | Schema.decodeTo(schema), |
| 404 | Schema.decodeEffect |
| 405 | ) |
| 406 | return Effect.flatMap( |
| 407 | HttpServerRequest, |
| 408 | (request): Effect.Effect< |
| 409 | A, |
| 410 | Schema.SchemaError | HttpServerError, |
| 411 | RD | FileSystem.FileSystem | Path.Path | Scope.Scope | HttpServerRequest |
| 412 | > => { |
| 413 | if (isMultipart(request)) { |
| 414 | return Effect.flatMap( |
| 415 | Effect.mapError(request.multipart, (cause) => |
| 416 | new HttpServerError({ |
| 417 | reason: new RequestParseError({ |
| 418 | request, |
| 419 | cause |
| 420 | }) |
| 421 | })), |
| 422 | parseMultipart(field) |
| 423 | ) |
| 424 | } |
| 425 | return Effect.flatMap(request.urlParamsBody, (_) => parseUrlParams(_, options)) |
| 426 | } |
| 427 | ) |
| 428 | } |
| 429 | } |
| 430 | |
| 431 | /** |
| 432 | * Creates an `HttpServerRequest` view of an `HttpClientRequest`. |
nothing calls this directly
no test coverage detected