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

const makeListByRepoId: ServiceMethodFactory<
  PipelineServiceDeps,
  [string],
  Promise<Pipeline[]>
> = ({ request }) => {
  return async (repoId: string) => {
    return request.prisma.pipeline.findMany({
      where: { repoId },
      orderBy: { createdAt: "desc" },
    });
  };
};

export default makeListByRepoId;