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

const makeRmPipeline: ServiceMethodFactory<
  PipelineServiceDeps,
  [string, string],
  Promise<any>
> = ({ request, runner }) => {
  return async (pipelineId: string, reason: string) => {
    await runner.rmPipeline(pipelineId, reason);

    return request.prisma.pipeline.update({
      where: { id: pipelineId },
      data: { status: "CANCELED" as any },
    });
  };
};

export default makeRmPipeline;