치지직 앱으로 연동하고, 연동 확인된 ID만 접속할 수 있도록 수정, 개발용으로는 채널ID를 수동으로 접속할 수 있도록 변경.

최초 추천 고정 배치 추가.
This commit is contained in:
kimyu
2026-09-18 04:09:31 +09:00
parent 6f72824598
commit 73520f9f06
26 changed files with 1272 additions and 162 deletions

View File

@@ -0,0 +1,31 @@
import { NextResponse } from 'next/server';
import { assertChannelRoomAccess } from '@/lib/auth/room-access';
import { addDice, getRoom, notifyRoom, toPublicRoom } from '@/lib/rooms/store';
export const runtime = 'nodejs';
type Params = { params: Promise<{ roomId: string }> };
export async function POST(request: Request, { params }: Params) {
const { roomId } = await params;
const room = getRoom(roomId);
if (!room) {
return NextResponse.json({ error: '방을 찾을 수 없습니다.' }, { status: 404 });
}
const access = await assertChannelRoomAccess(room, request);
if (!access.ok) return access.response;
const body = (await request.json().catch(() => ({}))) as { count?: number };
const count = Number(body.count ?? 1);
if (!Number.isFinite(count) || count < 1) {
return NextResponse.json({ error: 'count는 1 이상이어야 합니다.' }, { status: 400 });
}
const updated = addDice(roomId, count);
if (!updated) {
return NextResponse.json({ error: '처리 실패' }, { status: 500 });
}
notifyRoom(roomId);
return NextResponse.json({ room: toPublicRoom(updated) });
}