refactor: split request handle logic to controller

This commit is contained in:
d-kimsuon
2025-10-17 23:46:38 +09:00
parent c745824dbe
commit 1bd122daa0
22 changed files with 1308 additions and 693 deletions

View File

@@ -0,0 +1,41 @@
import { Context, Data, Effect, Layer } from "effect";
import type { InferEffect } from "../../../lib/effect/types";
import { ProjectRepository } from "../../project/infrastructure/ProjectRepository";
import { parseMcpListOutput } from "../functions/parseMcpListOutput";
import * as ClaudeCode from "../models/ClaudeCode";
class ProjectPathNotFoundError extends Data.TaggedError(
"ProjectPathNotFoundError",
)<{
projectId: string;
}> {}
const LayerImpl = Effect.gen(function* () {
const projectRepository = yield* ProjectRepository;
const getMcpList = (projectId: string) =>
Effect.gen(function* () {
const { project } = yield* projectRepository.getProject(projectId);
if (project.meta.projectPath === null) {
return yield* Effect.fail(new ProjectPathNotFoundError({ projectId }));
}
const output = yield* ClaudeCode.getMcpListOutput(
project.meta.projectPath,
);
return parseMcpListOutput(output);
});
return {
getMcpList,
};
});
export type IClaudeCodeService = InferEffect<typeof LayerImpl>;
export class ClaudeCodeService extends Context.Tag("ClaudeCodeService")<
ClaudeCodeService,
IClaudeCodeService
>() {
static Live = Layer.effect(this, LayerImpl);
}