MCPcopy
hub / github.com/msgbyte/tianji / checkCredit

Function checkCredit

src/server/model/billing/credit.ts:73–92  ·  view source on GitHub ↗
(workspaceId: string)

Source from the content-addressed store, hash-verified

71}
72
73export async function checkCredit(workspaceId: string) {
74 const res = await prisma.workspace.findFirst({
75 where: {
76 id: workspaceId,
77 },
78 select: {
79 credit: true,
80 },
81 });
82
83 const credit = res?.credit ?? 0;
84 if (credit <= 0) {
85 const workspaceTier = await getWorkspaceTier(workspaceId);
86 if (workspaceTier === 'UNLIMITED') {
87 return;
88 }
89
90 throw new Error('Workspace not have enough credit');
91 }
92}
93
94export async function costCredit(
95 workspaceId: string,

Callers 2

requestOpenAIFunction · 0.85
ai.tsFile · 0.85

Calls 1

getWorkspaceTierFunction · 0.85

Tested by

no test coverage detected