Adding service to runtime

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 to RuntimeServer.

Effect.Service provide a default Layer called Default.

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 using Layer.mergeAll (only Api.Default for now).

With this we can use RuntimeServer to execute effects that depend on Api.

RuntimeServer has type ManagedRuntime<Api>, where Api is the service included in the runtime.