We can now provide the Api service to RuntimeServer.
The
Apiservice is server-only. It can't be used on the client. Therefore, we provide it only toRuntimeServer.
Effect.Serviceprovide a defaultLayercalledDefault.
We simply need to provide Api.Default inside MainLayer of RuntimeServer:
src/services/RuntimeServer.ts
import { Layer, ManagedRuntime } from "effect";
import { Api } from "./Api";
const MainLayer = Layer.mergeAll(Api.Default);
export const RuntimeServer = ManagedRuntime.make(MainLayer);
MainLayermerges all the layers available in the runtime usingLayer.mergeAll(onlyApi.Defaultfor now).
With this we can use RuntimeServer to execute effects that depend on Api.
RuntimeServerhas typeManagedRuntime<Api>, whereApiis the service included in the runtime.
