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

Function schemaParams

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

Source from the content-addressed store, hash-verified

119
120/** @internal */
121export const schemaParams = <A, I extends Readonly<Record<string, string | ReadonlyArray<string> | undefined>>, R>(
122 schema: Schema.Schema<A, I, R>,
123 options?: ParseOptions | undefined
124) => {
125 const parse = Schema.decodeUnknown(schema, options)
126 return Effect.flatMap(
127 Effect.context<ServerRequest.ParsedSearchParams | Router.RouteContext>(),
128 (context) => {
129 const searchParams = Context.get(context, ServerRequest.ParsedSearchParams)
130 const routeContext = Context.get(context, RouteContext)
131 return parse({ ...searchParams, ...routeContext.params })
132 }
133 )
134}
135
136/** @internal */
137export const schemaPathParams = <A, I extends Readonly<Record<string, 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