github Effect-TS/effect @effect/platform@0.71.1

latest releases: @effect/typeclass@0.30.8, @effect/vitest@0.14.8, @effect/sql-sqlite-wasm@0.25.0...
4 days ago

Patch Changes

  • #4132 1d3df5b Thanks @tim-smart! - allow passing Context to HttpApp web handlers

    This allows you to pass request-scoped data to your handlers.

    import { Context, Effect } from "effect"
    import { HttpApp, HttpServerResponse } from "@effect/platform"
    
    class Env extends Context.Reference<Env>()("Env", {
      defaultValue: () => ({ foo: "bar" })
    }) {}
    
    const handler = HttpApp.toWebHandler(
      Effect.gen(function* () {
        const env = yield* Env
        return yield* HttpServerResponse.json(env)
      })
    )
    
    const response = await handler(
      new Request("http://localhost:3000/"),
      Env.context({ foo: "baz" })
    )
    
    assert.deepStrictEqual(await response.json(), {
      foo: "baz"
    })

Don't miss a new effect release

NewReleases is sending notifications on new releases.