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

Function withHandler

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

Source from the content-addressed store, hash-verified

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

Callers 1

Calls 2

runFunction · 0.50
disposeFunction · 0.50

Tested by

no test coverage detected