.ts
TypeScript
(application/typescript)
// 1st-party
import type { ReqHandler } from "@ethicdevs/react-monolith";
// app
import { AppRoute, AppRouteParams } from "../../routes.defs";
import { makePipelineService } from "../../services/pipelines";
import PipelinesView, {
  PipelinesViewProps,
} from "../../views/pipelines/PipelinesView";

const getPipelinesView: ReqHandler<
  AppRouteParams,
  AppRoute.REPOSITORY_PIPELINES
> = async (request, reply) => {
  const { orgSlug, repoSlug } = request.params;

  const pipelineService = makePipelineService({ request, runner: {} });
  const pipelines = await pipelineService.listByRepo(orgSlug, repoSlug);

  const reqHandler = reply.makeRequestHandler(request, reply);
  return reqHandler<PipelinesViewProps>(PipelinesView.name, {
    pipelines,
    orgSlug,
    repoSlug,
  });
};

export default getPipelinesView;