first commit
CI / Type-check & Build (push) Failing after 5m50s
CI / Build & Push image (push) Skipped

This commit is contained in:
ysj7705 committed 2026-08-12 15:01:43 +09:00
commit 69b647145f
58 files changed
+15796

No files matched your search

+37
View File
@@ -0,0 +1,37 @@
import bcrypt from 'bcryptjs'
import { prisma } from '../../utils/db'
export default defineEventHandler(async (event) => {
const roomId = getRouterParam(event, 'roomId')
if (!roomId) {
throw createError({ statusCode: 400, statusMessage: 'Room id required' })
}
const body = await readBody<{ name?: string; password?: string }>(event)
const existing = await prisma.room.findUnique({ where: { id: roomId } })
if (!existing) {
throw createError({ statusCode: 404, statusMessage: 'Room not found' })
}
const data: { name?: string; passwordHash?: string; pwdVersion?: number } = {}
if (body?.name?.trim()) {
data.name = body.name.trim()
}
if (body?.password) {
if (body.password.length < 4) {
throw createError({ statusCode: 400, statusMessage: 'Password must be at least 4 characters' })
}
data.passwordHash = await bcrypt.hash(body.password, 10)
data.pwdVersion = existing.pwdVersion + 1
}
const room = await prisma.room.update({ where: { id: roomId }, data })
return {
id: room.id,
name: room.name,
pwdVersion: room.pwdVersion,
createdAt: room.createdAt.toISOString(),
createdBy: room.createdBy,
}
})