In the previous chapter, we defined the GetProducts procedure and added it to the productRpcGroup. Next, we need to merge the productRpcGroup into a top-level group, which will serve as the single entry point for our entire application.
Create a new file at ecom/api.ts and add the following code:
import { RpcGroup } from "effect/unstable/rpc";import { productRpcGroup } from "./products/procedures.js";
export const ecomRpcGroup = RpcGroup.make().merge(productRpcGroup);We start by calling RpcGroup.make() with no arguments to create an empty group, and then use the .merge() method to combine productRpcGroup into it. As we add more domains throughout this course (such as the cart domain in an upcoming chapter), we’ll pass them as additional arguments to .merge().
So, what we have done until now is follow a three-tier structure to build out our API:
Procedures → Domain Groups → Root Group
We define individual procedures, organize them into domain-specific groups, and then merge those groups into a single root group that represents the full API surface.
The most important point to note is that everything we have written so far is just the contract, or the shape, of the API. We haven’t yet written the logic that runs when a procedure is invoked. We’ll do that in the next chapter.