MCPcopy
hub / github.com/Effect-TS/effect / makeSecurityMiddleware

Function makeSecurityMiddleware

packages/platform/src/HttpApiBuilder.ts:736–758  ·  view source on GitHub ↗
(
  entry: {
    readonly tag: HttpApiMiddleware.TagClassSecurityAny
    readonly effect: Record<string, (_: any) => Effect.Effect<any, any>>
  }
)

Source from the content-addressed store, hash-verified

734)
735
736const makeSecurityMiddleware = (
737 entry: {
738 readonly tag: HttpApiMiddleware.TagClassSecurityAny
739 readonly effect: Record<string, (_: any) => Effect.Effect<any, any>>
740 }
741): Effect.Effect<any, any, any> => {
742 if (securityMiddlewareCache.has(entry)) {
743 return securityMiddlewareCache.get(entry)!
744 }
745
746 let effect: Effect.Effect<any, any, any> | undefined
747 for (const [key, security] of Object.entries(entry.tag.security)) {
748 const decode = securityDecode(security)
749 const handler = entry.effect[key]
750 const middleware = Effect.flatMap(decode, handler)
751 effect = effect === undefined ? middleware : Effect.catchAll(effect, () => middleware)
752 }
753 if (effect === undefined) {
754 effect = Effect.void
755 }
756 securityMiddlewareCache.set(entry, effect)
757 return effect
758}
759
760const responseSchema = Schema.declare(HttpServerResponse.isServerResponse)
761

Callers 1

applyMiddlewareFunction · 0.85

Calls 4

securityDecodeFunction · 0.85
entriesMethod · 0.80
getMethod · 0.65
setMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…