Integrating Effects with Async Functions in Zero Setup

Bit of a weird one here:
So I'm currently in the process of setting up Zero, that means I have to setup an endpoint in my server, which is effect, that acts as the recepients of push from external, that looks like this (hono example from the docs)
app.post('/push', async c => {
  const result = await processor.process(
    createMutators(),
    c.req.raw,
  );
  return await c.json(result);
});


Now this isn't the particular problem here, I would just wrap this in Effect.tryPromise I asume.

The problem is the createMutators which looks like this:
export function createMutators() {
  return {
    issue: {
      update: async (tx, {id, title}: {id: string; title: string}) => {
        // Validate title length. Legacy issues are exempt.
        if (title.length > 100) {
          throw new Error(`Title is too long`);
        }
        await tx.mutate.issue.update({id, title});
      },
    },
  } as const satisfies CustomMutatorDefs<typeof schema>;
}


Now these are the functions that are called by the processor.
I would like these to be effects aswell so i can access my services in stuff here.

However the processor calls async functions instead of effects.
So my idea was to create a managed runtime so in create mutators it would be:
export function createMutators() {
  return {
    issue: {
      update: runtime.runPromise(someEffect)
  } as const satisfies CustomMutatorDefs<typeof schema>;
}


I was wondering if 1. there is a better solution to this, 2. if there are problems with this, because this is then a runtime within the runtime? which seems like something that should be avoided
Was this page helpful?