feat: add basic storage usage tracking

This commit is contained in:
2025-11-02 18:12:33 +00:00
parent d2c09f5d0f
commit 9b8367ade4
8 changed files with 129 additions and 22 deletions

View File

@@ -1,5 +1,7 @@
import type { MutationCtx, QueryCtx } from "@fileone/convex/server"
import type { Doc } from "../_generated/dataModel"
import { authComponent } from "../auth"
import { type AuthenticatedQueryCtx, authorizedGet } from "../functions"
import * as Err from "../shared/error"
export type AuthUser = Awaited<ReturnType<typeof authComponent.getAuthUser>>
@@ -23,3 +25,10 @@ export async function userOrThrow(ctx: QueryCtx | MutationCtx) {
const user = await authComponent.getAuthUser(ctx)
return user
}
export async function queryInfo(ctx: AuthenticatedQueryCtx) {
return await ctx.db
.query("userInfo")
.withIndex("byUserId", (q) => q.eq("userId", ctx.user._id))
.first()
}