MCPcopy Create free account
hub / github.com/Effect-TS/effect / schemaNoBody

Function schemaNoBody

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

Source from the content-addressed store, hash-verified

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