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
.
Effect.Service
provide a defaultLayer
calledDefault
.
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);
MainLayer
merges all the layers available in the runtime usingLayer.mergeAll
(onlyApi.Default
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.