| 362 | * @since 4.0.0 |
| 363 | */ |
| 364 | export const schemaNoBody = < |
| 365 | A, |
| 366 | I extends Partial<{ |
| 367 | readonly method: HttpMethod.HttpMethod |
| 368 | readonly url: string |
| 369 | readonly cookies: Readonly<Record<string, string | undefined>> |
| 370 | readonly headers: Readonly<Record<string, string | undefined>> |
| 371 | readonly pathParams: Readonly<Record<string, string | undefined>> |
| 372 | readonly searchParams: Readonly<Record<string, string | ReadonlyArray<string> | undefined>> |
| 373 | }>, |
| 374 | RD |
| 375 | >( |
| 376 | schema: Schema.ConstraintCodec<A, I, RD, unknown>, |
| 377 | options?: ParseOptions | undefined |
| 378 | ): Effect.Effect< |
| 379 | A, |
| 380 | Schema.SchemaError, |
| 381 | HttpServerRequest.HttpServerRequest | HttpServerRequest.ParsedSearchParams | RouteContext | RD |
| 382 | > => { |
| 383 | const parse = Schema.decodeUnknownEffect(schema) |
| 384 | return Effect.contextWith( |
| 385 | ( |
| 386 | context: Context.Context< |
| 387 | HttpServerRequest.HttpServerRequest | HttpServerRequest.ParsedSearchParams | RouteContext |
| 388 | > |
| 389 | ) => { |
| 390 | const request = Context.get(context, HttpServerRequest.HttpServerRequest) |
| 391 | const searchParams = Context.get(context, HttpServerRequest.ParsedSearchParams) |
| 392 | const routeContext = Context.get(context, RouteContext) |
| 393 | return parse({ |
| 394 | method: request.method, |
| 395 | url: request.url, |
| 396 | headers: request.headers, |
| 397 | cookies: request.cookies, |
| 398 | pathParams: routeContext.params, |
| 399 | searchParams |
| 400 | }, options) |
| 401 | } |
| 402 | ) |
| 403 | } |
| 404 | |
| 405 | /** |
| 406 | * Decodes a schema from the current route path parameters and search parameters. |