Typing a Request Handler Using Endpoint Definition in Effect Typescript

Hi! How can I type a request handler using the type of the endpoint definition? (or just type it conveniently and safely in any way.) I don't want to inline the handlers into the router definition.
// Definition
const createFlagEndpoint = HttpApiEndpoint.post("create-flag")`/`
    .setPayload(FlagPayload)
    .addSuccess(Flag);
const flagsGroup = HttpApiGroup.make("flags").add(createFlagEndpoint);
export const Api = HttpApi.make("Api").add(flagsGroup);

// Implementation
const FlagsLive = HttpApiBuilder.group(Api, "flags", (h) => h.handle("create-flag", createFlag));
export const ApiLive = HttpApiBuilder.api(Api).pipe(Layer.provide(FlagsLive));

// Handlers
const createFlag: (??? something something typeof createFlagEndpoint...?) = function ({ payload, request }) { ... }
Was this page helpful?