M1 웹 + 배포: 홈·코드 입장·대기실·오목 화면·결과·계정, E2E, Docker/Caddy
- 웹(React+Vite): 홈(큰 버튼 2개·하던 게임 돌아가기), 6자리 코드 입력(붙여넣기 감지·자동 입장), 링크 입장(닉네임 한 칸), 대기실(코드/링크 복사·공유·QR·자리·준비·방장 메뉴·설정), 오목(SVG 판·두 번 눌러 확정·금수/위험 표시·시계·무르기·무승부·기권·키보드 조작·스크린리더 안내), 결과(한 판 더 투표·방 전적·공정성 확인), 채팅·반응, 계정(닉네임 변경·글자 크기·테마·소리·진동) - WS 클라이언트: 지수 백오프+지터 재연결, 화면 복귀/온라인 즉시 재연결, seq 순서 처리, ping/pong 지연·시계 보정, 서버 재시작 안내, 다른 창 접속 처리 - @bg/shared/lite: 브라우저용 진입점(zod 제외) → 첫 화면 JS 약 90KB gzip - e2e/omok.e2e.ts: 브라우저 두 개(모바일·PC)로 방 만들기→링크 입장→대국→새로고침 복구→승리→한 판 더 - deploy: Dockerfile(운영 의존성만, 267MB), docker-compose(app+Caddy), Caddyfile(보안 헤더·CSP), .env.example - 프록시 뒤에서만 X-Forwarded-For 신뢰(TRUST_PROXY=1) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,4 +1,2 @@
|
||||
export * from './lite';
|
||||
export * from './protocol';
|
||||
export * from './nickname';
|
||||
export * from './room-code';
|
||||
export * from './catalog';
|
||||
|
||||
5
packages/shared/src/lite.ts
Normal file
5
packages/shared/src/lite.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
/** Browser-safe exports (no zod). */
|
||||
export * from './types';
|
||||
export * from './nickname';
|
||||
export * from './room-code';
|
||||
export * from './catalog';
|
||||
@@ -1,9 +1,8 @@
|
||||
/** WebSocket protocol, docs/03-realtime-protocol.md. */
|
||||
/** WebSocket protocol client→server schema (zod; server-side validation), docs/03-realtime-protocol.md. */
|
||||
import { z } from 'zod';
|
||||
import { CHAT_MAX } from './types';
|
||||
|
||||
export const PROTOCOL = 1;
|
||||
export const MAX_CLIENT_MESSAGE_BYTES = 16 * 1024;
|
||||
export const CHAT_MAX = 200;
|
||||
export * from './types';
|
||||
|
||||
const code = z.string().regex(/^\d{6}$/);
|
||||
const userId = z.string().min(1).max(64);
|
||||
@@ -32,86 +31,9 @@ export const ClientMessage = z.discriminatedUnion('t', [
|
||||
z.object({ t: z.literal('chat'), text: z.string().min(1).max(CHAT_MAX) }),
|
||||
z.object({ t: z.literal('emote'), id: z.string().max(20) }),
|
||||
z.object({ t: z.literal('rematch') }),
|
||||
z.object({ t: z.literal('void') }),
|
||||
z.object({ t: z.literal('sync') }),
|
||||
z.object({ t: z.literal('ping'), ts: z.number() }),
|
||||
]);
|
||||
export type ClientMessage = z.infer<typeof ClientMessage>;
|
||||
|
||||
export const EMOTES = ['thumbs', 'laugh', 'wow', 'sad', 'clap', 'nice', 'hurry', 'gg'] as const;
|
||||
export const EMOTE_LABEL: Record<(typeof EMOTES)[number], string> = {
|
||||
thumbs: '👍',
|
||||
laugh: '😂',
|
||||
wow: '😮',
|
||||
sad: '😢',
|
||||
clap: '👏',
|
||||
nice: '잘했어요!',
|
||||
hurry: '조금만 서둘러 주세요',
|
||||
gg: '좋은 게임이었어요',
|
||||
};
|
||||
|
||||
export interface PublicUser {
|
||||
id: string;
|
||||
nickname: string;
|
||||
avatar: string | null;
|
||||
kind: 'guest' | 'member';
|
||||
}
|
||||
|
||||
export interface SeatView {
|
||||
user: PublicUser;
|
||||
ready: boolean;
|
||||
connected: boolean;
|
||||
away: boolean;
|
||||
}
|
||||
|
||||
export type RoomStatus = 'lobby' | 'playing' | 'finished' | 'paused' | 'broken';
|
||||
|
||||
export interface RoomView {
|
||||
code: string;
|
||||
hostId: string;
|
||||
gameId: string;
|
||||
options: unknown;
|
||||
maxPlayers: number;
|
||||
minPlayers: number;
|
||||
visibility: 'private' | 'public';
|
||||
turnSeconds: number | null;
|
||||
allowSpectators: boolean;
|
||||
chatEnabled: boolean;
|
||||
chatFilter: boolean;
|
||||
seats: (SeatView | null)[];
|
||||
spectators: PublicUser[];
|
||||
status: RoomStatus;
|
||||
gameNo: number;
|
||||
rematchVotes: string[];
|
||||
sessionStats: Record<string, { played: number; wins: number }>;
|
||||
seedHash: string | null;
|
||||
/** Seed revealed after the game for fairness check. */
|
||||
lastSeed: string | null;
|
||||
}
|
||||
|
||||
export interface GameResultView {
|
||||
ranking: string[][];
|
||||
scores?: Record<string, number>;
|
||||
summary: string;
|
||||
reason: string;
|
||||
}
|
||||
|
||||
export type ServerMessage =
|
||||
| { t: 'welcome'; me: PublicUser; serverTime: number; protocol: number; activeRoom: string | null }
|
||||
| { t: 'room'; seq: number; room: RoomView }
|
||||
| {
|
||||
t: 'state';
|
||||
seq: number;
|
||||
view: unknown;
|
||||
events: unknown[];
|
||||
active: string[];
|
||||
deadline: number | null;
|
||||
cs?: number;
|
||||
}
|
||||
| { t: 'reject'; cs: number; reason: string }
|
||||
| { t: 'chat'; from: PublicUser | null; text: string; at: number; channel?: string }
|
||||
| { t: 'emote'; from: string; id: string }
|
||||
| { t: 'result'; seq: number; result: GameResultView }
|
||||
| { t: 'notice'; code: string; message: string }
|
||||
| { t: 'error'; code: string; message: string }
|
||||
| { t: 'pong'; ts: number; serverTime: number }
|
||||
| { t: 'bye'; reason: 'restart' | 'replaced' | 'kicked' | 'closed' };
|
||||
|
||||
83
packages/shared/src/types.ts
Normal file
83
packages/shared/src/types.ts
Normal file
@@ -0,0 +1,83 @@
|
||||
/** Protocol constants and message types shared by server and web (no runtime deps). */
|
||||
export const PROTOCOL = 1;
|
||||
export const MAX_CLIENT_MESSAGE_BYTES = 16 * 1024;
|
||||
export const CHAT_MAX = 200;
|
||||
|
||||
export const EMOTES = ['thumbs', 'laugh', 'wow', 'sad', 'clap', 'nice', 'hurry', 'gg'] as const;
|
||||
export const EMOTE_LABEL: Record<(typeof EMOTES)[number], string> = {
|
||||
thumbs: '👍',
|
||||
laugh: '😂',
|
||||
wow: '😮',
|
||||
sad: '😢',
|
||||
clap: '👏',
|
||||
nice: '잘했어요!',
|
||||
hurry: '조금만 서둘러 주세요',
|
||||
gg: '좋은 게임이었어요',
|
||||
};
|
||||
|
||||
export interface PublicUser {
|
||||
id: string;
|
||||
nickname: string;
|
||||
avatar: string | null;
|
||||
kind: 'guest' | 'member';
|
||||
}
|
||||
|
||||
export interface SeatView {
|
||||
user: PublicUser;
|
||||
ready: boolean;
|
||||
connected: boolean;
|
||||
away: boolean;
|
||||
}
|
||||
|
||||
export type RoomStatus = 'lobby' | 'playing' | 'finished' | 'paused' | 'broken';
|
||||
|
||||
export interface RoomView {
|
||||
code: string;
|
||||
hostId: string;
|
||||
gameId: string;
|
||||
options: unknown;
|
||||
maxPlayers: number;
|
||||
minPlayers: number;
|
||||
visibility: 'private' | 'public';
|
||||
turnSeconds: number | null;
|
||||
allowSpectators: boolean;
|
||||
chatEnabled: boolean;
|
||||
chatFilter: boolean;
|
||||
seats: (SeatView | null)[];
|
||||
spectators: PublicUser[];
|
||||
status: RoomStatus;
|
||||
gameNo: number;
|
||||
rematchVotes: string[];
|
||||
sessionStats: Record<string, { played: number; wins: number }>;
|
||||
seedHash: string | null;
|
||||
/** Seed revealed after the game for fairness check. */
|
||||
lastSeed: string | null;
|
||||
}
|
||||
|
||||
export interface GameResultView {
|
||||
ranking: string[][];
|
||||
scores?: Record<string, number>;
|
||||
summary: string;
|
||||
reason: string;
|
||||
}
|
||||
|
||||
export type ServerMessage =
|
||||
| { t: 'welcome'; me: PublicUser; serverTime: number; protocol: number; activeRoom: string | null }
|
||||
| { t: 'room'; seq: number; room: RoomView }
|
||||
| {
|
||||
t: 'state';
|
||||
seq: number;
|
||||
view: unknown;
|
||||
events: unknown[];
|
||||
active: string[];
|
||||
deadline: number | null;
|
||||
cs?: number;
|
||||
}
|
||||
| { t: 'reject'; cs: number; reason: string }
|
||||
| { t: 'chat'; from: PublicUser | null; text: string; at: number; channel?: string }
|
||||
| { t: 'emote'; from: string; id: string }
|
||||
| { t: 'result'; seq: number; result: GameResultView }
|
||||
| { t: 'notice'; code: string; message: string }
|
||||
| { t: 'error'; code: string; message: string }
|
||||
| { t: 'pong'; ts: number; serverTime: number }
|
||||
| { t: 'bye'; reason: 'restart' | 'replaced' | 'kicked' | 'closed' };
|
||||
Reference in New Issue
Block a user