import { HttpApiBuilder, HttpApiError } from "@effect/platform";
import { Effect } from "effect";
import { CashApi } from "../contracts/api";
import { RakeModelService } from "../services/rake-model";
HttpApiBuilder.group(CashApi, "CashRakeModel", (handlers) =>
Effect.gen(function* () {
const rakeModelService = yield* RakeModelService;
return handlers
.handle("createRakeModel", ({ payload }) =>
rakeModelService
.createRakeModel(payload)
.pipe(
Effect.catchTag(
"PrismaError",
() => new HttpApiError.InternalServerError()
)
)
)
.handle("getRakeModels", () =>
rakeModelService
.getRakeModels()
.pipe(
Effect.catchTag(
"PrismaError",
() => new HttpApiError.InternalServerError()
)
)
)
.handle("getRakeModel", ({ path }) =>
rakeModelService
.getRakeModel(path.id)
.pipe(
Effect.catchTag(
"PrismaError",
() => new HttpApiError.InternalServerError()
)
)
);
})
);
import { HttpApiBuilder, HttpApiError } from "@effect/platform";
import { Effect } from "effect";
import { CashApi } from "../contracts/api";
import { RakeModelService } from "../services/rake-model";
HttpApiBuilder.group(CashApi, "CashRakeModel", (handlers) =>
Effect.gen(function* () {
const rakeModelService = yield* RakeModelService;
return handlers
.handle("createRakeModel", ({ payload }) =>
rakeModelService
.createRakeModel(payload)
.pipe(
Effect.catchTag(
"PrismaError",
() => new HttpApiError.InternalServerError()
)
)
)
.handle("getRakeModels", () =>
rakeModelService
.getRakeModels()
.pipe(
Effect.catchTag(
"PrismaError",
() => new HttpApiError.InternalServerError()
)
)
)
.handle("getRakeModel", ({ path }) =>
rakeModelService
.getRakeModel(path.id)
.pipe(
Effect.catchTag(
"PrismaError",
() => new HttpApiError.InternalServerError()
)
)
);
})
);