46 lines
1.2 KiB
TypeScript
46 lines
1.2 KiB
TypeScript
import { db } from "@pkg/db";
|
|
import { type Err } from "@pkg/result";
|
|
import { FlowExecCtx } from "@core/flow.execution.context";
|
|
import { ResultAsync } from "neverthrow";
|
|
import {
|
|
CreateSupportedApp,
|
|
SupportedApp,
|
|
UpdateSupportedApp,
|
|
} from "./data";
|
|
import { SupportedAppRepository } from "./repository";
|
|
|
|
export class SupportedAppController {
|
|
constructor(private repo: SupportedAppRepository) {}
|
|
|
|
list(fctx: FlowExecCtx): ResultAsync<SupportedApp[], Err> {
|
|
return this.repo.list(fctx);
|
|
}
|
|
|
|
getById(fctx: FlowExecCtx, id: number): ResultAsync<SupportedApp, Err> {
|
|
return this.repo.getById(fctx, id);
|
|
}
|
|
|
|
create(
|
|
fctx: FlowExecCtx,
|
|
data: CreateSupportedApp,
|
|
): ResultAsync<SupportedApp, Err> {
|
|
return this.repo.create(fctx, data);
|
|
}
|
|
|
|
update(
|
|
fctx: FlowExecCtx,
|
|
id: number,
|
|
data: UpdateSupportedApp,
|
|
): ResultAsync<SupportedApp, Err> {
|
|
return this.repo.update(fctx, id, data);
|
|
}
|
|
|
|
delete(fctx: FlowExecCtx, id: number): ResultAsync<boolean, Err> {
|
|
return this.repo.delete(fctx, id);
|
|
}
|
|
}
|
|
|
|
export function getSupportedAppController(): SupportedAppController {
|
|
return new SupportedAppController(new SupportedAppRepository(db));
|
|
}
|