Files
docker-registry-aio/app/server/api/users/[id].delete.ts
T
ysj7705andCursor 0fd00bfa37 Add Docker Registry AIO with Nuxt Token Auth and admin UI.
Compose brings up registry:3 plus a Prisma/SQLite Nuxt app for docker login, ACL management, and image browsing with shadcn-vue.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-30 16:12:12 +09:00

26 lines
776 B
TypeScript

export default defineEventHandler(async (event) => {
const session = await requireAdmin(event)
await ensureBootstrap()
const id = getRouterParam(event, 'id')
if (!id) {
throw createError({ statusCode: 400, statusMessage: 'Missing id' })
}
if (session.id === id) {
throw createError({ statusCode: 400, statusMessage: 'Cannot delete yourself' })
}
const existing = await prisma.user.findUnique({ where: { id } })
if (!existing) {
throw createError({ statusCode: 404, statusMessage: 'User not found' })
}
if (existing.username === (process.env.ADMIN_USERNAME || 'admin')) {
throw createError({ statusCode: 400, statusMessage: 'Cannot delete bootstrap admin' })
}
await prisma.user.delete({ where: { id } })
return { ok: true }
})