Issue with `HttpLayerRouter.add` Not Propagating Effect's Type Properly

I think there is an issue with the new HttpLayerRouter.add method where it does not properly propagate the Effect's type up.
I have the following code:
const AuthRoute = HttpLayerRouter.add(
  '*',
  '/auth',
  Effect.gen(function* () {
    const request = yield* HttpServerRequest.HttpServerRequest
    const auth = yield* BetterAuth
    const response = yield* Effect.tryPromise({
      try: () => auth.handler(BunHttpServerRequest.toRequest(request)),
      catch: (error) => new BetterAuthError({ cause: error }),
    })

    return HttpServerResponse.raw(response)
  })
).pipe(Layer.provide(BetterAuth.Default()))


The key part here is the BetterAuth service that I am injecting. Now if I look at the type of AuthRoute, its the following: const AuthRoute: Layer.Layer<never, never, PgDatabase | HttpLayerRouter.HttpRouter | HttpLayerRouter.Type<"Requires", BetterAuth> | HttpLayerRouter.Type<...>>. As one can see both the dependency BetterAuth aswell as the BetterAuthError are not tracked in the respective channels of the Effect but are wrapped inside HttpLayerRouter.Type and within the dependency channel. This makes it so I can't provide a Layer and not use the endpoint.
Was this page helpful?