| 83 | |
| 84 | /** @internal */ |
| 85 | export const schemaNoBody = < |
| 86 | R, |
| 87 | I extends Partial<{ |
| 88 | readonly method: Method.HttpMethod |
| 89 | readonly url: string |
| 90 | readonly cookies: Readonly<Record<string, string | undefined>> |
| 91 | readonly headers: Readonly<Record<string, string | undefined>> |
| 92 | readonly pathParams: Readonly<Record<string, string | undefined>> |
| 93 | readonly searchParams: Readonly<Record<string, string | ReadonlyArray<string> | undefined>> |
| 94 | }>, |
| 95 | A |
| 96 | >( |
| 97 | schema: Schema.Schema<A, I, R>, |
| 98 | options?: ParseOptions | undefined |
| 99 | ) => { |
| 100 | const parse = Schema.decodeUnknown(schema, options) |
| 101 | return Effect.flatMap( |
| 102 | Effect.context<ServerRequest.HttpServerRequest | ServerRequest.ParsedSearchParams | Router.RouteContext>(), |
| 103 | (context) => { |
| 104 | const request = Context.get(context, ServerRequest.HttpServerRequest) |
| 105 | const searchParams = Context.get(context, ServerRequest.ParsedSearchParams) |
| 106 | const routeContext = Context.get(context, RouteContext) |
| 107 | return parse({ |
| 108 | method: request.method, |
| 109 | url: request.url, |
| 110 | headers: request.headers, |
| 111 | cookies: request.cookies, |
| 112 | pathParams: routeContext.params, |
| 113 | searchParams |
| 114 | }) |
| 115 | } |
| 116 | ) |
| 117 | } |
| 118 | |
| 119 | /** @internal */ |
| 120 | export const schemaParams = <A, I extends Readonly<Record<string, string | ReadonlyArray<string> | undefined>>, R>( |