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

Function withHandler

packages/platform/node/test/NodeHttpCompression.test.ts:29–44  ·  view source on GitHub ↗
(
  app: App,
  options: CompressionOptions,
  run: (handler: (request: Request) => Promise<Response>) => Promise<void>
)

Source from the content-addressed store, hash-verified

27type CompressionOptions = Parameters<typeof HttpMiddleware.compression>[0]
28
29const withHandler = async (
30 app: App,
31 options: CompressionOptions,
32 run: (handler: (request: Request) => Promise<Response>) => Promise<void>
33) => {
34 const { dispose, handler } = HttpEffect.toWebHandlerLayer(
35 app as Effect.Effect<HttpServerResponse.HttpServerResponse, never, HttpServerRequest>,
36 NodeHttpPlatform.layer,
37 { middleware: HttpMiddleware.compression(options) }
38 )
39 try {
40 await run(handler)
41 } finally {
42 await dispose()
43 }
44}
45
46const get = (
47 handler: (request: Request) => Promise<Response>,

Callers 1

Calls 2

runFunction · 0.50
disposeFunction · 0.50

Tested by

no test coverage detected