Extracting Route Handler Logic in TypeScript

Is there any way to extract the route handler logic into a separate function/module without losing type information?

// api endpoint
export const ListDebatesV3 = Api.get("ListDebatesV3", "/disputes").pipe(
  Api.setResponseBody(Response),
);

// api
const api = pipe(
  Api.make({ title: "Users API" }),
  Api.addEndpoint(ListDebatesV3),
);

// app (including route handler)
const app = pipe(
  RouterBuilder.make(api),
  RouterBuilder.handle("ListDebatesV3", (_) =>
    // how can i extract this?
    Effect.gen(function* () {
      return [
        { username: "Alice", id: 1 },
        { username: "Bob", id: 2 },
      ];
    }),
  ),
Was this page helpful?