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

Function layer

packages/effect/src/unstable/httpapi/HttpApiScalar.ts:209–226  ·  view source on GitHub ↗
(
  api: HttpApi.HttpApi<Id, Groups>,
  options?: {
    readonly path?: `/${string}` | undefined
    readonly scalar?: ScalarConfig
  } | undefined
)

Source from the content-addressed store, hash-verified

207 * @since 4.0.0
208 */
209export const layer = <Id extends string, Groups extends HttpApiGroup.Constraint>(
210 api: HttpApi.HttpApi<Id, Groups>,
211 options?: {
212 readonly path?: `/${string}` | undefined
213 readonly scalar?: ScalarConfig
214 } | undefined
215): Layer.Layer<never, never, HttpRouter.HttpRouter> =>
216 HttpRouter.use(Effect.fnUntraced(function*(router) {
217 const handler = makeHandler({
218 api,
219 source: {
220 _tag: "Inline",
221 source: internal.javascript
222 },
223 scalar: options?.scalar
224 })
225 yield* router.add("GET", options?.path ?? "/docs", handler)
226 }))
227
228/**
229 * Mounts a Scalar API reference page for an `HttpApi` that loads Scalar from jsDelivr.

Callers

nothing calls this directly

Calls 3

makeHandlerFunction · 0.70
useMethod · 0.65
addMethod · 0.65

Tested by

no test coverage detected