supported apps domain + some refactor of data types redundancy
This commit is contained in:
45
packages/logic/domains/supported-app/controller.ts
Normal file
45
packages/logic/domains/supported-app/controller.ts
Normal file
@@ -0,0 +1,45 @@
|
||||
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));
|
||||
}
|
||||
Reference in New Issue
Block a user