fix(git): improve error reporting and resolve correct repo in GET endpoint

This commit is contained in:
2026-04-28 16:54:57 +05:00
parent 0c5b58e26b
commit 699e6bbe9f
2 changed files with 14 additions and 10 deletions
@@ -1,5 +1,6 @@
import { requireAuth } from '~/server/utils/auth'
import { resolveRepo, ensureRepo } from '~/server/utils/giteaApi'
import { resolveRepo } from '~/server/utils/giteaApi'
import { prisma } from '~/server/utils/prisma'
export default defineEventHandler(async (event) => {
const user = requireAuth(event)
@@ -9,9 +10,12 @@ export default defineEventHandler(async (event) => {
throw createError({ statusCode: 400, message: 'Canvas ID is required' })
}
// We need to resolve the repo. For now, assume it's a personal repo.
// In a real scenario, we'd check the DB to see if it's a group canvas.
const opts = { username: user.username }
const canvas = await prisma.canvas.findUnique({ where: { id: canvasId } })
const opts = canvas
? { username: user.username, groupId: canvas.groupId, isPublic: canvas.isPublic }
: { username: user.username }
const { owner, repo } = resolveRepo(opts)
const config = useRuntimeConfig()