| 459 | * @since 4.0.0 |
| 460 | */ |
| 461 | export const schemaNoBody = < |
| 462 | A, |
| 463 | I extends Partial<{ |
| 464 | readonly method: HttpMethod.HttpMethod |
| 465 | readonly url: string |
| 466 | readonly cookies: Readonly<Record<string, string | undefined>> |
| 467 | readonly headers: Readonly<Record<string, string | undefined>> |
| 468 | readonly pathParams: Readonly<Record<string, string | undefined>> |
| 469 | readonly searchParams: Readonly<Record<string, string | ReadonlyArray<string> | undefined>> |
| 470 | }>, |
| 471 | RD |
| 472 | >( |
| 473 | schema: Schema.ConstraintCodec<A, I, RD, unknown>, |
| 474 | options?: ParseOptions | undefined |
| 475 | ): Effect.Effect< |
| 476 | A, |
| 477 | Schema.SchemaError, |
| 478 | HttpServerRequest.HttpServerRequest | HttpServerRequest.ParsedSearchParams | RouteContext | RD |
| 479 | > => { |
| 480 | const parse = Schema.decodeUnknownEffect(schema) |
| 481 | return Effect.contextWith( |
| 482 | ( |
| 483 | context: Context.Context< |
| 484 | HttpServerRequest.HttpServerRequest | HttpServerRequest.ParsedSearchParams | RouteContext |
| 485 | > |
| 486 | ) => { |
| 487 | const request = Context.get(context, HttpServerRequest.HttpServerRequest) |
| 488 | const searchParams = Context.get(context, HttpServerRequest.ParsedSearchParams) |
| 489 | const routeContext = Context.get(context, RouteContext) |
| 490 | return parse({ |
| 491 | method: request.method, |
| 492 | url: request.url, |
| 493 | headers: request.headers, |
| 494 | cookies: request.cookies, |
| 495 | pathParams: routeContext.params, |
| 496 | searchParams |
| 497 | }, options) |
| 498 | } |
| 499 | ) |
| 500 | } |
| 501 | |
| 502 | /** |
| 503 | * Decodes a schema from the current route path parameters and search parameters. |