MCPcopy Index your code
hub / github.com/Effect-TS/effect / schemaNoBody

Function schemaNoBody

packages/platform/src/internal/httpRouter.ts:85–117  ·  view source on GitHub ↗
(
  schema: Schema.Schema<A, I, R>,
  options?: ParseOptions | undefined
)

Source from the content-addressed store, hash-verified

83
84/** @internal */
85export 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 */
120export const schemaParams = <A, I extends Readonly<Record<string, string | ReadonlyArray<string> | undefined>>, R>(

Callers

nothing calls this directly

Calls 3

parseFunction · 0.70
contextMethod · 0.65
getMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…