Split shared RPC handler by domain
This commit is contained in:
16
packages/shared/src/rpc/modelRpc.ts
Normal file
16
packages/shared/src/rpc/modelRpc.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import type { Db } from "../db/database.js";
|
||||
import { getModel, updateModelCell } from "../db/queries.js";
|
||||
import { ok } from "./result.js";
|
||||
import type { RpcHandlers } from "./types.js";
|
||||
|
||||
export function modelHandlers(db: Db): RpcHandlers<"model.get" | "model.updateCell" | "model.runScenario"> {
|
||||
return {
|
||||
"model.get": ({ companyId, tab }) => ok("model.get", getModel(db, companyId, tab)),
|
||||
"model.updateCell": ({ companyId, tab, row, col, value }) =>
|
||||
ok("model.updateCell", updateModelCell(db, companyId, tab, row, col, value)),
|
||||
"model.runScenario": ({ companyId }) => {
|
||||
const model = getModel(db, companyId, "income");
|
||||
return ok("model.runScenario", model);
|
||||
},
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user