Track HiveGrid Cloud planning reference
This commit is contained in:
1 parent
b3d5ea6764
commit
e341c5938a
5784 files changed
+1104929
-3
No files matched your search
@@ -0,0 +1,23 @@
|
||||
import { createCredit } from "../db/credits.db.server";
|
||||
import { CreditType, CreditTypes } from "../dtos/CreditType";
|
||||
import { createScopedLogger } from "~/utils/logger.server";
|
||||
|
||||
const creditsLogger = createScopedLogger("usage.credits");
|
||||
|
||||
async function create(data: { tenantId: string; userId: string | null; type: CreditType; objectId: string | null }) {
|
||||
const creditType = CreditTypes.find((t) => t.value === data.type);
|
||||
if (!creditType) {
|
||||
creditsLogger.error({ type: data.type }, `Credit type not found: ${data.type}`);
|
||||
return;
|
||||
}
|
||||
return await createCredit({
|
||||
tenantId: data.tenantId,
|
||||
userId: data.userId,
|
||||
type: data.type,
|
||||
objectId: data.objectId,
|
||||
amount: creditType.amount,
|
||||
});
|
||||
}
|
||||
export default {
|
||||
create,
|
||||
};
|
||||
Reference in new issue
Block a user