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