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

Function schemaParams

packages/effect/src/unstable/http/HttpRouter.ts:415–425  ·  view source on GitHub ↗
(
  schema: Schema.ConstraintCodec<A, I, RD, unknown>,
  options?: ParseOptions | undefined
)

Source from the content-addressed store, hash-verified

413 * @since 4.0.0
414 */
415export const schemaParams = <A, I extends Readonly<Record<string, string | ReadonlyArray<string> | undefined>>, RD>(
416 schema: Schema.ConstraintCodec<A, I, RD, unknown>,
417 options?: ParseOptions | undefined
418): Effect.Effect<A, Schema.SchemaError, HttpServerRequest.ParsedSearchParams | RouteContext | RD> => {
419 const parse = Schema.decodeUnknownEffect(schema)
420 return Effect.contextWith((context: Context.Context<HttpServerRequest.ParsedSearchParams | RouteContext>) => {
421 const searchParams = Context.get(context, HttpServerRequest.ParsedSearchParams)
422 const routeContext = Context.get(context, RouteContext)
423 return parse({ ...searchParams, ...routeContext.params }, options)
424 })
425}
426
427/**
428 * Decodes a schema from the path parameters captured for the current matched

Callers

nothing calls this directly

Calls 2

getMethod · 0.65
parseFunction · 0.50

Tested by

no test coverage detected