.ts
TypeScript
(application/typescript)
// 1st-party
import type { ServiceMethodFactory } from "@ethicdevs/react-monolith";
import type { PipelineServiceDeps } from "./types";

const makeGetPipelineStageLogs: ServiceMethodFactory<
  PipelineServiceDeps,
  [string, string],
  Promise<string>
> = ({ request }) => {
  return async (pipelineId: string, stageId: string) => {
    const stage = await request.prisma.stage.findFirst({
      where: { id: stageId, pipelineId },
    });
    return stage?.logs ?? "";
  };
};

export default makeGetPipelineStageLogs;