Compare commits

...

29 Commits

Author SHA1 Message Date
7de5e96c4c 릴리스: v0.1.44 공개 목록 검색과 즐겨찾기 페이지 추가 2026-03-27 10:35:16 +09:00
61fe758b7c 릴리스: v0.1.43 토스트와 즐겨찾기 추가 2026-03-27 10:23:29 +09:00
3bd9751621 릴리스: v0.1.42 관리자 티어표 관리 추가 2026-03-26 19:02:46 +09:00
b9aa714501 릴리스: v0.1.41 커스텀 아이템 승격 연결 수정 2026-03-26 18:49:31 +09:00
6ddc82b1c7 릴리스: v0.1.40 관리자 아이템 관리 UX 보강 2026-03-26 18:38:46 +09:00
94152f22b2 릴리스: v0.1.39 티어표 편집 헤더 레이아웃 정리 2026-03-26 18:24:18 +09:00
5d778e9c20 릴리스: v0.1.38 아이템 이름 수정과 티어표 썸네일 추가 2026-03-26 18:14:54 +09:00
f729b6fa82 릴리스: v0.1.37 운영 배포 설정과 로컬 변경 동기화 2026-03-26 17:53:32 +09:00
c413371935 릴리스: v0.1.36 제목 기본값과 브라우저 타이틀 조정 2026-03-26 17:44:44 +09:00
e0c2995518 릴리스: v0.1.35 NAS Git 배포 절차 정리 2026-03-26 17:33:47 +09:00
5c3877b5c1 릴리스: v0.1.34 파비콘과 관리자 기본 아이템 업로드 개선 2026-03-26 17:30:03 +09:00
3eceec64e7 릴리스: v0.1.27 UGREEN NAS 운영 배포 파일 추가 2026-03-26 15:25:28 +09:00
37b59c7ab6 릴리스: v0.1.26 아이콘 크기 단계 조절 추가 2026-03-26 15:19:33 +09:00
464819571b 릴리스: v0.1.25 export 보드 폭 추가 축소 2026-03-26 15:09:41 +09:00
b1d5355123 릴리스: v0.1.24 드래그 정렬과 export 크기 조정 2026-03-26 15:05:43 +09:00
c1575783f0 릴리스: v0.1.23 홈 게임 정렬과 관리자 순서 관리 추가 2026-03-26 14:59:50 +09:00
b58a641453 릴리스: v0.1.22 무제목 저장 규칙과 export 정보 보강 2026-03-26 14:50:43 +09:00
b3f9f8e4d0 릴리스: v0.1.21 저장 피드백과 썸네일 fallback 정리 2026-03-26 14:39:34 +09:00
2374cd9272 릴리스: v0.1.20 게임 카드 3열 레이아웃 정리 2026-03-19 18:25:02 +09:00
d4ab4b2cd1 릴리스: v0.1.19 티어표 저장 UI와 작성자 표시 정리 2026-03-19 18:17:53 +09:00
7bc1af268f 릴리스: v0.1.18 미사용 아이템 필터 동작 수정 2026-03-19 17:58:41 +09:00
8af2726574 릴리스: v0.1.17 티어표 삭제와 미사용 이미지 정리 추가 2026-03-19 17:52:09 +09:00
85ee6e3649 릴리스: v0.1.16 티어표 편집 화면 마감 정리 2026-03-19 17:44:21 +09:00
a1afa658c2 릴리스: v0.1.15 다운로드와 반응형 UI 보정 2026-03-19 17:35:38 +09:00
b97d7eacda 릴리스: v0.1.13 관리자 탭과 가변 티어 행 추가 2026-03-19 16:58:17 +09:00
f6a031cfe4 릴리스: v0.1.12 작성 권한과 회원 관리 보강 2026-03-19 16:44:50 +09:00
c71a19873d 릴리스: v0.1.11 관리자 레이아웃과 자유 티어표 흐름 정리 2026-03-19 16:20:06 +09:00
f9ae036890 릴리스: v0.1.10 관리자 업로드 UX 정리 2026-03-19 15:42:12 +09:00
beaec9326b 릴리스: v0.1.9 MariaDB 전용 코드베이스 정리 2026-03-19 15:20:13 +09:00
43 changed files with 5247 additions and 1386 deletions

11
.dockerignore Normal file
View File

@@ -0,0 +1,11 @@
.git
.gitignore
.DS_Store
node_modules
frontend/node_modules
frontend/dist
backend/node_modules
backend/.sessions
backend/uploads
docker-compose.yml
docs

5
.env.production.example Normal file
View File

@@ -0,0 +1,5 @@
MARIADB_ROOT_PASSWORD=change-this-root-password
MARIADB_DATABASE=tier_cursor
MARIADB_USER=tier_cursor
MARIADB_PASSWORD=change-this-db-password
SESSION_SECRET=change-this-session-secret

View File

@@ -37,14 +37,19 @@ VITE_API_ORIGIN=http://localhost:5179 npm run dev
- 접속: `http://localhost:5173`
### 4) 기존 lowdb 데이터 이관
자세한 내용은 [docs/local-mariadb.md](/Users/bicute/Desktop/zenn.dev/tier-cursor/docs/local-mariadb.md)를 참고하세요.
## UGREEN NAS 운영 배포
운영용은 `MariaDB + backend + frontend` 3컨테이너 구조를 권장합니다.
```bash
cd backend
npm run migrate:lowdb
cp .env.production.example .env.production
docker compose --env-file .env.production -f docker-compose.prod.yml up -d --build
```
자세한 내용은 [docs/local-mariadb.md](/Users/bicute/Desktop/zenn.dev/tier-cursor/docs/local-mariadb.md)를 참고하세요.
- 프로덕션 컴포즈: [docker-compose.prod.yml](/Users/bicute/Desktop/zenn.dev/tier-cursor/docker-compose.prod.yml)
- 배포 가이드: [docs/ugreen-nas-deploy.md](/Users/bicute/Desktop/zenn.dev/tier-cursor/docs/ugreen-nas-deploy.md)
## 사용 흐름(현재 구현)

View File

@@ -4,6 +4,12 @@
- 모든 대화와 문서는 **한국어**로 작성한다.
- 코드 내 주석은 반드시 **JSDoc 형식**을 사용한다.
## 🧾 Git 및 버전 관리 규칙
- Git 작성자 정보는 프로젝트 기준 계정으로 통일한다.
- Git 커밋 메시지는 반드시 **한국어**로 작성한다.
- 버전이 올라가는 작업은 `docs/update.md`에 먼저 반영하고, 같은 버전명을 Git 태그에도 맞춘다.
- 원격 저장소에 푸시하기 전, 민감 정보(실명, 개인 이메일, 비밀키, 로컬 경로)가 포함되지 않았는지 확인한다.
## 📂 문서 자동 관리 규칙
모든 작업 수행 후, AI는 관련 내용을 아래 지정된 파일에 즉시 반영해야 한다.
@@ -28,4 +34,4 @@
## ⚠️ 실행 지침
- 새로운 코드를 작성하거나 수정하기 전, 반드시 `docs/` 내 관련 문서들을 먼저 참조한다.
- 작업 완료 후 위 문서들의 업데이트가 누락되지 않도록 확인한다.
- 작업 완료 후 위 문서들의 업데이트가 누락되지 않도록 확인한다.

15
backend/Dockerfile Normal file
View File

@@ -0,0 +1,15 @@
FROM node:20-alpine
WORKDIR /app
COPY backend/package*.json ./
RUN npm ci --omit=dev
COPY backend/ ./
ENV NODE_ENV=production
ENV PORT=5179
EXPOSE 5179
CMD ["node", "index.js"]

View File

@@ -1,341 +0,0 @@
{
"users": [
{
"id": "nsTJTtyrDHSqfmRu5glSN",
"email": "zenn.message@gmail.com",
"passwordHash": "$2b$10$DxSEaZctF5u8A5rYDQRZOu4rkRNEaCytX0m0raQn6Fwjx.G0h9k8K",
"isAdmin": true,
"createdAt": 1773887700454,
"avatarSrc": "/uploads/avatars/1773889900538-fef80900076ae-스크린샷 2026-03-19 오전 11.38.05.png"
}
],
"games": [
{
"id": "example-game",
"name": "예시 게임",
"createdAt": 1773887395598
},
{
"id": "another-game",
"name": "다른 예시 게임",
"createdAt": 1773887395598
},
{
"id": "stellasora",
"name": "스텔라소라",
"createdAt": 1773887727309,
"thumbnailSrc": "/uploads/games/1773890252955-fbdff9a881edf-스크린샷 2026-03-19 오전 11.23.48(2).png"
}
],
"gameImages": [
{
"id": "img-1",
"gameId": "example-game",
"src": "/uploads/seeds/example1.png",
"label": "샘플 1",
"createdAt": 1773887395598
},
{
"id": "img-2",
"gameId": "example-game",
"src": "/uploads/seeds/example2.png",
"label": "샘플 2",
"createdAt": 1773887395598
},
{
"id": "dVx9t49q3CbKe_dnY9Zit",
"gameId": "stellasora",
"src": "/uploads/games/1773887834722-a3ce962de80228-Chitose-head-xxl.webp",
"label": "치토세",
"createdAt": 1773887834727
},
{
"id": "Tf3MgX_4Pk4YZszOTfGEQ",
"gameId": "stellasora",
"src": "/uploads/games/1773887843354-3dd04644093c5-Freesia-head-xxl.webp",
"label": "프리지아",
"createdAt": 1773887843356
},
{
"id": "ceaMtFXf7Jq-83f66T-UM",
"gameId": "stellasora",
"src": "/uploads/games/1773887854172-ea9752e9139b-Donna-head-xxl.webp",
"label": "도나",
"createdAt": 1773887854174
},
{
"id": "2odX6CHJOyFroPZ8s57oe",
"gameId": "stellasora",
"src": "/uploads/games/1773887863903-3635cbc2e569e8-Fuyuka-head-xxl.webp",
"label": "후유카",
"createdAt": 1773887863905
},
{
"id": "OfDKYixqM12e57ZAAcGlW",
"gameId": "stellasora",
"src": "/uploads/games/1773887879061-801daab97ebb98-Snowish_Laru-head-xxl.webp",
"label": "라루(크리스마스)",
"createdAt": 1773887879064
},
{
"id": "P1BOwa2sMv_YbAOkhMPVS",
"gameId": "stellasora",
"src": "/uploads/games/1773890202889-54aedfa2cea6e-스크린샷 2026-03-16 오후 6.35.30.png",
"label": "기본이미지?",
"createdAt": 1773890202906
}
],
"tierLists": [
{
"id": "PiAKeKNvjJb68IPYiUv-r",
"authorId": "nsTJTtyrDHSqfmRu5glSN",
"gameId": "stellasora",
"title": "새 티어표1",
"isPublic": false,
"groups": [
{
"id": "gS",
"name": "S",
"itemIds": [
"dVx9t49q3CbKe_dnY9Zit"
]
},
{
"id": "gA",
"name": "A",
"itemIds": [
"ceaMtFXf7Jq-83f66T-UM"
]
},
{
"id": "gB",
"name": "B",
"itemIds": [
"2odX6CHJOyFroPZ8s57oe",
"OfDKYixqM12e57ZAAcGlW"
]
},
{
"id": "gC",
"name": "C",
"itemIds": [
"Tf3MgX_4Pk4YZszOTfGEQ"
]
},
{
"id": "gD",
"name": "D",
"itemIds": []
}
],
"pool": [
{
"id": "dVx9t49q3CbKe_dnY9Zit",
"src": "http://localhost:5179/uploads/games/1773887834722-a3ce962de80228-Chitose-head-xxl.webp",
"label": "치토세",
"origin": "game"
},
{
"id": "Tf3MgX_4Pk4YZszOTfGEQ",
"src": "http://localhost:5179/uploads/games/1773887843354-3dd04644093c5-Freesia-head-xxl.webp",
"label": "프리지아",
"origin": "game"
},
{
"id": "ceaMtFXf7Jq-83f66T-UM",
"src": "http://localhost:5179/uploads/games/1773887854172-ea9752e9139b-Donna-head-xxl.webp",
"label": "도나",
"origin": "game"
},
{
"id": "2odX6CHJOyFroPZ8s57oe",
"src": "http://localhost:5179/uploads/games/1773887863903-3635cbc2e569e8-Fuyuka-head-xxl.webp",
"label": "후유카",
"origin": "game"
},
{
"id": "OfDKYixqM12e57ZAAcGlW",
"src": "http://localhost:5179/uploads/games/1773887879061-801daab97ebb98-Snowish_Laru-head-xxl.webp",
"label": "라루(크리스마스)",
"origin": "game"
}
],
"createdAt": 1773888446012,
"updatedAt": 1773888446013
},
{
"id": "F1qD3tWgW1aPJkLPjeWWA",
"authorId": "nsTJTtyrDHSqfmRu5glSN",
"gameId": "stellasora",
"title": "새 티어표1",
"isPublic": true,
"groups": [
{
"id": "gS",
"name": "S",
"itemIds": [
"dVx9t49q3CbKe_dnY9Zit"
]
},
{
"id": "gA",
"name": "A",
"itemIds": [
"ceaMtFXf7Jq-83f66T-UM"
]
},
{
"id": "gB",
"name": "B",
"itemIds": [
"2odX6CHJOyFroPZ8s57oe",
"OfDKYixqM12e57ZAAcGlW"
]
},
{
"id": "gC",
"name": "C",
"itemIds": [
"Tf3MgX_4Pk4YZszOTfGEQ"
]
},
{
"id": "gD",
"name": "D",
"itemIds": [
"c-1773888464832-e963464a5f73e8"
]
}
],
"pool": [
{
"id": "dVx9t49q3CbKe_dnY9Zit",
"src": "http://localhost:5179/uploads/games/1773887834722-a3ce962de80228-Chitose-head-xxl.webp",
"label": "치토세",
"origin": "game"
},
{
"id": "Tf3MgX_4Pk4YZszOTfGEQ",
"src": "http://localhost:5179/uploads/games/1773887843354-3dd04644093c5-Freesia-head-xxl.webp",
"label": "프리지아",
"origin": "game"
},
{
"id": "ceaMtFXf7Jq-83f66T-UM",
"src": "http://localhost:5179/uploads/games/1773887854172-ea9752e9139b-Donna-head-xxl.webp",
"label": "도나",
"origin": "game"
},
{
"id": "2odX6CHJOyFroPZ8s57oe",
"src": "http://localhost:5179/uploads/games/1773887863903-3635cbc2e569e8-Fuyuka-head-xxl.webp",
"label": "후유카",
"origin": "game"
},
{
"id": "OfDKYixqM12e57ZAAcGlW",
"src": "http://localhost:5179/uploads/games/1773887879061-801daab97ebb98-Snowish_Laru-head-xxl.webp",
"label": "라루(크리스마스)",
"origin": "game"
},
{
"id": "c-1773888464832-e963464a5f73e8",
"src": "blob:http://localhost:5174/10e01324-bbc9-403f-bfe4-0dd7e47eace7",
"label": "Chixia-head-xxl.webp",
"origin": "custom"
}
],
"createdAt": 1773888448774,
"updatedAt": 1773890284754,
"description": ""
},
{
"id": "zq8qdUD6q541v5l6X0wAg",
"authorId": "nsTJTtyrDHSqfmRu5glSN",
"gameId": "stellasora",
"title": "스텔라소라 개쩜",
"description": "설명 이렇게 적어봄 이건 개쩌는 티어표임",
"isPublic": true,
"groups": [
{
"id": "gS",
"name": "S",
"itemIds": [
"dVx9t49q3CbKe_dnY9Zit",
"ceaMtFXf7Jq-83f66T-UM"
]
},
{
"id": "gA",
"name": "A",
"itemIds": [
"Tf3MgX_4Pk4YZszOTfGEQ"
]
},
{
"id": "gC",
"name": "C",
"itemIds": [
"OfDKYixqM12e57ZAAcGlW"
]
},
{
"id": "gB",
"name": "B",
"itemIds": [
"2odX6CHJOyFroPZ8s57oe"
]
},
{
"id": "gD",
"name": "쓰레기",
"itemIds": [
"P1BOwa2sMv_YbAOkhMPVS"
]
}
],
"pool": [
{
"id": "dVx9t49q3CbKe_dnY9Zit",
"src": "http://localhost:5179/uploads/games/1773887834722-a3ce962de80228-Chitose-head-xxl.webp",
"label": "치토세",
"origin": "game"
},
{
"id": "Tf3MgX_4Pk4YZszOTfGEQ",
"src": "http://localhost:5179/uploads/games/1773887843354-3dd04644093c5-Freesia-head-xxl.webp",
"label": "프리지아",
"origin": "game"
},
{
"id": "ceaMtFXf7Jq-83f66T-UM",
"src": "http://localhost:5179/uploads/games/1773887854172-ea9752e9139b-Donna-head-xxl.webp",
"label": "도나",
"origin": "game"
},
{
"id": "2odX6CHJOyFroPZ8s57oe",
"src": "http://localhost:5179/uploads/games/1773887863903-3635cbc2e569e8-Fuyuka-head-xxl.webp",
"label": "후유카",
"origin": "game"
},
{
"id": "OfDKYixqM12e57ZAAcGlW",
"src": "http://localhost:5179/uploads/games/1773887879061-801daab97ebb98-Snowish_Laru-head-xxl.webp",
"label": "라루(크리스마스)",
"origin": "game"
},
{
"id": "P1BOwa2sMv_YbAOkhMPVS",
"src": "http://localhost:5179/uploads/games/1773890202889-54aedfa2cea6e-스크린샷 2026-03-16 오후 6.35.30.png",
"label": "기본이미지?",
"origin": "game"
}
],
"createdAt": 1773890445513,
"updatedAt": 1773890445513
}
],
"customItems": [],
"gameSuggestions": []
}

View File

@@ -24,7 +24,7 @@ const allowedOrigins = (process.env.CORS_ORIGINS || '')
const FileStore = FileStoreFactory(session)
;['uploads/avatars', 'uploads/games', 'uploads/custom', '.sessions'].forEach((relativePath) => {
;['uploads/avatars', 'uploads/games', 'uploads/custom', 'uploads/tierlists', '.sessions'].forEach((relativePath) => {
fs.mkdirSync(path.join(__dirname, relativePath), { recursive: true })
})
@@ -53,6 +53,7 @@ app.use(
retries: 0,
}),
secret: SESSION_SECRET,
proxy: TRUST_PROXY > 0,
resave: false,
saveUninitialized: false,
cookie: {

View File

@@ -13,7 +13,6 @@
"cors": "^2.8.6",
"express": "^5.2.1",
"express-session": "^1.19.0",
"lowdb": "^7.0.1",
"multer": "^2.1.1",
"mysql2": "^3.20.0",
"nanoid": "^5.1.7",
@@ -889,21 +888,6 @@
"integrity": "sha512-mNAgZ1GmyNhD7AuqnTG3/VQ26o760+ZYBPKjPvugO8+nLbYfX6TVpJPseBvopbdY+qpZ/lKUnmEc1LeZYS3QAA==",
"license": "Apache-2.0"
},
"node_modules/lowdb": {
"version": "7.0.1",
"resolved": "https://registry.npmjs.org/lowdb/-/lowdb-7.0.1.tgz",
"integrity": "sha512-neJAj8GwF0e8EpycYIDFqEPcx9Qz4GUho20jWFR7YiFeXzF1YMLdxB36PypcTSPMA+4+LvgyMacYhlr18Zlymw==",
"license": "MIT",
"dependencies": {
"steno": "^4.0.2"
},
"engines": {
"node": ">=18"
},
"funding": {
"url": "https://github.com/sponsors/typicode"
}
},
"node_modules/lru.min": {
"version": "1.1.4",
"resolved": "https://registry.npmjs.org/lru.min/-/lru.min-1.1.4.tgz",
@@ -1589,18 +1573,6 @@
"node": ">= 0.8"
}
},
"node_modules/steno": {
"version": "4.0.2",
"resolved": "https://registry.npmjs.org/steno/-/steno-4.0.2.tgz",
"integrity": "sha512-yhPIQXjrlt1xv7dyPQg2P17URmXbuM5pdGkpiMB3RenprfiBlvK415Lctfe0eshk90oA7/tNq7WEiMK8RSP39A==",
"license": "MIT",
"engines": {
"node": ">=18"
},
"funding": {
"url": "https://github.com/sponsors/typicode"
}
},
"node_modules/streamsearch": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/streamsearch/-/streamsearch-1.1.0.tgz",

View File

@@ -4,11 +4,8 @@
"description": "",
"main": "index.js",
"scripts": {
"dev": "DB_CLIENT=mariadb DB_HOST=127.0.0.1 DB_PORT=3307 DB_USER=tier_cursor DB_PASSWORD=tier_cursor1234 DB_NAME=tier_cursor nodemon --legacy-watch --watch index.js --watch src index.js",
"start": "DB_CLIENT=mariadb DB_HOST=127.0.0.1 DB_PORT=3307 DB_USER=tier_cursor DB_PASSWORD=tier_cursor1234 DB_NAME=tier_cursor node index.js",
"dev:lowdb": "nodemon --legacy-watch --watch index.js --watch src index.js",
"start:lowdb": "node index.js",
"migrate:lowdb": "DB_CLIENT=mariadb DB_HOST=127.0.0.1 DB_PORT=3307 DB_USER=tier_cursor DB_PASSWORD=tier_cursor1234 DB_NAME=tier_cursor node scripts/migrate-lowdb-to-mariadb.js"
"dev": "DB_HOST=127.0.0.1 DB_PORT=3307 DB_USER=tier_cursor DB_PASSWORD=tier_cursor1234 DB_NAME=tier_cursor nodemon --legacy-watch --watch index.js --watch src index.js",
"start": "DB_HOST=127.0.0.1 DB_PORT=3307 DB_USER=tier_cursor DB_PASSWORD=tier_cursor1234 DB_NAME=tier_cursor node index.js"
},
"keywords": [],
"author": "",
@@ -19,7 +16,6 @@
"cors": "^2.8.6",
"express": "^5.2.1",
"express-session": "^1.19.0",
"lowdb": "^7.0.1",
"multer": "^2.1.1",
"mysql2": "^3.20.0",
"nanoid": "^5.1.7",

View File

@@ -1,103 +0,0 @@
const fs = require('fs')
const path = require('path')
const {
ensureData,
findUserByEmail,
createUser,
findGameById,
createGame,
updateGameThumbnail,
createGameItem,
createCustomItem,
findTierListById,
saveTierList,
createGameSuggestion,
} = require('../src/db')
async function run() {
const sourcePath = path.join(__dirname, '..', 'data', 'db.json')
const raw = fs.readFileSync(sourcePath, 'utf8')
const data = JSON.parse(raw)
await ensureData()
for (const user of data.users || []) {
const existing = await findUserByEmail(user.email)
if (!existing) {
await createUser({
id: user.id,
email: user.email,
nickname: user.nickname || '',
passwordHash: user.passwordHash,
isAdmin: !!user.isAdmin,
})
}
}
for (const game of data.games || []) {
const existing = await findGameById(game.id)
if (!existing) {
await createGame({ id: game.id, name: game.name })
}
if (game.thumbnailSrc) {
await updateGameThumbnail(game.id, game.thumbnailSrc)
}
}
for (const item of data.gameImages || []) {
try {
await createGameItem({
id: item.id,
gameId: item.gameId,
src: item.src,
label: item.label,
})
} catch (e) {}
}
for (const suggestion of data.gameSuggestions || []) {
try {
await createGameSuggestion({ id: suggestion.id, name: suggestion.name })
} catch (e) {}
}
const seenCustomIds = new Set()
for (const tierList of data.tierLists || []) {
for (const item of tierList.pool || []) {
if (item.origin !== 'custom' || seenCustomIds.has(item.id)) continue
seenCustomIds.add(item.id)
try {
await createCustomItem({
id: item.id,
ownerId: tierList.authorId,
src: item.src,
label: item.label,
})
} catch (e) {}
}
}
for (const tierList of data.tierLists || []) {
const existing = await findTierListById(tierList.id)
if (!existing) {
await saveTierList({
id: tierList.id,
authorId: tierList.authorId,
gameId: tierList.gameId,
title: tierList.title,
description: tierList.description || '',
isPublic: !!tierList.isPublic,
groups: tierList.groups || [],
pool: tierList.pool || [],
})
}
}
console.log('migrate-lowdb-to-mariadb: done')
}
run().catch((error) => {
console.error(error)
process.exit(1)
})

File diff suppressed because it is too large Load Diff

View File

@@ -1,13 +1,32 @@
const fs = require('fs/promises')
const path = require('path')
const express = require('express')
const multer = require('multer')
const bcrypt = require('bcryptjs')
const { z } = require('zod')
const { nanoid } = require('nanoid')
const {
findUserById,
findGameById,
createGame,
listGames,
updateGameThumbnail,
createGameItem,
updateGameItemLabel,
deleteGameItem,
deleteGame,
updateGameDisplayOrder,
listCustomItems,
findCustomItemById,
findUnusedCustomItems,
findCustomItemsByIds,
deleteCustomItems,
listUsers,
listAdminTierLists,
findTierListById,
adminUpdateUser,
adminUpdateUserPassword,
adminDeleteUser,
} = require('../db')
const { requireAdmin } = require('../middleware/auth')
@@ -19,6 +38,18 @@ function buildUploadFilename(file) {
return `${Date.now()}-${nanoid()}${safeExt}`
}
function buildItemLabelFromFilename(file) {
const originalName = file?.originalname || ''
const base = path.basename(originalName, path.extname(originalName))
const normalized = base
.replace(/[_-]+/g, ' ')
.replace(/\s+/g, ' ')
.trim()
.slice(0, 60)
return normalized || 'item'
}
const upload = multer({
storage: multer.diskStorage({
destination: (req, file, cb) => cb(null, path.join(__dirname, '..', '..', 'uploads', 'games')),
@@ -37,6 +68,20 @@ router.post('/games', requireAdmin, async (req, res) => {
res.json({ game })
})
router.patch('/games/display-order', requireAdmin, async (req, res) => {
const schema = z.object({
gameIds: z.array(z.string().min(1)).max(50),
})
const parsed = schema.safeParse(req.body)
if (!parsed.success) return res.status(400).json({ error: 'bad_request' })
const games = await listGames()
const validGameIds = new Set(games.map((game) => game.id))
const filteredIds = parsed.data.gameIds.filter((gameId) => validGameIds.has(gameId))
const updatedGames = await updateGameDisplayOrder(filteredIds)
res.json({ games: updatedGames })
})
router.post('/games/:gameId/thumbnail', requireAdmin, upload.single('thumbnail'), async (req, res) => {
if (!req.file) return res.status(400).json({ error: 'file_required' })
const game = await findGameById(req.params.gameId)
@@ -45,20 +90,347 @@ router.post('/games/:gameId/thumbnail', requireAdmin, upload.single('thumbnail')
res.json({ game: updated })
})
router.post('/games/:gameId/images', requireAdmin, upload.single('image'), async (req, res) => {
if (!req.file) return res.status(400).json({ error: 'file_required' })
const schema = z.object({ label: z.string().min(1).max(60) })
const parsed = schema.safeParse(req.body)
if (!parsed.success) return res.status(400).json({ error: 'bad_request' })
router.post('/games/:gameId/images', requireAdmin, upload.array('images', 50), async (req, res) => {
const files = Array.isArray(req.files) ? req.files : []
if (!files.length) return res.status(400).json({ error: 'file_required' })
const game = await findGameById(req.params.gameId)
if (!game) return res.status(404).json({ error: 'not_found' })
const item = await createGameItem({
id: nanoid(),
gameId: game.id,
src: `/uploads/games/${req.file.filename}`,
label: parsed.data.label,
const manualLabel = typeof req.body?.label === 'string' ? req.body.label.trim() : ''
if (manualLabel && manualLabel.length > 60) return res.status(400).json({ error: 'bad_request' })
const items = await Promise.all(
files.map((file, index) =>
createGameItem({
id: nanoid(),
gameId: game.id,
src: `/uploads/games/${file.filename}`,
label: index === 0 && manualLabel ? manualLabel : buildItemLabelFromFilename(file),
})
)
)
res.json({ item: items[0], items })
})
router.delete('/games/:gameId/items/:itemId', requireAdmin, async (req, res) => {
const game = await findGameById(req.params.gameId)
if (!game) return res.status(404).json({ error: 'not_found' })
await deleteGameItem(req.params.itemId)
res.json({ ok: true })
})
router.patch('/games/:gameId/items/:itemId', requireAdmin, async (req, res) => {
const schema = z.object({ label: z.string().trim().min(1).max(60) })
const parsed = schema.safeParse(req.body)
if (!parsed.success) return res.status(400).json({ error: 'bad_request' })
const game = await findGameById(req.params.gameId)
if (!game) return res.status(404).json({ error: 'not_found' })
const updated = await updateGameItemLabel(req.params.itemId, parsed.data.label)
if (!updated || updated.gameId !== game.id) return res.status(404).json({ error: 'not_found' })
res.json({ item: updated })
})
router.delete('/games/:gameId', requireAdmin, async (req, res) => {
const game = await findGameById(req.params.gameId)
if (!game) return res.status(404).json({ error: 'not_found' })
await deleteGame(req.params.gameId)
res.json({ ok: true })
})
router.get('/custom-items', requireAdmin, async (req, res) => {
const schema = z.object({
q: z.string().trim().max(120).optional().default(''),
page: z.coerce.number().int().min(1).optional().default(1),
limit: z.coerce.number().int().min(1).max(200).optional().default(50),
orphanOnly: z
.union([z.literal('true'), z.literal('false'), z.boolean()])
.optional()
.default('false')
.transform((value) => value === true || value === 'true'),
})
const parsed = schema.safeParse(req.query)
if (!parsed.success) return res.status(400).json({ error: 'bad_request' })
const result = await listCustomItems({
queryText: parsed.data.q,
page: parsed.data.page,
limit: parsed.data.limit,
orphanOnly: parsed.data.orphanOnly,
})
res.json(result)
})
router.get('/tierlists', requireAdmin, async (req, res) => {
const schema = z.object({
q: z.string().trim().max(120).optional().default(''),
page: z.coerce.number().int().min(1).optional().default(1),
limit: z.coerce.number().int().min(1).max(200).optional().default(50),
})
const parsed = schema.safeParse(req.query)
if (!parsed.success) return res.status(400).json({ error: 'bad_request' })
const result = await listAdminTierLists({
queryText: parsed.data.q,
page: parsed.data.page,
limit: parsed.data.limit,
currentUserId: req.session?.userId || '',
})
res.json(result)
})
async function removeCustomItemFiles(items) {
await Promise.all(
items.map(async (item) => {
if (!item?.src || !item.src.startsWith('/uploads/custom/')) return
const absolutePath = path.join(__dirname, '..', '..', item.src.replace(/^\//, ''))
try {
await fs.unlink(absolutePath)
} catch (e) {
if (e?.code !== 'ENOENT') throw e
}
})
)
}
async function promoteCustomItemToGameItem({ customItem, gameId }) {
const originalName = path.basename(customItem.src || '')
const nextFilename = buildUploadFilename({ originalname: originalName })
const sourcePath = path.join(__dirname, '..', '..', customItem.src.replace(/^\//, ''))
const targetRelativePath = path.join('uploads', 'games', nextFilename)
const targetPath = path.join(__dirname, '..', '..', targetRelativePath)
await fs.copyFile(sourcePath, targetPath)
return createGameItem({
id: nanoid(),
gameId,
src: `/${targetRelativePath.replace(/\\/g, '/')}`,
label: customItem.label,
})
}
async function copyUploadIntoGameAsset(src) {
if (typeof src !== 'string' || !src.startsWith('/uploads/')) return src || ''
const originalName = path.basename(src)
const nextFilename = buildUploadFilename({ originalname: originalName })
const sourcePath = path.join(__dirname, '..', '..', src.replace(/^\//, ''))
const targetRelativePath = path.join('uploads', 'games', nextFilename)
const targetPath = path.join(__dirname, '..', '..', targetRelativePath)
await fs.copyFile(sourcePath, targetPath)
return `/${targetRelativePath.replace(/\\/g, '/')}`
}
function uniqueTierListPoolItems(tierList) {
const seen = new Set()
return (tierList?.pool || []).filter((item) => {
if (!item?.id || seen.has(item.id)) return false
seen.add(item.id)
return true
})
}
async function promoteTierListItemsToGame({ tierList, gameId, itemIds = [] }) {
const allowedIds = new Set((itemIds || []).filter(Boolean))
const sourceItems = uniqueTierListPoolItems(tierList).filter((item) => item.origin === 'custom')
const itemsToCopy = allowedIds.size ? sourceItems.filter((item) => allowedIds.has(item.id)) : sourceItems
const createdItems = []
for (const item of itemsToCopy) {
const copiedSrc = await copyUploadIntoGameAsset(item.src)
createdItems.push(
await createGameItem({
id: nanoid(),
gameId,
src: copiedSrc,
label: item.label,
})
)
}
return createdItems
}
async function createGameTemplateFromTierList({ tierList, gameId, gameName }) {
await createGame({ id: gameId, name: gameName })
if (tierList.thumbnailSrc) {
const copiedThumb = await copyUploadIntoGameAsset(tierList.thumbnailSrc)
await updateGameThumbnail(gameId, copiedThumb)
}
const createdItems = []
for (const item of uniqueTierListPoolItems(tierList)) {
const copiedSrc = await copyUploadIntoGameAsset(item.src)
createdItems.push(
await createGameItem({
id: nanoid(),
gameId,
src: copiedSrc,
label: item.label,
})
)
}
return { game: await findGameById(gameId), items: createdItems }
}
router.delete('/custom-items/:itemId', requireAdmin, async (req, res) => {
const result = await listCustomItems({ page: 1, limit: 200, orphanOnly: false })
const target = result.items.find((item) => item.id === req.params.itemId)
if (!target) return res.status(404).json({ error: 'not_found' })
if (target.usageCount > 0) return res.status(409).json({ error: 'item_in_use' })
const items = await findCustomItemsByIds([target.id])
await deleteCustomItems([target.id])
await removeCustomItemFiles(items)
res.json({ ok: true })
})
router.post('/custom-items/:itemId/promote', requireAdmin, async (req, res) => {
const schema = z.object({
gameId: z.string().min(1),
})
const parsed = schema.safeParse(req.body)
if (!parsed.success) return res.status(400).json({ error: 'bad_request' })
const game = await findGameById(parsed.data.gameId)
if (!game) return res.status(404).json({ error: 'game_not_found' })
const customItem = await findCustomItemById(req.params.itemId)
if (!customItem) return res.status(404).json({ error: 'not_found' })
const item = await promoteCustomItemToGameItem({ customItem, gameId: game.id })
res.json({ item })
})
router.post('/tierlists/:tierListId/promote-items', requireAdmin, async (req, res) => {
const schema = z.object({
gameId: z.string().min(1),
itemIds: z.array(z.string().min(1)).optional().default([]),
})
const parsed = schema.safeParse(req.body)
if (!parsed.success) return res.status(400).json({ error: 'bad_request' })
const game = await findGameById(parsed.data.gameId)
if (!game) return res.status(404).json({ error: 'game_not_found' })
const tierList = await findTierListById(req.params.tierListId)
if (!tierList) return res.status(404).json({ error: 'not_found' })
const items = await promoteTierListItemsToGame({
tierList,
gameId: game.id,
itemIds: parsed.data.itemIds,
})
res.json({ items })
})
router.post('/tierlists/:tierListId/create-game-template', requireAdmin, async (req, res) => {
const schema = z.object({
gameId: z.string().trim().min(1).max(120),
name: z.string().trim().min(1).max(120),
itemIds: z.array(z.string().min(1)).optional().default([]),
})
const parsed = schema.safeParse(req.body)
if (!parsed.success) return res.status(400).json({ error: 'bad_request' })
const exists = await findGameById(parsed.data.gameId)
if (exists) return res.status(409).json({ error: 'game_id_taken' })
const tierList = await findTierListById(req.params.tierListId)
if (!tierList) return res.status(404).json({ error: 'not_found' })
const result = await createGameTemplateFromTierList({
tierList: {
...tierList,
pool: parsed.data.itemIds.length ? (tierList.pool || []).filter((item) => parsed.data.itemIds.includes(item.id)) : tierList.pool,
},
gameId: parsed.data.gameId,
gameName: parsed.data.name,
})
res.json(result)
})
router.delete('/custom-items', requireAdmin, async (req, res) => {
const schema = z.object({
q: z.string().trim().max(120).optional().default(''),
})
const parsed = schema.safeParse(req.query)
if (!parsed.success) return res.status(400).json({ error: 'bad_request' })
const items = await findUnusedCustomItems({ queryText: parsed.data.q })
const ids = items.map((item) => item.id)
await deleteCustomItems(ids)
await removeCustomItemFiles(items)
res.json({ ok: true, deletedCount: ids.length })
})
router.get('/users', requireAdmin, async (req, res) => {
const users = await listUsers()
res.json({ users })
})
router.patch('/users/:userId', requireAdmin, async (req, res) => {
const schema = z.object({
email: z.string().email(),
nickname: z.string().trim().max(40).default(''),
isAdmin: z.boolean(),
})
const parsed = schema.safeParse(req.body)
if (!parsed.success) return res.status(400).json({ error: 'bad_request' })
if (req.params.userId === req.session.userId && !parsed.data.isAdmin) {
return res.status(400).json({ error: 'self_admin_required' })
}
const user = await findUserById(req.params.userId)
if (!user) return res.status(404).json({ error: 'not_found' })
try {
const updated = await adminUpdateUser({
id: user.id,
email: parsed.data.email,
nickname: parsed.data.nickname,
isAdmin: parsed.data.isAdmin,
})
res.json({ user: updated })
} catch (e) {
if (e && e.code === 'ER_DUP_ENTRY') {
return res.status(409).json({ error: 'email_taken' })
}
throw e
}
})
router.delete('/users/:userId', requireAdmin, async (req, res) => {
if (req.params.userId === req.session.userId) {
return res.status(400).json({ error: 'cannot_delete_self' })
}
const user = await findUserById(req.params.userId)
if (!user) return res.status(404).json({ error: 'not_found' })
await adminDeleteUser(user.id)
res.json({ ok: true })
})
router.patch('/users/:userId/password', requireAdmin, async (req, res) => {
const schema = z.object({
password: z.string().min(6).max(120),
})
const parsed = schema.safeParse(req.body)
if (!parsed.success) return res.status(400).json({ error: 'bad_request' })
const user = await findUserById(req.params.userId)
if (!user) return res.status(404).json({ error: 'not_found' })
const passwordHash = await bcrypt.hash(parsed.data.password, 10)
await adminUpdateUserPassword({ id: user.id, passwordHash })
res.json({ ok: true })
})
module.exports = router

View File

@@ -44,7 +44,11 @@ router.post('/signup', async (req, res) => {
req.session.userId = user.id
req.session.isAdmin = !!user.isAdmin
res.json(user)
// 세션을 응답 전에 명시적으로 저장해 Set-Cookie가 확실히 내려오도록 보강
req.session.save((err) => {
if (err) return res.status(500).json({ error: 'session_save_failed' })
res.json(user)
})
})
router.post('/login', async (req, res) => {
@@ -60,13 +64,16 @@ router.post('/login', async (req, res) => {
req.session.userId = user.id
req.session.isAdmin = !!user.isAdmin
res.json({
id: user.id,
email: user.email,
nickname: user.nickname || '',
isAdmin: !!user.isAdmin,
avatarSrc: user.avatarSrc || '',
createdAt: user.createdAt,
req.session.save((err) => {
if (err) return res.status(500).json({ error: 'session_save_failed' })
res.json({
id: user.id,
email: user.email,
nickname: user.nickname || '',
isAdmin: !!user.isAdmin,
avatarSrc: user.avatarSrc || '',
createdAt: user.createdAt,
})
})
})

View File

@@ -1,7 +1,5 @@
const express = require('express')
const { z } = require('zod')
const { nanoid } = require('nanoid')
const { listGames, getGameDetail, createGameSuggestion } = require('../db')
const { listGames, getGameDetail } = require('../db')
const router = express.Router()
@@ -16,16 +14,4 @@ router.get('/:gameId', async (req, res) => {
res.json({ game: detail.game, items: detail.items })
})
router.post('/suggest', async (req, res) => {
const schema = z.object({ name: z.string().min(1).max(60) })
const parsed = schema.safeParse(req.body)
if (!parsed.success) return res.status(400).json({ error: 'bad_request' })
const suggestion = await createGameSuggestion({
id: nanoid(),
name: parsed.data.name,
})
res.json({ suggestion })
})
module.exports = router

View File

@@ -6,9 +6,14 @@ const { nanoid } = require('nanoid')
const {
findTierListById,
listPublicTierLists,
listFavoriteTierLists,
listUserTierLists,
deleteTierList,
saveTierList,
createCustomItem,
findUserById,
favoriteTierList,
unfavoriteTierList,
} = require('../db')
const { requireAuth } = require('../middleware/auth')
@@ -51,10 +56,19 @@ const upload = multer({
limits: { fileSize: 6 * 1024 * 1024 },
})
const thumbnailUpload = multer({
storage: multer.diskStorage({
destination: (req, file, cb) => cb(null, path.join(__dirname, '..', '..', 'uploads', 'tierlists')),
filename: (req, file, cb) => cb(null, buildUploadFilename(file)),
}),
limits: { fileSize: 6 * 1024 * 1024 },
})
const tierListUpsertSchema = z.object({
id: z.string().optional(),
gameId: z.string().min(1),
title: z.string().min(1).max(120),
thumbnailSrc: z.string().max(255).optional().default(''),
description: z.string().max(1000).optional().default(''),
isPublic: z.boolean().default(false),
groups: z.array(
@@ -76,7 +90,8 @@ const tierListUpsertSchema = z.object({
router.get('/public', async (req, res) => {
const gameId = req.query.gameId
const lists = await listPublicTierLists(gameId)
const queryText = typeof req.query.q === 'string' ? req.query.q : ''
const lists = await listPublicTierLists(gameId, req.session?.userId || '', queryText)
res.json({ tierLists: lists })
})
@@ -85,15 +100,52 @@ router.get('/me', requireAuth, async (req, res) => {
res.json({ tierLists: lists })
})
router.get('/favorites/me', requireAuth, async (req, res) => {
const queryText = typeof req.query.q === 'string' ? req.query.q : ''
const sort = typeof req.query.sort === 'string' ? req.query.sort : 'favorited'
const lists = await listFavoriteTierLists(req.session.userId, { queryText, sort })
res.json({ tierLists: lists })
})
router.get('/:id', async (req, res) => {
const t = await findTierListById(req.params.id)
const t = await findTierListById(req.params.id, req.session?.userId || '')
if (!t) return res.status(404).json({ error: 'not_found' })
if (!t.isPublic) {
if (!req.session || req.session.userId !== t.authorId) return res.status(403).json({ error: 'forbidden' })
if (!req.session?.userId) return res.status(403).json({ error: 'forbidden' })
const currentUser = req.session.userId === t.authorId ? { isAdmin: false } : await findUserById(req.session.userId)
if (req.session.userId !== t.authorId && !currentUser?.isAdmin) return res.status(403).json({ error: 'forbidden' })
}
res.json({ tierList: normalizeTierList(t) })
})
router.delete('/:id', requireAuth, async (req, res) => {
const tierList = await findTierListById(req.params.id, req.session.userId)
if (!tierList) return res.status(404).json({ error: 'not_found' })
if (tierList.authorId !== req.session.userId) return res.status(403).json({ error: 'forbidden' })
await deleteTierList(tierList.id)
res.json({ ok: true })
})
router.post('/:id/favorite', requireAuth, async (req, res) => {
const tierList = await findTierListById(req.params.id, req.session.userId)
if (!tierList) return res.status(404).json({ error: 'not_found' })
if (!tierList.isPublic && tierList.authorId !== req.session.userId) return res.status(403).json({ error: 'forbidden' })
await favoriteTierList({ userId: req.session.userId, tierListId: tierList.id })
const updated = await findTierListById(tierList.id, req.session.userId)
res.json({ tierList: normalizeTierList(updated) })
})
router.delete('/:id/favorite', requireAuth, async (req, res) => {
const tierList = await findTierListById(req.params.id, req.session.userId)
if (!tierList) return res.status(404).json({ error: 'not_found' })
await unfavoriteTierList({ userId: req.session.userId, tierListId: tierList.id })
const updated = await findTierListById(tierList.id, req.session.userId)
res.json({ tierList: normalizeTierList(updated) })
})
router.post('/custom-items', requireAuth, upload.single('image'), async (req, res) => {
if (!req.file) return res.status(400).json({ error: 'file_required' })
@@ -111,6 +163,11 @@ router.post('/custom-items', requireAuth, upload.single('image'), async (req, re
res.json({ item })
})
router.post('/thumbnail', requireAuth, thumbnailUpload.single('thumbnail'), async (req, res) => {
if (!req.file) return res.status(400).json({ error: 'file_required' })
res.json({ thumbnailSrc: `/uploads/tierlists/${req.file.filename}` })
})
router.post('/', requireAuth, async (req, res) => {
const parsed = tierListUpsertSchema.safeParse(req.body)
if (!parsed.success) return res.status(400).json({ error: 'bad_request' })
@@ -127,6 +184,7 @@ router.post('/', requireAuth, async (req, res) => {
authorId: existing.authorId,
gameId: existing.gameId,
title: payload.title,
thumbnailSrc: payload.thumbnailSrc || '',
description: payload.description || '',
isPublic: !!payload.isPublic,
groups: payload.groups,
@@ -140,6 +198,7 @@ router.post('/', requireAuth, async (req, res) => {
authorId: req.session.userId,
gameId: payload.gameId,
title: payload.title,
thumbnailSrc: payload.thumbnailSrc || '',
description: payload.description || '',
isPublic: !!payload.isPublic,
groups: payload.groups,

80
docker-compose.prod.yml Normal file
View File

@@ -0,0 +1,80 @@
services:
mariadb:
image: mariadb:11.4
container_name: tmaker-mariadb
restart: unless-stopped
environment:
MARIADB_ROOT_PASSWORD: ${MARIADB_ROOT_PASSWORD}
MARIADB_DATABASE: ${MARIADB_DATABASE}
MARIADB_USER: ${MARIADB_USER}
MARIADB_PASSWORD: ${MARIADB_PASSWORD}
command:
- --character-set-server=utf8mb4
- --collation-server=utf8mb4_unicode_ci
volumes:
- tmaker_mariadb_data:/var/lib/mysql
healthcheck:
test: ["CMD-SHELL", "mariadb-admin ping -h 127.0.0.1 -uroot -p$$MARIADB_ROOT_PASSWORD --silent"]
start_period: 150s
interval: 10s
timeout: 5s
retries: 20
backend:
build:
context: .
dockerfile: backend/Dockerfile
container_name: tmaker-backend
restart: unless-stopped
depends_on:
mariadb:
condition: service_healthy
environment:
PORT: 5179
DB_HOST: mariadb
DB_PORT: 3306
DB_USER: ${MARIADB_USER}
DB_PASSWORD: ${MARIADB_PASSWORD}
DB_NAME: ${MARIADB_DATABASE}
SESSION_SECRET: ${SESSION_SECRET}
SESSION_COOKIE_SECURE: "true"
SESSION_COOKIE_SAME_SITE: "lax"
CORS_ORIGINS: https://tmaker.sori.studio
TRUST_PROXY: 1
volumes:
- tmaker_uploads:/app/uploads
- tmaker_sessions:/app/.sessions
frontend:
build:
context: .
dockerfile: frontend/Dockerfile
args:
VITE_API_ORIGIN: https://tmaker.sori.studio
container_name: tmaker-frontend
restart: unless-stopped
depends_on:
- backend
ports:
- "18080:80"
phpmyadmin:
image: phpmyadmin:5.2-apache
container_name: tmaker-phpmyadmin
restart: unless-stopped
profiles: ["admin"]
depends_on:
mariadb:
condition: service_healthy
environment:
PMA_HOST: mariadb
PMA_PORT: 3306
PMA_USER: ${MARIADB_USER}
PMA_PASSWORD: ${MARIADB_PASSWORD}
ports:
- "18081:80"
volumes:
tmaker_mariadb_data:
tmaker_uploads:
tmaker_sessions:

View File

@@ -7,6 +7,7 @@
- 경로, 주소, 운영 설정은 하드코딩보다 환경변수 기반 구성을 우선한다.
- Git 커밋 메시지는 한국어로 작성한다.
- 버전 릴리스가 포함된 작업은 `docs/update.md`의 버전 표기와 Git 태그를 함께 맞춘다.
- Git 푸시 전에는 민감 정보(실명, 개인 이메일, 비밀키, 로컬 절대 경로) 포함 여부를 다시 확인한다.
## 프런트엔드
- API 호출은 `frontend/src/lib/api.js` 또는 런타임 유틸을 통해 통합한다.

View File

@@ -1,5 +1,35 @@
# 의사결정 이력
## 2026-03-27 v0.1.44
- 전역 토스트는 공통 composable을 템플릿에 넘길 때 top-level ref로 풀어줘야 하므로, 렌더링 구조를 단순하게 유지하는 편이 안전하다고 정리했다.
- 공개 티어표가 많아질수록 게임별 목록 안에서 바로 제목/작성자 검색이 가능해야 하므로, 검색은 별도 페이지보다 각 게임 허브 안에서 먼저 제공하기로 결정했다.
- 즐겨찾기는 저장만으로 끝나면 활용도가 낮으므로, 별도 `내 즐겨찾기` 화면과 정렬 옵션을 함께 제공해야 실사용성이 높다고 판단했다.
## 2026-03-27 v0.1.43
- 화면 상단 인라인 경고는 스크롤이 생기면 놓치기 쉬우므로, 저장/삭제/가져오기 같은 사용자 행동 피드백은 전역 우측 상단 토스트로 통일하는 편이 더 적합하다고 정리했다.
- 관리자 티어표 관리의 목적지 선택은 상단 고정 셀렉트보다 액션 직전 모달이 더 명확하므로, `기존 템플릿에 추가 / 새 템플릿 만들기`를 그 순간에 고르게 하기로 결정했다.
- 공개 티어표는 수량이 많아질수록 개인 보관 수단이 필요하므로, 사용자별 즐겨찾기를 별도 테이블로 저장하고 목록/상세에서 즉시 토글할 수 있게 하기로 했다.
## 2026-03-26 v0.1.42
- 관리자 운영 관점에서는 공개 목록만으로는 부족하므로, 전체 티어표를 검색하고 추가 아이템까지 확인하는 별도 `티어표 관리` 탭을 두는 편이 더 적합하다고 정리했다.
- 게임 기반 티어표의 “사용자 추가 아이템”과 `freeform` 티어표의 “전체 아이템”은 활용 목적이 다르므로, 전자는 기존 게임 템플릿 승격 중심으로, 후자는 새 게임 템플릿 생성 중심으로 다루기로 결정했다.
- 관리자는 moderation 목적의 완성본 검토가 필요하므로, 작성자가 아니어도 비공개 티어표 상세를 열람할 수 있게 하기로 했다.
## 2026-03-26 v0.1.41
- 관리자 커스텀 아이템 승격은 버튼만 보이는 상태로 끝나면 안 되므로, 프런트 API와 백엔드 라우트가 실제로 함께 연결되어야 기능이 완결된다고 정리했다.
## 2026-03-26 v0.1.40
- 관리자 기본 아이템 이름 저장은 눌러도 변화가 없으면 혼란스러우므로, 실제 변경이 있을 때만 버튼이 활성화되는 편이 더 명확하다고 판단했다.
- 사용자 커스텀 이미지는 관리자 검토 후 특정 게임의 기본 템플릿으로 복제해 가져올 수 있어야 운영 효율이 높아지므로, 게임 선택 기반 승격 흐름을 추가하기로 결정했다.
## 2026-03-26 v0.1.39
- 티어표 편집 헤더는 게임명 kicker보다 제목과 설명이 더 중요하므로, 좌측 입력 중심 구조로 재배치하고 썸네일은 우측 보조 카드로 분리하는 편이 더 자연스럽다고 판단했다.
- 썸네일 조작 버튼은 모바일에서도 카드와 함께 유지되는 편이 흐름이 덜 끊기므로, 미리보기 아래 별도 줄로 떨어뜨리기보다 카드 내부의 짧은 액션 행으로 묶기로 결정했다.
## 2026-03-26 v0.1.38
- 관리자 기본 아이템은 업로드 시점에만 이름을 정할 수 있으면 운영 중 수정이 어려우므로, 목록에서 직접 이름을 바꾸고 저장할 수 있게 하기로 결정했다.
- 게임별 티어표 목록도 식별성이 중요하므로, 사용자가 편집 시 별도 썸네일을 지정할 수 있게 하고 목록 카드에서는 게임 카드와 비슷한 상단 썸네일 구조를 사용하기로 결정했다.
## 2026-03-19
- 초기 저장소는 빠른 구현을 위해 `lowdb(JSON 파일)`를 채택했다.
- 인증은 JWT 대신 서버 세션(`express-session` + `session-file-store`)을 사용했다.
@@ -26,3 +56,114 @@
## 2026-03-19 v0.1.6
- 저장소 운영 규칙을 정리하면서 Git 작성자 정보는 프로젝트 기준 계정으로 통일하고, 커밋 메시지는 한국어로 남기기로 결정했다.
## 2026-03-19 v0.1.7
- 관리자 페이지는 여러 작업을 동시에 나열하는 구조보다 “하나의 작업 모드를 선택하고 그 작업에 집중하는 구조”가 더 적합하다고 판단해 단계형 UI로 전환했다.
- 관리자에게는 생성뿐 아니라 삭제 책임도 필요하므로 게임 삭제와 아이템 삭제 기능을 추가하기로 결정했다.
- 아이템 삭제는 단순 파일/레코드 삭제만으로 끝내면 안 되고, 기존 티어표 데이터의 참조까지 함께 정리해야 한다고 결정했다.
## 2026-03-19 v0.1.8
- 관리자 업로드 작업은 선택 즉시 결과를 예측할 수 있어야 하므로, 썸네일과 아이템 모두 “파일 선택 → 미리보기 → 실제 업로드” 흐름으로 보강했다.
- 게임 썸네일은 대표 이미지 성격이 강하므로 16:9 비율로, 아이템은 캐릭터/오브젝트 단위 식별이 중요하므로 1:1 비율로 보는 방향을 채택했다.
- 현재 `db.json`과 lowdb 관련 코드는 기본 운영 런타임이 아니라 마이그레이션/예외 fallback 성격임을 분명히 정리했다.
## 2026-03-19 v0.1.9
- 로컬과 운영 환경을 완전히 같은 DB 계층으로 맞추기 위해 lowdb fallback을 제거하고 MariaDB만 지원하는 코드베이스로 정리했다.
- 마이그레이션 종료 이후에는 레거시 JSON 저장소와 예외 실행 스크립트를 남겨두는 비용이 더 크다고 판단해 삭제하기로 결정했다.
## 2026-03-19 v0.1.10
- 관리자 업로드 작업은 "파일 선택 후 적용"이 더 정확하므로, 썸네일 버튼 문구와 활성화 조건을 그 흐름에 맞추기로 결정했다.
- 작은 화면에서 미리보기가 실제 작업 영역을 압박하지 않도록, 아이템 미리보기는 정사각형을 유지하되 최대 크기를 제한하는 방향을 채택했다.
- 파일 입력은 업로드 성공 후와 게임 전환 시 초기화해 같은 파일 재선택이 막히지 않도록 정리했다.
## 2026-03-19 v0.1.11
- 관리자 화면은 좌우 여백이 크게 남는 구조보다, 상단 2열 작업 카드와 하단 목록 영역으로 나누는 편이 더 안정적이라고 판단해 레이아웃을 재정리했다.
- 게임 목록에 없는 주제로도 바로 작업할 수 있도록, 시스템 전용 `freeform` 게임을 내부적으로 유지하고 홈 화면에서는 `직접 티어표 만들기` 카드로 노출하기로 결정했다.
- 게임 제안은 현재 운영 흐름과 맞지 않아 사용자 진입점과 프런트 API에서 제거하고, 대신 관리자에게는 사용자 커스텀 아이템 검토 기능을 제공하기로 했다.
## 2026-03-19 v0.1.12
- 앱 전체 배경은 화면 폭 전체를 사용하고, 개별 콘텐츠만 필요한 만큼 정렬하는 방향이 더 자연스럽다고 판단해 전역 최대 폭 제한을 제거했다.
- 비로그인 사용자가 새 티어표를 편집하다 저장 단계에서 막히는 경험은 손실 위험이 크므로, 작성 시작 자체를 로그인 사용자로 제한하고 공개 티어표는 읽기 전용으로 보여주기로 결정했다.
- 커스텀 이미지 업로드는 단일 파일 선택만으로는 불편하므로, 다중 선택과 드래그 앤 드롭을 기본 흐름으로 보강했다.
- 관리자에게는 게임 관리뿐 아니라 회원 관리 책임도 필요하므로, 회원 목록 조회/수정/삭제 기능을 추가하기로 결정했다.
## 2026-03-19 v0.1.13
- 관리자 페이지는 기능 수가 늘어난 만큼 게임, 아이템, 회원 관리 탭으로 나누는 편이 더 안전하다고 판단했다.
- 사용자 커스텀 아이템은 수량이 빠르게 커질 수 있으므로, 검색과 페이지네이션을 기본 제공하는 관리 화면으로 보는 방향을 채택했다.
- 메일 기반 복구가 없으므로, 관리자가 회원 비밀번호를 직접 초기화할 수 있는 기능을 제공하기로 결정했다.
- 티어표 구조는 게임마다 다르므로, 기본 5단은 시작 템플릿일 뿐 사용자가 행을 직접 추가/삭제할 수 있어야 한다고 결정했다.
## 2026-03-19 v0.1.17
- 작성자가 자기 티어표를 직접 삭제할 수 있어야 관리 흐름이 완결되므로, `내 티어표` 화면에 삭제 기능을 추가하기로 결정했다.
- 사용자 커스텀 이미지는 서버 용량을 계속 차지하므로, 참조가 하나도 남지 않은 이미지(미사용 항목)를 식별하고 관리자 화면에서 개별/일괄 정리할 수 있도록 하기로 결정했다.
## 2026-03-19 v0.1.19
- 티어표 공개 여부는 운영 기준상 대부분 공개 공유가 목적이므로, 신규 작성 시 기본값을 `공개 ON`으로 두기로 결정했다.
- 에디터에서 저장 관련 행동은 좌우로 역할을 나눠 `다운로드/삭제``공개/저장`으로 묶는 편이 더 빠르게 인지된다고 판단했다.
- 공개 목록과 내 목록에서 제목만으로는 식별이 어려우므로, 제목 옆에 작성자 아바타와 표시명을 함께 노출하기로 결정했다.
- 티어표 카드 메타 정보는 저장 시각과 업데이트 시각을 동시에 노출하는 대신, 최종 업데이트 시각만 남겨 단순화하기로 결정했다.
## 2026-03-26 v0.1.21
- 목록 썸네일 fallback 문자는 닉네임보다 계정 기준이 더 일관되므로, 아바타 이미지가 없을 때는 계정명 첫 글자를 사용하기로 결정했다.
- 저장 성공은 화면 이동보다 현 위치 유지가 더 중요하므로, 편집을 계속할 수 있는 확인형 모달로 피드백을 제공하기로 결정했다.
- PNG export는 가장자리 여백이 없는 결과보다 중앙 정렬된 카드형 결과물이 더 완성도 있게 보이므로, export 전용 보드에 충분한 바깥 패딩을 포함하기로 했다.
## 2026-03-26 v0.1.22
- 무제목 저장은 게임 이름 기본값보다 `이름 없음 + 날짜`가 더 명확하다고 판단해 자동 제목 규칙을 변경했다.
- 제목이 비어 있는 티어표는 품질 관리 대상이 될 수 있으므로, 작성 중 단계에서 관리자 임의 삭제 가능성을 미리 안내하기로 결정했다.
- 다운로드 이미지에는 편집용 빈 칸 안내 문구를 제외하고, 더 넓은 보드 폭과 하단 작성자/날짜 메타를 포함해 공유용 완성도를 높이기로 결정했다.
## 2026-03-26 v0.1.23
- 홈 화면 정렬은 단순 생성순 하나보다 `관리자 상단 고정 순서 + 나머지 최신 생성순` 조합이 운영과 신규 노출을 함께 만족시킨다고 판단했다.
- 상단 고정은 전체 수동 정렬보다 최대 50개만 관리하는 방식이 운영 부담이 적으므로, 관리자에게는 제한된 상단 고정 목록만 직접 편집하게 하기로 결정했다.
- `커스텀 티어표 만들기`는 일반 게임 카드와 성격이 다르므로 카드형 목록에서 분리해 우측 상단 버튼으로 노출하기로 결정했다.
## 2026-03-26 v0.1.24
- 상단 고정 게임이 50개까지 늘어날 수 있으므로, 위/아래 버튼만으로는 불편하다고 판단해 드래그 정렬을 함께 제공하기로 결정했다.
- export 결과가 지나치게 넓으면 아이콘이 한 줄에 과도하게 몰리므로, 공유용 이미지 폭을 줄이고 pixel ratio도 낮춰 균형을 맞추기로 결정했다.
- 현재 업로드는 파일 크기 제한만 있고 서버 저장 전 최적화는 없으므로, 운영 문서에 현황을 명확히 남기고 향후 리사이즈/압축 도입 여부를 검토하기로 했다.
## 2026-03-26 v0.1.25
- 저장 결과물 기준 너비가 여전히 길다고 판단해, export 보드 폭을 추가로 `960px`까지 줄여 최종 PNG 밀도를 더 낮추기로 결정했다.
## 2026-03-26 v0.1.26
- 아이콘 크기는 사용자 취향 차이가 큰 요소이므로, 고정값 하나보다 기본 `80px`에 단계형 크기 선택을 제공하는 편이 더 낫다고 판단했다.
## 2026-03-26 v0.1.27
- NAS 운영은 리버스 프록시 설정을 단순하게 유지하는 편이 좋으므로, 프런트 컨테이너 하나만 외부 공개하고 `/api`, `/uploads`는 내부 프록시로 넘기는 구조를 채택했다.
- 운영은 로컬 개발 컴포즈와 분리된 전용 `docker-compose.prod.yml`을 두고, 환경변수는 `.env.production`으로 분리해 관리하기로 결정했다.
## 2026-03-26 v0.1.28
- UGREEN NAS에서 MariaDB 초기화가 길게 걸릴 수 있으므로, healthcheck는 앱 계정보다 `root` 기준 ping과 더 긴 유예 시간으로 두는 편이 안전하다고 판단했다.
## 2026-03-26 v0.1.29
- NAS에서 HTTPS를 종료한 뒤 내부 컨테이너끼리는 HTTP로 통신하는 구조에서는, 프런트 프록시가 백엔드에 원래 프로토콜을 정확히 전달하지 않으면 `secure` 세션 쿠키가 발급되지 않는다고 판단했다.
- 따라서 운영 프런트 Nginx는 백엔드 프록시 요청에 `X-Forwarded-Proto: https`를 명시하고, Express 세션도 프록시 환경을 명시적으로 신뢰하도록 설정하기로 결정했다.
## 2026-03-26 v0.1.30
- 운영 프런트는 다른 origin 절대 URL보다 같은 origin 상대 `/api` 요청을 우선해야 세션 쿠키 저장이 안정적이라고 판단했다.
## 2026-03-26 v0.1.31
- 세션 기반 로그인 응답은 저장소 반영 타이밍 차이를 줄이기 위해 `req.session.save()`를 명시 호출하는 쪽이 운영 안정성에 유리하다고 판단했다.
## 2026-03-26 v0.1.32
- 인증 문제를 빠르게 확인하기 위해 일시적으로 세션 저장 성공/실패 로그를 남기고 원인을 좁혀가는 접근을 선택했다.
## 2026-03-26 v0.1.33
- 프록시 환경의 실제 판단 값을 보기 위해 `req.secure`, `req.protocol`, `x-forwarded-proto`를 직접 로그로 비교해 원인을 확인하기로 했다.
## 2026-03-26 v0.1.34
- 일부 NAS 환경에서 `favicon.svg` 정적 응답이 `403`으로 차단될 수 있으므로, 운영 안정성을 위해 별도 파일 요청이 필요 없는 인라인 데이터 URL 파비콘으로 전환하기로 결정했다.
- 관리자 기본 아이템 등록은 단일 파일 업로드만으로는 운영 부담이 크므로, 다중 선택과 드래그 앤 드롭을 지원하고 라벨은 파일명으로 자동 생성하는 방향을 채택했다.
## 2026-03-26 v0.1.35
- NAS 운영 경로는 수동 파일 복사보다 Git clone 기반이 로컬 개발 흐름과 더 잘 맞고, 실수로 누락되는 파일을 줄일 수 있으므로 기본 배포 방식으로 권장하기로 결정했다.
- 운영 환경 변수와 Docker 볼륨은 Git 저장소 바깥의 NAS 자산으로 유지하고, 코드는 `git pull`로만 반영하는 역할 분리를 명확히 하기로 했다.
## 2026-03-26 v0.1.36
- 브라우저 탭 제목은 개발용 기본 문자열보다 서비스 이름을 직접 보여주는 편이 맞다고 판단해 `Tier Maker`로 고정했다.
- 무제목 티어표 기본값은 날짜형 임시 제목보다 사용자가 어떤 게임으로 작성했는지 즉시 알 수 있는 게임명 기준이 더 자연스럽다고 판단했다.
## 2026-03-26 v0.1.37
- 운영 포트 충돌을 피하기 위해 프로덕션 외부 포트는 `frontend=18080`, `phpMyAdmin=18081`로 고정하고, 리버스 프록시 문서도 그 기준으로 맞추기로 했다.
- 인증 장애 원인을 찾기 위한 디버그 로그는 문제 해결 후 제거하고, 실제 운영에는 세션 저장 보강과 프록시 헤더 설정만 유지하는 편이 낫다고 판단했다.

View File

@@ -33,14 +33,6 @@ cd frontend
VITE_API_ORIGIN=http://localhost:5179 npm run dev
```
## 5. 기존 lowdb 데이터 이관
MariaDB 컨테이너와 백엔드 의존성이 준비된 뒤 아래 명령을 실행한다.
```bash
cd backend
npm run migrate:lowdb
```
## 메모
- 긴급 확인용으로만 `npm run dev:lowdb`를 남겨두었고, 기본 개발 기준은 MariaDB다.
- 현재 코드베이스는 MariaDB 전용이며, 로컬과 NAS 모두 같은 DB 계층을 사용한다.
- NAS 배포 시에도 동일하게 MariaDB를 사용하므로 로컬과 운영 간 DB 계층 차이를 줄일 수 있다.

View File

@@ -2,18 +2,18 @@
## `/`
- 화면 파일: `frontend/src/views/HomeView.vue`
- 역할: 게임 목록 표시, 게임 카드 클릭 이동, 새 게임 제안 모달
- 연동 API: `GET /api/games`, `POST /api/games/suggest`
- 역할: 게임 목록 표시, 게임 카드 클릭 이동, `직접 티어표 만들기` 진입
- 연동 API: `GET /api/games`
## `/games/:gameId`
- 화면 파일: `frontend/src/views/GameHubView.vue`
- 역할: 선택한 게임 정보 표시, 공개 티어표 목록 표시, 작성자 닉네임 노출, 새 티어표 작성 진입
- 연동 API: `GET /api/games/:gameId`, `GET /api/tierlists/public`
- 역할: 선택한 게임 정보 표시, 공개 티어표 목록 표시, 제목/작성자 검색, 티어표별 상단 썸네일/작성자 표시, 즐겨찾기 토글, 새 티어표 작성 진입
- 연동 API: `GET /api/games/:gameId`, `GET /api/tierlists/public`, `POST /api/tierlists/:id/favorite`, `DELETE /api/tierlists/:id/favorite`
## `/editor/:gameId/new`, `/editor/:gameId/:tierListId`
- 화면 파일: `frontend/src/views/TierEditorView.vue`
- 역할: 티어 그룹 편집, 관리자 아이템/커스텀 아이템 드래그 앤 드롭, 저장, 공개 여부 설정, PNG 다운로드
- 연동 API: `GET /api/games/:gameId`, `GET /api/tierlists/:id`, `POST /api/tierlists/custom-items`, `POST /api/tierlists`
- 역할: 티어 그룹 편집, 티어 행 추가/삭제, 관리자 아이템/커스텀 아이템 다중 드래그 앤 드롭 업로드, 티어표 썸네일 선택, 작성 권한 제어, 저장, 공개 여부 설정, 즐겨찾기 토글, PNG 다운로드
- 연동 API: `GET /api/games/:gameId`, `GET /api/tierlists/:id`, `POST /api/tierlists/:id/favorite`, `DELETE /api/tierlists/:id/favorite`, `POST /api/tierlists/thumbnail`, `POST /api/tierlists/custom-items`, `POST /api/tierlists`
## `/login`
- 화면 파일: `frontend/src/views/LoginView.vue`
@@ -22,13 +22,18 @@
## `/me`
- 화면 파일: `frontend/src/views/MyTierListsView.vue`
- 역할: 내 티어표 목록 조회, 편집 화면으로 이동
- 연동 API: `GET /api/tierlists/me`
- 역할: 내 티어표 목록 조회, 상단 썸네일 카드 표시, 편집 화면으로 이동, 작성자 본인 티어표 삭제
- 연동 API: `GET /api/tierlists/me`, `DELETE /api/tierlists/:id`
## `/favorites`
- 화면 파일: `frontend/src/views/FavoriteTierListsView.vue`
- 역할: 즐겨찾기한 티어표 목록 조회, 검색/정렬, 편집 화면 이동, 즐겨찾기 해제
- 연동 API: `GET /api/tierlists/favorites/me`, `DELETE /api/tierlists/:id/favorite`
## `/admin`
- 화면 파일: `frontend/src/views/AdminView.vue`
- 역할: 게임 추가, 게임 선택 후 썸네일 업로드, 관리자 아이템 추가, 현재 아이템 목록 확인
- 연동 API: `POST /api/admin/games`, `POST /api/admin/games/:gameId/thumbnail`, `POST /api/admin/games/:gameId/images`
- 역할: `게임 관리 / 아이템 관리 / 티어표 관리 / 회원 관리` 탭 분리, 선택된 게임의 썸네일 관리, 기본 아이템 다중 드래그 앤 드롭 업로드, 기본 아이템 이름 수정, 사용자 커스텀 아이템 검색/페이지네이션/사용 횟수 확인/미사용 이미지 개별·일괄 삭제, 사용자 커스텀 아이템의 기본 템플릿 승격, 전체 티어표 검색/페이지네이션/공개 여부 확인/완성본 이동, 티어표의 추가 커스텀 아이템을 모달 기반으로 기존 템플릿 또는 새 템플릿에 가져오기, freeform 티어표의 게임 템플릿화, 회원 비밀번호 초기화 포함 회원 관리, 파일 입력 초기화, 아이템 삭제, 게임 삭제
- 연동 API: `POST /api/admin/games`, `POST /api/admin/games/:gameId/thumbnail`, `POST /api/admin/games/:gameId/images`, `PATCH /api/admin/games/:gameId/items/:itemId`, `GET /api/admin/custom-items`, `POST /api/admin/custom-items/:itemId/promote`, `DELETE /api/admin/custom-items/:itemId`, `DELETE /api/admin/custom-items`, `GET /api/admin/tierlists`, `POST /api/admin/tierlists/:tierListId/promote-items`, `POST /api/admin/tierlists/:tierListId/create-game-template`, `GET /api/admin/users`, `PATCH /api/admin/users/:userId`, `PATCH /api/admin/users/:userId/password`, `DELETE /api/admin/users/:userId`, `DELETE /api/admin/games/:gameId/items/:itemId`, `DELETE /api/admin/games/:gameId`
## `/profile`
- 화면 파일: `frontend/src/views/ProfileView.vue`
@@ -37,7 +42,7 @@
## 공통 레이아웃
- 앱 셸 파일: `frontend/src/App.vue`
- 역할: 상단 내비게이션, 로그인 상태 반영, 아바타 메뉴, 관리자 메뉴 노출 제어
- 역할: 상단 내비게이션, 로그인 상태 반영, 아바타 메뉴, 관리자 메뉴 노출 제어, 전역 우측 상단 토스트 렌더링
## 백엔드 진입점
- 서버 엔트리: `backend/index.js`

View File

@@ -6,6 +6,9 @@
- 데이터 저장소: MariaDB(MySQL 호환)
- 세션 저장소: `session-file-store` 기반 파일 세션
- 업로드 저장소: 로컬 파일 시스템(`backend/uploads/`)
- 운영 배포: `frontend(Nginx 정적 서빙 + /api,/uploads 프록시) + backend + mariadb` Docker Compose 구조
- NAS HTTPS 리버스 프록시 운영 시 프런트 Nginx는 백엔드로 `X-Forwarded-Proto: https`를 전달하고, Express 세션은 프록시 환경에서 `secure` 쿠키를 허용하도록 설정한다.
- 프런트 파비콘은 운영 정적 파일 차단 영향을 줄이기 위해 `index.html`의 인라인 데이터 URL로 제공한다.
## 데이터 저장 구조
- 메인 데이터베이스: MariaDB `tier_cursor` (기본값)
@@ -15,7 +18,6 @@
- 아바타: `backend/uploads/avatars/`
- 커스텀 아이템: `backend/uploads/custom/`
- 시드 이미지: `backend/uploads/seeds/`
- 레거시 마이그레이션 소스: `backend/data/db.json`
## DB 스키마
- `users`
@@ -31,6 +33,7 @@
- `name`: string
- `thumbnailSrc`: string
- `createdAt`: number
- 시스템 전용 `freeform` 레코드는 홈 화면의 `직접 티어표 만들기` 저장 대상이며 일반 게임 목록에서는 숨긴다.
- `gameItems`
- `id`: string
- `gameId`: string
@@ -48,12 +51,17 @@
- `authorId`: string
- `gameId`: string
- `title`: string
- `thumbnailSrc`: string
- `description`: string
- `isPublic`: boolean
- `groups`: `{ id, name, itemIds[] }[]`
- `pool`: `{ id, src, label, origin }[]`
- `createdAt`: number
- `updatedAt`: number
- `favoriteTierLists`
- `userId`: string
- `tierListId`: string
- `createdAt`: number
- `gameSuggestions`
- `id`: string
- `name`: string
@@ -70,23 +78,86 @@
- 게임
- `GET /api/games`
- `GET /api/games/:gameId`
- `POST /api/games/suggest`
- 티어표
- `GET /api/tierlists/public`
- `GET /api/tierlists/me`
- `GET /api/tierlists/favorites/me`
- `GET /api/tierlists/:id`
- `POST /api/tierlists/:id/favorite`
- `DELETE /api/tierlists/:id/favorite`
- `DELETE /api/tierlists/:id`
- `POST /api/tierlists/thumbnail`
- `POST /api/tierlists/custom-items`
- `POST /api/tierlists`
- 관리자
- `POST /api/admin/games`
- `POST /api/admin/games/:gameId/thumbnail`
- `POST /api/admin/games/:gameId/images`
- 여러 이미지를 한 번에 업로드할 수 있고, 별도 라벨이 없으면 파일명 기준으로 기본 아이템 이름을 만든다.
- `PATCH /api/admin/games/:gameId/items/:itemId`
- `GET /api/admin/tierlists`
- `POST /api/admin/tierlists/:tierListId/promote-items`
- `POST /api/admin/tierlists/:tierListId/create-game-template`
- `GET /api/admin/custom-items`
- `POST /api/admin/custom-items/:itemId/promote`
- `DELETE /api/admin/custom-items/:itemId`
- `DELETE /api/admin/custom-items`
- `GET /api/admin/users`
- `PATCH /api/admin/users/:userId`
- `PATCH /api/admin/users/:userId/password`
- `DELETE /api/admin/users/:userId`
- `DELETE /api/admin/games/:gameId/items/:itemId`
- `DELETE /api/admin/games/:gameId`
## 관리자 화면 메모
- 썸네일은 16:9 비율 미리보기 후 `썸네일 적용` 버튼으로 실제 반영한다.
- 게임 기본 아이템 추가는 드래그 앤 드롭 또는 다중 파일 선택으로 처리하고, 미리보기 카드에서 여러 장을 함께 확인할 수 있다.
- 현재 기본 아이템 목록에서는 등록된 아이템 이름을 직접 수정하고 저장할 수 있다.
- 기본 아이템 이름 저장 버튼은 값이 실제로 바뀐 경우에만 활성화된다.
- 아이템 미리보기는 반응형 환경에서도 최대 `192px` 크기 안에서 표시한다.
- 게임 전환 또는 업로드 성공 뒤에는 파일 입력값을 초기화해 같은 파일도 다시 선택할 수 있다.
- 게임 관리 탭에서는 홈 화면 상단에 먼저 노출할 게임을 최대 50개까지 지정하고, 드래그 또는 위/아래 버튼으로 순서를 저장할 수 있다.
- 사용자 업로드 커스텀 아이템은 관리자 화면의 아이템 관리 탭에서 검색, 페이지네이션, 다운로드할 수 있다.
- 사용자 커스텀 아이템은 선택한 게임의 기본 템플릿으로 복제해 가져올 수 있다.
- 커스텀 아이템은 사용 횟수(`usageCount`)를 표시하며, 미사용 항목만 필터링해 개별/일괄 삭제할 수 있다.
- 관리자 화면에는 별도 `티어표 관리` 탭이 있으며, 최근 티어표 전체를 제목/게임/작성자 기준으로 검색하고 공개 여부를 함께 확인할 수 있다.
- `티어표 관리` 탭의 추가 아이템은 작은 그리드 카드로 표시하고, 클릭 시 `기존 템플릿에 추가 / 새 템플릿 만들기` 모달을 통해 목적지를 선택한다.
- `티어표 관리` 탭에서는 티어표 안의 커스텀 아이템을 개별 또는 일괄로 기존 게임 템플릿에 복제할 수 있다.
- `freeform` 티어표는 관리자 화면에서 새 게임 ID/이름을 입력해 새로운 게임 템플릿으로 복제 생성할 수 있다.
- 관리자 화면에서는 회원 이메일/닉네임/권한 수정, 비밀번호 초기화, 계정 삭제가 가능하다.
## 티어표 접근 메모
- `new` 작성 경로는 로그인한 사용자만 진입할 수 있다.
- 비로그인 사용자는 공개된 티어표를 열람만 할 수 있고, 편집 UI와 저장 동작은 비활성화된다.
- 비공개 티어표라도 관리자는 편집 화면에서 완성본을 열람할 수 있다.
- 공개 티어표는 목록과 상세 화면에서 즐겨찾기 토글 및 개수를 함께 표시한다.
- 공개 티어표 목록은 현재 게임 기준으로 제목/작성자 검색을 지원한다.
- `내 즐겨찾기` 화면에서는 즐겨찾기한 순, 최신 업데이트순, 인기순 정렬을 제공한다.
- 커스텀 이미지 추가는 다중 파일 선택과 드래그 앤 드롭을 모두 지원한다.
- 티어 행은 기본 5단으로 시작하지만, 사용자가 직접 추가하거나 제거할 수 있다.
- 신규 티어표의 공개 여부 기본값은 `ON`이며, 기존 티어표는 편집 화면과 `내 티어표` 목록에서 직접 삭제할 수 있다.
- 제목이 비어 있는 상태로 저장하면 내부 제목은 현재 게임명을 기본값으로 사용한다.
- 제목 입력이 비어 있는 동안에는 무분별한 도배 방지를 위한 관리자 임의 삭제 가능성 안내 문구를 표시한다.
- 티어표는 편집 화면에서 16:9 썸네일 이미지를 별도로 선택해 저장할 수 있고, 목록 카드에서는 그 이미지를 상단 대표 썸네일로 사용한다.
- 편집 화면 상단 헤더는 좌측 제목/설명, 우측 썸네일 카드 구조를 사용하며 모바일에서는 한 열로 접힌다.
- 티어표 편집기의 아이콘 기본 크기는 `80px`이며, 사용자가 `48 / 60 / 80 / 100 / 120` 단계로 즉시 조절할 수 있다.
- 공개 티어표 목록과 `내 티어표` 목록은 제목 옆에 작성자 아바타와 표시명을 함께 보여준다.
- 작성자 아바타 이미지가 없을 경우 목록 썸네일 fallback은 닉네임이 아니라 계정명 기준 첫 글자를 사용한다.
- 티어표 목록 메타 정보는 최종 업데이트 시각만 간략하게 표시한다.
- 저장 성공 시에는 에디터 안에서 반투명 오버레이 기반 확인 모달을 띄우고, PNG export 이미지는 약 `960px` 보드 폭과 `pixelRatio 1.5`, 외곽 여백, 작성자/날짜 하단 메타를 포함해 생성한다.
- 저장/삭제/가져오기 같은 사용자 행동 피드백은 전역 우측 상단 토스트로 표시한다.
- 홈 게임 목록은 관리자 상단 고정 순서가 있으면 그 순서를 먼저 적용하고, 그 외 게임은 최근 생성순으로 뒤에 이어진다.
- `커스텀 티어표 만들기`는 카드가 아니라 홈 우측 상단 버튼으로 진입한다.
## 업로드 제한 메모
- 프로필 아바타 업로드는 파일당 최대 `3MB`다.
- 관리자 게임 썸네일/기본 아이템 업로드와 사용자 커스텀 이미지 업로드는 파일당 최대 `6MB`다.
- 현재는 업로드 전에 이미지 리사이즈/압축을 하지 않고 원본 파일을 그대로 저장한다.
## 운영 환경 변수
- 프런트엔드
- `VITE_API_ORIGIN`: API 및 업로드 파일 절대 기준 주소
- 백엔드
- `DB_CLIENT`: 기본 개발 기준은 `mariadb`
- `DB_HOST`: MariaDB 호스트
- `DB_PORT`: MariaDB 포트
- `DB_USER`: MariaDB 계정
@@ -99,15 +170,20 @@
- `SESSION_COOKIE_SECURE`: `true`면 HTTPS 전용 쿠키
- `SESSION_COOKIE_SAME_SITE`: 기본 `lax`
## 운영 배포 메모
- 프로덕션 컴포즈 파일은 [docker-compose.prod.yml](/Users/bicute/Desktop/zenn.dev/tier-cursor/docker-compose.prod.yml)이다.
- 외부 도메인 `tmaker.sori.studio``frontend` 컨테이너의 `18080` 포트로 리버스 프록시하고, `/api`, `/uploads`, `/health`는 프런트 Nginx가 내부 `backend:5179`로 전달한다.
- 운영 볼륨은 MariaDB 데이터, 업로드 파일, 세션 파일을 각각 분리해 유지한다.
- MariaDB healthcheck는 NAS 첫 기동 지연을 고려해 `root` 기준 ping과 긴 `start_period/retries`를 사용한다.
## NAS 배포 메모
- 현재 구조는 MariaDB/MySQL 계열이므로 NAS에 MariaDB를 올리면 phpMyAdmin 또는 Adminer로 직접 데이터 확인이 가능하다.
- 추천 구성:
- MariaDB 컨테이너 또는 NAS 패키지 설치
- phpMyAdmin 또는 Adminer 설치
- 앱은 환경변수로 해당 DB에 연결
- 레거시 `db.json` 데이터는 `node backend/scripts/migrate-lowdb-to-mariadb.js`로 이관한다.
## 로컬 개발 기준
- 기본 로컬 개발도 `docker compose`로 띄운 MariaDB를 사용한다.
- 기본 백엔드 실행 스크립트 `backend/package.json``dev`, `start`, `migrate:lowdb`는 로컬 MariaDB(`127.0.0.1:3307`) 기준으로 맞춰져 있다.
- 예외적으로만 `dev:lowdb`, `start:lowdb`를 사용한다.
- 기본 백엔드 실행 스크립트 `backend/package.json``dev`, `start`는 로컬 MariaDB(`127.0.0.1:3307`) 기준으로 맞춰져 있다.
- `backend/src/db.js`는 MariaDB만 대상으로 동작하며, 파일 기반 fallback은 제거되었다.

View File

@@ -1,9 +1,17 @@
# 할 일 및 이슈
## 즉시 확인 필요
- 관리자 화면에 게임 제안(`gameSuggestions`) 조회/처리 UI가 아직 없다.
- MariaDB 실제 서버가 준비되면 `backend/scripts/migrate-lowdb-to-mariadb.js`를 실행해 기존 `db.json` 데이터를 이관해야 한다.
- 기존 `backend/data/db.json`의 절대 로컬 URL/깨진 파일명 데이터는 마이그레이션 후 수동 정리가 필요할 수 있다.
- 회원 관리에서 아바타/작성 티어표 수/최근 활동 같은 보조 정보는 아직 표시하지 않는다.
- 미사용 커스텀 이미지 일괄 삭제는 현재 "참조가 없는 항목" 기준이며, 보관 기간 정책 같은 운영 규칙은 아직 없다.
- 업로드 이미지는 현재 원본 파일을 그대로 저장하므로, 운영 부담이 커지면 서버 저장 전 리사이즈/압축(예: 긴 변 제한, WebP 변환) 도입이 필요하다.
- 관리자 기본 아이템 다중 업로드는 현재 파일명 기반 자동 라벨만 지원하므로, 필요하면 업로드 후 일괄 라벨 수정/정렬 UX를 추가 검토한다.
- 티어표 썸네일은 현재 업로드/교체만 지원하므로, 필요하면 자동 썸네일 추출이나 업로드 이미지 크롭 UX를 추가 검토한다.
- 사용자 커스텀 아이템 승격은 현재 수동 복제 방식이므로, 필요하면 중복 감지나 “비슷한 항목 추천” 같은 보조 UX를 검토한다.
- 관리자 티어표 관리의 템플릿 생성은 현재 `freeform`만 직접 지원하므로, 필요하면 일반 게임 티어표의 전체 아이템을 복제한 파생 템플릿 생성 UX도 검토한다.
- 관리자 티어표 관리의 추가 아이템 승격은 현재 커스텀(origin=`custom`) 아이템 기준이므로, 필요하면 “기존 게임 아이템과 비교한 차집합” 기준으로 더 정교하게 확장할 수 있다.
- 즐겨찾기는 현재 `내 즐겨찾기` 목록과 정렬까지 지원하므로, 필요하면 폴더 분류나 메모 같은 개인 정리 기능을 추가 검토한다.
- 전역 토스트는 기본 시간 기반 자동 종료만 지원하므로, 필요하면 중복 합치기나 액션 링크 포함 형태로 확장할 수 있다.
- 공개 티어표 검색은 현재 게임별 허브 안에서만 제공하므로, 필요하면 홈 전역 통합 검색도 검토한다.
## 배포 전 작업
- NAS 실제 도메인 기준으로 `VITE_API_ORIGIN`, `CORS_ORIGINS`, `SESSION_SECRET`, `SESSION_COOKIE_SECURE`, `TRUST_PROXY` 값을 설정한다.
@@ -13,6 +21,8 @@
- 로컬 docker compose와 NAS MariaDB 사이의 버전 차이가 크지 않도록 유지한다.
## 중기 개선
- 게임/이미지/티어표 삭제 수정 이력 관리 기능을 추가한다.
- 게임/이미지/티어표 삭제 후 복구 또는 수정 이력 관리 기능을 추가한다.
- 자동 테스트와 최소한의 배포 체크리스트를 만든다.
- 관리자용 게임 제안 승인/반려, 아이템 삭제/정렬 UI를 추가한다.
- 관리자용 티어표 승인/숨김 처리, 아이템 정렬 UI를 추가한다.
- 회원 검색/필터, 일괄 권한 변경 같은 관리 보조 기능을 추가한다.
- 티어 행 프리셋 저장, 색상 관리, 행 복제 같은 고급 편집 기능을 추가한다.

160
docs/ugreen-nas-deploy.md Normal file
View File

@@ -0,0 +1,160 @@
# UGREEN NAS 배포 가이드
## 개요
- 운영 기본 컨테이너는 `mariadb`, `backend`, `frontend` 3개다.
- `phpmyadmin`은 필요할 때만 `admin` 프로필로 추가 실행한다.
- 외부 공개는 `frontend` 컨테이너 하나만 하고, `/api`, `/uploads`, `/health`는 내부적으로 `backend`로 프록시한다.
- 도메인은 `https://tmaker.sori.studio` 기준으로 설정한다.
## 파일
- 프로덕션 컴포즈: [docker-compose.prod.yml](/Users/bicute/Desktop/zenn.dev/tier-cursor/docker-compose.prod.yml)
- 백엔드 이미지: [backend/Dockerfile](/Users/bicute/Desktop/zenn.dev/tier-cursor/backend/Dockerfile)
- 프런트 이미지: [frontend/Dockerfile](/Users/bicute/Desktop/zenn.dev/tier-cursor/frontend/Dockerfile)
- 프런트 Nginx 프록시: [frontend/nginx.conf](/Users/bicute/Desktop/zenn.dev/tier-cursor/frontend/nginx.conf)
- 환경변수 예시: [.env.production.example](/Users/bicute/Desktop/zenn.dev/tier-cursor/.env.production.example)
## 1. 프로젝트 업로드
- NAS 작업 폴더에 현재 프로젝트를 그대로 업로드한다.
- 기존 로컬 MariaDB 내용은 무시하고 새 운영 DB로 시작해도 된다.
## 1-1. 권장 방식: Git clone 기반 운영
- 수동 복사는 처음 1회에는 가능하지만, 이후부터는 로컬과 NAS가 쉽게 어긋난다.
- 권장 방식은 NAS 작업 폴더를 Git 저장소로 두고, 로컬에서 작업 후 `push`, NAS에서는 `pull`만 하는 구조다.
- 추천 흐름:
- 로컬: 개발 → 테스트 → 커밋 → `git push`
- NAS: `git pull``docker compose up -d --build`
처음부터 Git으로 시작하려면 NAS에서:
```bash
cd /volume1/docker/projects/apps
git clone https://git.sori.studio/zenn/tier-maker.git
cd tier-maker
cp .env.production.example .env.production
```
- 이미 같은 경로에 수동 복사본이 있다면, 가장 깔끔한 방법은 기존 폴더를 다른 이름으로 잠시 옮기고 새로 `clone`하는 것이다.
- `.env.production`은 Git에 올리지 않고 NAS에만 유지한다.
예시:
```bash
cd /volume1/docker/projects/apps
mv tier-maker tier-maker-manual-backup
git clone https://git.sori.studio/zenn/tier-maker.git
cd tier-maker
cp .env.production.example .env.production
```
- 이후 기존 수동 복사본의 `.env.production` 값을 새 clone 폴더의 `.env.production`에 그대로 옮기면 된다.
## 2. 환경변수 파일 준비
- 루트에서 `.env.production.example`를 복사해 `.env.production`으로 만든다.
- 최소 변경값:
- `MARIADB_ROOT_PASSWORD`
- `MARIADB_PASSWORD`
- `SESSION_SECRET`
예시:
```env
MARIADB_ROOT_PASSWORD=very-strong-root-password
MARIADB_DATABASE=tier_cursor
MARIADB_USER=tier_cursor
MARIADB_PASSWORD=very-strong-app-password
SESSION_SECRET=very-strong-random-session-secret
```
## 3. 컨테이너 실행
```bash
docker compose --env-file .env.production -f docker-compose.prod.yml up -d --build
```
- phpMyAdmin까지 같이 띄우려면:
```bash
docker compose --env-file .env.production -f docker-compose.prod.yml --profile admin up -d --build
```
- MariaDB 첫 초기화는 NAS 환경에서 2분 이상 걸릴 수 있다.
- 현재 프로덕션 컴포즈는 이를 고려해 `start_period: 150s`, `retries: 20` healthcheck를 사용한다.
- 로그상 DB가 정상 기동했는데도 `unhealthy`가 뜬 적이 있다면 최신 `docker-compose.prod.yml`로 다시 올리는 것이 좋다.
## 3-1. 이후 업데이트 방식
- Git clone 기반으로 전환한 뒤에는 파일을 하나씩 NAS에 덮어쓰지 않는다.
- 로컬에서 커밋과 푸시가 끝난 뒤, NAS에서는 아래 두 줄이 기본 배포 절차다.
```bash
git pull origin main
docker compose --env-file .env.production -f docker-compose.prod.yml up -d --build
```
- Dockerfile, Nginx 설정, 프런트 소스, 백엔드 소스가 바뀐 경우에는 `--build`를 유지한다.
- 단순 재시작만 필요할 때도 있지만, 운영에서는 실수 방지를 위해 `up -d --build`를 기본값으로 두는 편이 안전하다.
## 3-2. 이번 v0.1.34까지 적용하는 예시
- 이미 NAS 폴더가 Git clone 상태라면:
```bash
cd /volume1/docker/projects/apps/tier-maker
git pull origin main
sudo docker compose --env-file .env.production -f docker-compose.prod.yml up -d --build
```
- 아직 수동 복사 폴더만 있다면:
```bash
cd /volume1/docker/projects/apps
mv tier-maker tier-maker-manual-backup
git clone https://git.sori.studio/zenn/tier-maker.git
cd tier-maker
cp .env.production.example .env.production
# 여기서 기존 .env.production 값을 새 파일에 옮긴다.
docker compose --env-file .env.production -f docker-compose.prod.yml up -d --build
```
## 4. NAS 리버스 프록시
- 외부 도메인: `tmaker.sori.studio`
- 내부 대상 프로토콜: `http`
- 내부 대상 호스트: NAS IP 또는 `localhost`
- 내부 대상 포트: `18080`
즉 NAS 리버스 프록시는 `frontend` 컨테이너의 `18080`만 바라보면 된다.
## 5. HTTPS / 쿠키
- 현재 프로덕션 컴포즈는 `SESSION_COOKIE_SECURE=true`를 사용한다.
- 따라서 `tmaker.sori.studio`에는 HTTPS 인증서가 연결되어 있어야 한다.
- NAS 리버스 프록시가 HTTPS 종료를 하고 내부는 `http://frontend:80` 또는 `localhost:18080`으로 전달하면 된다.
- 최신 프런트 Nginx 설정은 백엔드로 `X-Forwarded-Proto: https`를 넘기므로, 로그인 직후 세션이 바로 풀리는 경우에는 프런트 이미지를 다시 빌드해 최신 설정이 반영됐는지 먼저 확인한다.
## 6. 데이터 위치
- MariaDB 데이터: Docker volume `tmaker_mariadb_data`
- 업로드 파일: Docker volume `tmaker_uploads`
- 세션 파일: Docker volume `tmaker_sessions`
## 7. 점검 포인트
- 메인 접속: `https://tmaker.sori.studio`
- 헬스체크: `https://tmaker.sori.studio/health`
- 로그인 후 새로고침 또는 `내 티어표` 진입 시 세션이 유지되는지 확인
- 관리자 로그인 후:
- 게임 생성
- 썸네일 업로드
- 티어표 저장
- 이미지 다운로드
## 8. MariaDB가 unhealthy일 때
- 로그에 `ready for connections`가 보이면 DB 자체는 정상일 가능성이 높다.
- 이 경우는 대부분 healthcheck 시간이 짧아서 생기는 문제다.
- 최신 컴포즈 파일 반영 후 아래 순서로 다시 시작한다:
```bash
docker compose --env-file .env.production -f docker-compose.prod.yml down -v
docker compose --env-file .env.production -f docker-compose.prod.yml up -d --build
```
## 9. 참고
- 현재 업로드 이미지는 서버 저장 전에 리사이즈/압축하지 않는다.
- 운영 중 원본 이미지가 많이 쌓이면 이후 `sharp` 기반 최적화 단계를 추가하는 것이 좋다.
- 프런트/백엔드/Nginx 설정을 바꿨다면 NAS에서 `docker compose --env-file .env.production -f docker-compose.prod.yml up -d --build`로 이미지를 다시 빌드해 반영한다.
- 운영 중 `.env.production`, 업로드 파일 볼륨, MariaDB 볼륨은 Git과 별개로 NAS 로컬 자산이므로 백업 정책을 따로 잡아야 한다.

View File

@@ -1,5 +1,120 @@
# 업데이트 로그
## 2026-03-27 v0.1.44
- **토스트 렌더링 버그 수정**: 전역 토스트가 빈 카드 여러 개로 보이던 ref 참조 문제를 수정해 실제 메시지만 표시되도록 정리
- **공개 티어표 검색 추가**: 게임별 공개 티어표 목록에서 제목/작성자 기준 검색이 가능하도록 검색창과 API 쿼리 지원 추가
- **내 즐겨찾기 페이지 추가**: 사용자별 즐겨찾기 목록 화면과 `즐겨찾기한 순 / 최신 업데이트순 / 인기순` 정렬 옵션을 추가
## 2026-03-27 v0.1.43
- **전역 토스트 알림 추가**: 저장/삭제/가져오기 같은 사용자 행동 피드백을 상단 인라인 경고 대신 우측 상단 토스트로 통일해 잠시 표시 후 자동으로 사라지도록 변경
- **관리자 티어표 아이템 가져오기 모달화**: 티어표 관리의 추가 아이템 영역을 소형 그리드로 다듬고, 가져오기 시점에 `기존 템플릿에 추가 / 새 템플릿 만들기`를 선택하는 모달 흐름으로 재정리
- **티어표 즐겨찾기 추가**: 공개 티어표 목록과 상세 화면에서 즐겨찾기 토글과 개수를 표시하고, MariaDB에 사용자별 즐겨찾기 이력을 저장하도록 확장
## 2026-03-26 v0.1.42
- **관리자 티어표 관리 탭 추가**: 공개/비공개를 포함한 최근 티어표 전체를 관리자 화면에서 검색/페이지네이션으로 확인하고, 제목·작성자·게임·공개 여부를 함께 볼 수 있도록 보강
- **추가 아이템 승격 흐름 확장**: 티어표 안에서 사용자가 추가한 커스텀 아이템을 관리자 화면에서 바로 특정 게임의 기본 템플릿으로 개별 또는 일괄 복제할 수 있도록 추가
- **커스텀 티어표 템플릿화 추가**: `freeform` 티어표는 관리자 화면에서 새 게임 ID/이름을 입력해 별도 게임 템플릿으로 복제 생성할 수 있도록 지원
- **관리자 열람 권한 확장**: 비공개 티어표도 관리자는 편집 화면에서 완성본을 열람할 수 있도록 상세 조회 권한을 확장
## 2026-03-26 v0.1.41
- **커스텀 아이템 승격 연결 수정**: 관리자 아이템 관리의 `기본 템플릿에 추가` 버튼이 실제 API와 백엔드 승격 라우트로 연결되도록 누락된 프런트/백엔드 구현을 보완
## 2026-03-26 v0.1.40
- **기본 아이템 저장 UX 보강**: 관리자 게임 관리에서 아이템 이름이 실제로 바뀐 경우에만 `이름 저장` 버튼이 활성화되도록 조정하고, 저장 중 상태를 버튼에 표시
- **커스텀 아이템 승격 추가**: 관리자 아이템 관리에서 사용자 커스텀 이미지를 선택한 게임의 기본 템플릿으로 복제해 가져올 수 있도록 API와 UI를 추가
## 2026-03-26 v0.1.39
- **에디터 헤더 재구성**: 티어표 편집 상단에서 게임명 kicker를 제거하고, 좌측 제목/설명 입력과 우측 썸네일 카드가 나란히 보이는 구조로 재정리
- **썸네일 영역 UX 개선**: 썸네일 미리보기와 선택/제거 버튼을 하나의 카드 안에 묶고, 모바일에서도 버튼이 카드 아래로 무너지지 않도록 밀도 있게 조정
## 2026-03-26 v0.1.38
- **관리자 기본 아이템 이름 수정 추가**: 게임 관리 화면의 현재 기본 아이템 목록에서 이름을 직접 수정하고 저장할 수 있도록 API와 UI를 보강
- **티어표 썸네일 추가**: 티어표 편집 화면에서 별도 썸네일 이미지를 선택해 저장할 수 있도록 업로드 흐름을 추가하고, 게임별 공개 티어표/내 티어표 목록은 게임 카드처럼 상단 썸네일 + 하단 제목/작성자 정보 카드 구조로 변경
## 2026-03-26 v0.1.37
- **운영 포트 설정 반영**: 프로덕션 컴포즈의 `frontend/phpMyAdmin` 외부 포트를 `18080/18081` 기준으로 유지하고, NAS 배포 문서와 기술 명세의 리버스 프록시 포트 안내도 동일하게 정리
- **인증 라우트 정리**: NAS 로그인 문제를 확인하기 위해 넣었던 `auth` 디버그 로그를 제거하고, 실제 운영에 필요한 세션 저장 보강만 유지
- **이력 문서 정렬**: `docs/history.md`를 날짜/버전 흐름에 맞게 다시 정리해 추적성을 높임
## 2026-03-26 v0.1.36
- **브라우저 탭 이름 변경**: 프런트 문서 제목을 `frontend`에서 `Tier Maker`로 변경
- **무제목 티어표 기본값 조정**: 사용자가 제목을 입력하지 않으면 `이름 없음 + 날짜` 대신 현재 게임명을 기본 제목으로 사용하도록 변경하고, 관리자 임의 삭제 안내 문구는 유지
## 2026-03-26 v0.1.35
- **NAS Git 배포 절차 추가**: UGREEN NAS에서 수동 복사 대신 `git clone``git pull` 기반으로 운영 배포를 관리하는 절차를 배포 가이드에 정리
- **v0.1.34 반영 명령 정리**: 이미 수동 복사본이 있는 경우 새 clone으로 전환한 뒤 최신 이미지를 다시 빌드하는 순서를 문서화
## 2026-03-26 v0.1.34
- **파비콘 정적 요청 제거**: 운영 환경에서 `/favicon.svg``403`으로 막히는 경우를 피하기 위해, 별도 파일 대신 `index.html` 인라인 데이터 URL 파비콘으로 전환
- **관리자 기본 아이템 다중 업로드 추가**: 게임 관리 화면에서 기본 아이템을 여러 장 드래그 앤 드롭 또는 다중 파일 선택으로 한 번에 추가할 수 있도록 변경하고, 기본 라벨은 파일명 기준으로 자동 생성
## 2026-03-26 v0.1.33
- **[NAS] 요청 프로토콜 디버그**: `auth/login`/`auth/me`에서 `req.secure`, `req.protocol`, `x-forwarded-proto` 값을 로그로 출력해 프록시/HTTPS 판단 문제를 확인
## 2026-03-26 v0.1.32
- **[NAS] 인증 디버그 로그 추가**: `auth/login`에서 `req.session.save` 성공/실패와 `auth/me`에서 세션 존재 여부를 콘솔 로그로 남겨 세션 쿠키 발급 문제를 빠르게 진단
## 2026-03-26 v0.1.31
- **[NAS] 세션 쿠키 발급 강제**: 백엔드 인증 라우트에서 `req.session.save()`를 명시 호출해 응답 전에 세션을 저장하고 `Set-Cookie`가 확실히 내려오도록 보강
## 2026-03-26 v0.1.30
- **[NAS] /api 상대경로 호출**: 운영(`import.meta.env.PROD`)에서는 `http://localhost:...` 같은 다른 origin으로 API를 호출하지 않도록, `frontend/src/lib/runtime.js`에서 `/api` 호출을 상대경로로 고정해 세션 쿠키가 정상 저장되도록 수정
## 2026-03-26 v0.1.29
- **NAS 로그인 유지 수정**: 프런트 Nginx가 백엔드에 전달하는 `X-Forwarded-Proto``https`로 고정하고 Express 세션의 프록시 인지를 명시해, NAS HTTPS 리버스 프록시 뒤에서도 `secure` 세션 쿠키가 정상 발급되도록 조정
- **운영 템플릿 복구**: 실수로 빠질 수 있는 `.env.production.example`를 다시 포함하고, NAS 재배포 시 최신 프런트 이미지를 다시 빌드하도록 문서 보강
## 2026-03-26 v0.1.28
- **MariaDB healthcheck 완화**: UGREEN NAS 첫 초기화 시간이 길어도 `unhealthy`로 오판하지 않도록 프로덕션 컴포즈의 DB healthcheck를 `root` 기준과 더 긴 `start_period/retries`로 조정
- **NAS 장애 대응 문서화**: `ready for connections` 이후에도 `unhealthy`가 뜨는 경우의 재기동 절차를 배포 가이드에 추가
## 2026-03-26 v0.1.27
- **UGREEN NAS 배포 파일 추가**: `backend`, `frontend`용 Dockerfile과 프런트 Nginx 프록시 설정, 프로덕션 전용 `docker-compose.prod.yml` 추가
- **운영 환경 예시 추가**: `.env.production.example`로 MariaDB/세션 시크릿 환경변수 템플릿 제공
- **배포 문서화**: `tmaker.sori.studio` 기준 NAS 리버스 프록시, 컨테이너 실행, 볼륨 구성 가이드를 문서에 정리
## 2026-03-26 v0.1.26
- **아이콘 크기 조절 추가**: 티어표 편집기에서 `48 / 60 / 80 / 100 / 120` 단계로 아이콘 크기를 직접 바꿀 수 있도록 추가
- **기본 아이콘 크기 상향**: 기본 `.thumb` 크기를 `80px` 기준으로 조정하고, 보드와 우측 아이템 목록에 함께 반영되도록 정리
## 2026-03-26 v0.1.25
- **export 폭 추가 축소**: 티어표 PNG export 보드 폭을 `960px`로 더 줄여 최종 저장 이미지가 지나치게 길어지지 않도록 조정
## 2026-03-26 v0.1.24
- **관리자 게임 순서 드래그 정렬 추가**: 상단 고정 게임 목록을 위/아래 버튼뿐 아니라 드래그로도 순서를 바꿀 수 있도록 보강
- **export 크기 재조정**: 티어표 PNG export를 약 `1360px` 폭과 `pixelRatio 1.5` 기준으로 낮춰 아이콘이 과도하게 한 줄에 몰리지 않도록 수정
- **업로드 정책 문서화**: 현재 아바타 `3MB`, 게임/커스텀 이미지 `6MB` 제한이 있으며 서버 저장 전 리사이즈/압축은 아직 하지 않는다는 점을 문서에 명시
## 2026-03-26 v0.1.23
- **홈 게임 정렬 규칙 변경**: 일반 게임 목록은 `상단 고정 순서 → 나머지 최신 생성순`으로 정렬되도록 변경
- **관리자 게임 순서 편집 추가**: 관리자 게임 관리 탭에서 최대 50개의 게임을 상단 고정 목록으로 선택하고 위/아래 순서를 저장할 수 있도록 추가
- **커스텀 티어표 진입점 변경**: 홈 화면의 `직접 티어표 만들기` 카드를 제거하고 우측 상단 버튼형 진입점으로 변경
## 2026-03-26 v0.1.22
- **무제목 저장 규칙 변경**: 제목을 비워두고 저장하면 내부 저장 제목을 `이름 없음 + 날짜` 형식으로 생성하도록 변경
- **무제목 안내 문구 추가**: 제목 입력이 비어 있는 동안 관리자 임의 삭제 가능성을 알리는 경고 문구를 제목 입력 아래에 표시
- **export 보드 확장**: 다운로드용 티어표 이미지는 빈 칸 안내 문구를 숨기고, 약 `1600px` 폭과 더 넉넉한 여백, 하단 작성자/날짜 메타 정보를 포함하도록 조정
## 2026-03-26 v0.1.21
- **아바타 fallback 기준 통일**: 티어표 목록에서 작성자 아바타 이미지가 없을 때 닉네임이 아니라 계정명 기준 첫 글자를 표시하도록 정리
- **저장 완료 모달 추가**: 에디터에서 저장 성공 시 반투명 오버레이와 확인 버튼이 있는 피드백 모달을 표시하도록 추가
- **다운로드 이미지 여백 보강**: PNG export 전용 보드에 외곽 패딩과 배경 여백을 넣어 콘텐츠가 가장자리에 붙어 보이지 않도록 조정
## 2026-03-19 v0.1.20
- **게임 선택 카드 순서 조정**: 홈 화면에서 일반 게임 카드를 먼저 보여주고 `직접 티어표 만들기` 카드는 마지막에 배치
- **게임 카드 3열 레이아웃**: PC 기준 게임 선택 화면 카드를 3열로 재구성하고, 썸네일을 16:9 비율로 통일
- **공개 티어표 카드 3열 레이아웃**: 게임 허브의 공개 티어표 목록도 PC 기준 3열 카드형으로 재배치하고 태블릿/모바일에서는 자동 줄바꿈되도록 조정
## 2026-03-19 v0.1.19
- **에디터 저장 영역 재정렬**: 공개 기본값을 `ON`으로 바꾸고, 액션 영역을 `이미지 다운로드 / 삭제 / 공개 ON·OFF / 저장` 흐름으로 재배치
- **에디터 삭제 진입점 추가**: 기존 티어표는 편집 화면에서 바로 삭제할 수 있도록 버튼을 추가
- **목록 작성자 표시 개선**: 공개 티어표와 내 티어표 목록의 제목 옆에 원형 아바타와 `by 닉네임(없으면 계정명)`을 표시
- **목록 메타 단순화**: 티어표 카드 하단 정보는 게임 ID, 저장 시각, 라벨 문구를 제거하고 최종 업데이트 시각만 간략하게 노출
## 2026-03-19 v0.1.18
- **미사용 아이콘 필터 수정**: 관리자 아이템 관리의 `미사용 아이콘 보기` 체크 상태가 실제 API 요청의 `orphanOnly` 파라미터로 전달되도록 수정
- **삭제 활성화 흐름 정상화**: 미사용 아이콘만 조회했을 때 `usageCount = 0` 항목의 개별 삭제 버튼이 의도대로 활성화되도록 정리
## 2026-03-19 v0.1.0
- **초기 스캐폴딩**: `frontend/`에 Vue3(Vite, JavaScript) 프로젝트 생성
- **라우팅/화면 골격**: 게임 선택(`/`), 게임 허브(`/games/:gameId`), 에디터(`/editor/:gameId/...`), 로그인(`/login`), 내 티어표(`/me`), 관리자(`/admin`) 라우트 추가
@@ -50,3 +165,60 @@
## 2026-03-19 v0.1.6
- **저장소 메타데이터 정리**: Git 작성자 정보를 프로젝트 계정 기준으로 통일하고, 초기 릴리스 커밋 메시지를 한국어 기준으로 재작성
- **버전 관리 규칙 보강**: 커밋 메시지 한국어 작성 및 문서 버전과 Git 태그를 함께 맞추는 규칙을 문서에 반영
## 2026-03-19 v0.1.7
- **AI 작업 규칙 보강**: `ai-rules.md`에 Git 작성자 정보, 한국어 커밋 메시지, 버전/태그 동기화, 민감 정보 확인 규칙 추가
- **관리자 화면 재구성**: `/admin`을 좌우 병렬 구조에서 `모드 선택 → 게임 선택/생성 → 선택된 게임 상세 관리` 흐름으로 재구성
- **관리자 삭제 기능 추가**: 등록된 게임 자체 삭제 및 등록된 아이템 개별 삭제 기능 추가
- **데이터 정합성 보강**: 관리자 아이템 삭제 시 관련 티어표의 `groups/pool` 참조를 함께 정리하도록 백엔드 로직 보강
## 2026-03-19 v0.1.8
- **관리자 업로드 UX 개선**: 썸네일과 아이템 추가 시 파일 선택 직후 미리보기 표시
- **썸네일 비율 정리**: 관리자 썸네일 미리보기와 대표 썸네일 표시를 16:9, 약 256px 폭 기준으로 조정
- **아이템 카드 레이아웃 개선**: 아이템 목록과 추가 미리보기를 1:1 비율 기준으로 재구성하고 더 촘촘한 카드 그리드로 조정
- **레거시 파일 역할 정리**: `db.json`과 lowdb 관련 코드는 현재 MariaDB 기본 런타임에는 필수가 아니며, 마이그레이션/예외 fallback 용도임을 문서에 명시
## 2026-03-19 v0.1.9
- **MariaDB 전용 전환 완료**: `backend/src/db.js`에서 lowdb 분기와 `DB_CLIENT` 기반 fallback을 제거하고 MariaDB 전용 저장 계층으로 정리
- **레거시 파일 제거**: `backend/data/db.json`, `backend/scripts/migrate-lowdb-to-mariadb.js`, `dev:lowdb/start:lowdb/migrate:lowdb` 스크립트 및 `lowdb` 의존성 제거
- **실행 문서 정리**: `README.md`, `docs/local-mariadb.md`, `docs/spec.md`, `docs/todo.md`, `docs/history.md`를 현재 MariaDB 전용 개발/배포 흐름 기준으로 갱신
## 2026-03-19 v0.1.10
- **관리자 썸네일 액션 정리**: 썸네일 버튼 문구를 `썸네일 적용`으로 바꾸고, 파일 선택 전에는 비활성화되도록 조정
- **아이템 추가 폼 정리**: 아이템 이름 입력 너비를 줄이고, 과한 미리보기 안내 문구를 제거해 작업 집중도를 높임
- **반응형 미리보기 보정**: 태블릿 이하 화면에서도 아이템 1:1 미리보기가 최대 `192px` 범위 안에서 보이도록 조정
- **파일 재선택 버그 수정**: 아이템 추가나 게임 전환 뒤 파일 입력 값을 초기화해 같은 이미지를 다시 선택해도 정상 인식되도록 수정
## 2026-03-19 v0.1.11
- **관리자 레이아웃 재구성**: 인라인 스타일을 제거하고, 썸네일 적용과 아이템 추가를 상단 2열 카드로 재배치한 뒤 아이템 목록은 하단 리스트로 분리
- **직접 티어표 만들기 추가**: 홈 화면에 게임 카드와 동일한 형태의 `직접 티어표 만들기` 진입점을 추가하고, 내부 전용 `freeform` 게임 레코드로 1회성 빈 티어표 저장 흐름을 지원
- **게임 제안 흐름 제거**: 홈 화면의 `새로운 게임 제안` 버튼/모달과 관련 프런트 API를 제거해 현재 운영 흐름에 맞게 단순화
- **커스텀 아이템 검토 영역 추가**: 관리자 페이지에서 사용자 업로드 커스텀 아이템을 목록으로 보고 다운로드할 수 있는 검토 영역과 조회 API를 추가
## 2026-03-19 v0.1.12
- **전역 레이아웃 폭 정리**: 앱 메인 영역의 고정 최대 너비를 제거해 배경과 페이지 폭이 잘린 듯 보이지 않도록 조정
- **작성 권한 제한**: 비로그인 사용자는 새 티어표 작성 화면으로 직접 진입할 수 없도록 하고, 공개된 티어표는 읽기 전용으로만 보이게 조정
- **커스텀 이미지 업로드 개선**: 에디터의 커스텀 이미지 추가 영역에 다중 파일 선택과 드래그 앤 드롭 업로드를 추가
- **회원 관리 추가**: 관리자 페이지에서 가입 회원 목록 조회, 이메일/닉네임/권한 수정, 계정 삭제가 가능한 관리 영역과 API를 추가
## 2026-03-19 v0.1.13
- **관리자 탭 구조 정리**: 관리자 페이지를 `게임 관리 / 아이템 관리 / 회원 관리` 탭으로 분리하고 기능별 작업 영역을 명확히 분리
- **커스텀 아이템 조회 강화**: 사용자 커스텀 아이템 목록에 파일명 검색, `50/200` 단위 페이지네이션, 다운로드 흐름 추가
- **회원 비밀번호 초기화 추가**: 관리자 페이지와 API에서 회원 비밀번호를 직접 재설정할 수 있도록 기능 추가
- **가변 티어 행 지원**: 티어표 에디터에서 `S~D` 고정 5단이 아니라 티어 행을 직접 추가/삭제할 수 있도록 보강
## 2026-03-19 v0.1.14
- **커스텀 아이템 카드 반응형 수정**: 관리자 아이템 관리 탭의 커스텀 아이템 카드에서 이미지 폭을 유동값으로 조정하고, 텍스트 영역에 `min-width: 0`과 강제 줄바꿈 기준을 추가해 카드 바깥 overflow를 방지
## 2026-03-19 v0.1.15
- **셀렉트 화살표 여백 정리**: 전역 `select` 스타일에 커스텀 화살표 위치와 오른쪽 여백을 추가해 텍스트와 화살표가 지나치게 붙지 않도록 조정
- **티어표 다운로드 결과 개선**: `TierEditorView`의 이미지 저장을 Blob 다운로드 방식으로 바꾸고, 캡처 대상을 보드 영역만 포함하는 전용 export 뷰로 분리해 우측 아이템 영역과 편집용 버튼/입력 UI가 저장 이미지에 섞이지 않도록 수정
## 2026-03-19 v0.1.16
- **티어표 헤더 마감 정리**: 제목/설명 입력을 각각 한 줄 폭으로 정리하고, 액션 영역과 분리해 헤더 가독성을 개선
- **export 정보 보강**: 이미지 저장 시 제목 아래에 설명이 함께 표시되도록 보강
- **보드 여백/정렬 정리**: 보드 내부 패딩을 늘리고, 티어 그룹 제목을 중앙 정렬로 조정해 완성본 느낌을 개선
## 2026-03-19 v0.1.17
- **내 티어표 삭제 추가**: `내 티어표` 목록에서 작성자가 자신의 티어표를 직접 삭제할 수 있도록 삭제 버튼과 API를 추가
- **미사용 커스텀 이미지 관리 추가**: 관리자 아이템 탭에서 커스텀 이미지의 사용 횟수를 표시하고, 미사용 항목만 따로 필터링해 개별/일괄 삭제할 수 있도록 보강

22
frontend/Dockerfile Normal file
View File

@@ -0,0 +1,22 @@
FROM node:20-alpine AS build
WORKDIR /app
COPY frontend/package*.json ./
RUN npm ci
COPY frontend/ ./
ARG VITE_API_ORIGIN=https://tmaker.sori.studio
ENV VITE_API_ORIGIN=${VITE_API_ORIGIN}
RUN npm run build
FROM nginx:1.27-alpine
COPY frontend/nginx.conf /etc/nginx/conf.d/default.conf
COPY --from=build /app/dist /usr/share/nginx/html
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]

View File

@@ -2,9 +2,12 @@
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
<link
rel="icon"
href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64'%3E%3Crect width='64' height='64' rx='16' fill='%230b1220'/%3E%3Cpath d='M18 18h28v8H36v20h-8V26H18z' fill='%23f8fafc'/%3E%3C/svg%3E"
/>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>frontend</title>
<title>Tier Maker</title>
</head>
<body>
<div id="app"></div>

38
frontend/nginx.conf Normal file
View File

@@ -0,0 +1,38 @@
server {
listen 80;
server_name _;
root /usr/share/nginx/html;
index index.html;
location / {
try_files $uri $uri/ /index.html;
}
location /api/ {
proxy_pass http://backend:5179/api/;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto https;
}
location /uploads/ {
proxy_pass http://backend:5179/uploads/;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto https;
}
location /health {
proxy_pass http://backend:5179/health;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto https;
}
}

View File

@@ -3,10 +3,12 @@ import { computed, onMounted, onUnmounted, ref, watch } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import { useAuthStore } from './stores/auth'
import { toApiUrl } from './lib/runtime'
import { useToast } from './composables/useToast'
const route = useRoute()
const router = useRouter()
const auth = useAuthStore()
const { toasts, dismissToast } = useToast()
const isAdmin = computed(() => !!auth.user?.isAdmin)
const avatarUrl = computed(() => {
if (!auth.user?.avatarSrc) return ''
@@ -58,11 +60,12 @@ async function logout() {
<header class="app-header">
<div class="brand" @click="$router.push('/')">
<span class="brand__title">Tier Maker</span>
<span class="brand__sub">Vue</span>
<span class="brand__sub">by zenn</span>
</div>
<nav class="nav">
<RouterLink to="/" class="nav__link">게임</RouterLink>
<RouterLink to="/me" class="nav__link"> 티어표</RouterLink>
<RouterLink v-if="auth.user" to="/favorites" class="nav__link">즐겨찾기</RouterLink>
<RouterLink v-if="isAdmin" to="/admin" class="nav__link">관리자</RouterLink>
<RouterLink v-if="!auth.user" to="/login" class="nav__link">로그인</RouterLink>
@@ -81,6 +84,12 @@ async function logout() {
<main class="app-main">
<RouterView />
</main>
<div class="toastStack" aria-live="polite" aria-atomic="true">
<div v-for="item in toasts" :key="item.id" class="toast" :class="`toast--${item.type}`">
<div class="toast__message">{{ item.message }}</div>
<button class="toast__close" @click="dismissToast(item.id)">닫기</button>
</div>
</div>
</div>
</template>
@@ -143,8 +152,8 @@ async function logout() {
}
.app-main {
padding: 20px 18px 60px;
max-width: 1100px;
margin: 0 auto;
width: 100%;
box-sizing: border-box;
}
.user {
@@ -198,4 +207,54 @@ async function logout() {
.menuItem:hover {
background: rgba(255, 255, 255, 0.09);
}
.toastStack {
position: fixed;
top: 78px;
right: 18px;
z-index: 30;
display: grid;
gap: 10px;
width: min(360px, calc(100vw - 24px));
}
.toast {
display: flex;
gap: 12px;
align-items: flex-start;
justify-content: space-between;
padding: 12px 14px;
border-radius: 16px;
border: 1px solid rgba(255, 255, 255, 0.12);
background: rgba(11, 18, 32, 0.94);
backdrop-filter: blur(12px);
box-shadow: 0 14px 30px rgba(0, 0, 0, 0.28);
}
.toast--success {
border-color: rgba(52, 211, 153, 0.38);
}
.toast--error {
border-color: rgba(239, 68, 68, 0.34);
}
.toast--info {
border-color: rgba(96, 165, 250, 0.34);
}
.toast__message {
line-height: 1.5;
font-size: 14px;
}
.toast__close {
flex: 0 0 auto;
border: 0;
background: transparent;
color: rgba(255, 255, 255, 0.76);
cursor: pointer;
font-weight: 800;
}
@media (max-width: 640px) {
.toastStack {
top: 70px;
right: 12px;
left: 12px;
width: auto;
}
}
</style>

View File

@@ -0,0 +1,31 @@
import { readonly, ref } from 'vue'
const toasts = ref([])
let toastSeq = 0
function dismissToast(id) {
toasts.value = toasts.value.filter((toast) => toast.id !== id)
}
function showToast(message, { type = 'info', duration = 2600 } = {}) {
if (!message) return ''
const id = `toast-${++toastSeq}`
toasts.value = [...toasts.value, { id, message, type }]
if (duration > 0) {
window.setTimeout(() => dismissToast(id), duration)
}
return id
}
export function useToast() {
return {
toasts: readonly(toasts),
dismissToast,
showToast,
success: (message, options = {}) => showToast(message, { type: 'success', ...options }),
error: (message, options = {}) => showToast(message, { type: 'error', ...options }),
info: (message, options = {}) => showToast(message, { type: 'info', ...options }),
}
}

View File

@@ -32,11 +32,58 @@ export const api = {
listGames: () => request('/api/games'),
getGame: (gameId) => request(`/api/games/${encodeURIComponent(gameId)}`),
suggestGame: (name) => request('/api/games/suggest', { method: 'POST', body: { name } }),
updateAdminGameDisplayOrder: (payload) => request('/api/admin/games/display-order', { method: 'PATCH', body: payload }),
updateAdminGameItem: (gameId, itemId, payload) =>
request(`/api/admin/games/${encodeURIComponent(gameId)}/items/${encodeURIComponent(itemId)}`, { method: 'PATCH', body: payload }),
listAdminCustomItems: ({ q = '', page = 1, limit = 50, orphanOnly = false } = {}) =>
request(
`/api/admin/custom-items?q=${encodeURIComponent(q)}&page=${encodeURIComponent(page)}&limit=${encodeURIComponent(limit)}&orphanOnly=${encodeURIComponent(orphanOnly)}`
),
listAdminTierLists: ({ q = '', page = 1, limit = 50 } = {}) =>
request(`/api/admin/tierlists?q=${encodeURIComponent(q)}&page=${encodeURIComponent(page)}&limit=${encodeURIComponent(limit)}`),
promoteAdminCustomItem: (itemId, payload) =>
request(`/api/admin/custom-items/${encodeURIComponent(itemId)}/promote`, { method: 'POST', body: payload }),
promoteAdminTierListItems: (tierListId, payload) =>
request(`/api/admin/tierlists/${encodeURIComponent(tierListId)}/promote-items`, { method: 'POST', body: payload }),
createAdminGameTemplateFromTierList: (tierListId, payload) =>
request(`/api/admin/tierlists/${encodeURIComponent(tierListId)}/create-game-template`, { method: 'POST', body: payload }),
listAdminUsers: () => request('/api/admin/users'),
updateAdminUser: (userId, payload) =>
request(`/api/admin/users/${encodeURIComponent(userId)}`, { method: 'PATCH', body: payload }),
updateAdminUserPassword: (userId, payload) =>
request(`/api/admin/users/${encodeURIComponent(userId)}/password`, { method: 'PATCH', body: payload }),
deleteAdminUser: (userId) => request(`/api/admin/users/${encodeURIComponent(userId)}`, { method: 'DELETE' }),
listPublicTierLists: (gameId) =>
request(`/api/tierlists/public?gameId=${encodeURIComponent(gameId || '')}`),
searchPublicTierLists: (gameId, q = '') =>
request(`/api/tierlists/public?gameId=${encodeURIComponent(gameId || '')}&q=${encodeURIComponent(q || '')}`),
listMyTierLists: () => request('/api/tierlists/me'),
listMyFavoriteTierLists: ({ q = '', sort = 'favorited' } = {}) =>
request(`/api/tierlists/favorites/me?q=${encodeURIComponent(q)}&sort=${encodeURIComponent(sort)}`),
getTierList: (id) => request(`/api/tierlists/${encodeURIComponent(id)}`),
favoriteTierList: (id) => request(`/api/tierlists/${encodeURIComponent(id)}/favorite`, { method: 'POST' }),
unfavoriteTierList: (id) => request(`/api/tierlists/${encodeURIComponent(id)}/favorite`, { method: 'DELETE' }),
deleteTierList: (id) => request(`/api/tierlists/${encodeURIComponent(id)}`, { method: 'DELETE' }),
saveTierList: (payload) => request('/api/tierlists', { method: 'POST', body: payload }),
uploadTierListThumbnail: async (file) => {
const fd = new FormData()
fd.append('thumbnail', file)
const res = await fetch(toApiUrl('/api/tierlists/thumbnail'), {
method: 'POST',
credentials: 'include',
body: fd,
})
const data = await res.json()
if (!res.ok) {
const err = new Error('request_failed')
err.status = res.status
err.data = data
throw err
}
return data
},
deleteAdminCustomItem: (itemId) => request(`/api/admin/custom-items/${encodeURIComponent(itemId)}`, { method: 'DELETE' }),
deleteAdminUnusedCustomItems: ({ q = '' } = {}) =>
request(`/api/admin/custom-items?q=${encodeURIComponent(q)}`, { method: 'DELETE' }),
}

View File

@@ -3,7 +3,12 @@ const FALLBACK_API_ORIGIN = 'http://localhost:5179'
export const API_ORIGIN = (import.meta.env.VITE_API_ORIGIN || FALLBACK_API_ORIGIN).replace(/\/+$/, '')
export function toApiUrl(path = '') {
if (!path) return API_ORIGIN
const p = path.startsWith('/') ? path : `/${path}`
// 운영(Nginx 프록시)에서는 같은 도메인/프로토콜로 호출해야
// 세션 쿠키(`Set-Cookie`)가 브라우저에 정상 저장됩니다.
if (import.meta.env.PROD) return p
if (/^https?:\/\//.test(path)) return path
return `${API_ORIGIN}${path.startsWith('/') ? path : `/${path}`}`
return `${API_ORIGIN}${p}`
}

View File

@@ -5,6 +5,7 @@ import GameHubView from '../views/GameHubView.vue'
import TierEditorView from '../views/TierEditorView.vue'
import LoginView from '../views/LoginView.vue'
import MyTierListsView from '../views/MyTierListsView.vue'
import FavoriteTierListsView from '../views/FavoriteTierListsView.vue'
import AdminView from '../views/AdminView.vue'
import ProfileView from '../views/ProfileView.vue'
@@ -18,9 +19,9 @@ export function createRouter() {
{ path: '/editor/:gameId/:tierListId', name: 'editEditor', component: TierEditorView },
{ path: '/login', name: 'login', component: LoginView },
{ path: '/me', name: 'me', component: MyTierListsView },
{ path: '/favorites', name: 'favorites', component: FavoriteTierListsView },
{ path: '/admin', name: 'admin', component: AdminView },
{ path: '/profile', name: 'profile', component: ProfileView },
],
})
}

View File

@@ -54,6 +54,21 @@ body {
margin: 0;
}
select {
appearance: none;
-webkit-appearance: none;
-moz-appearance: none;
background-image:
linear-gradient(45deg, transparent 50%, rgba(255, 255, 255, 0.78) 50%),
linear-gradient(135deg, rgba(255, 255, 255, 0.78) 50%, transparent 50%);
background-position:
calc(100% - 18px) calc(50% - 2px),
calc(100% - 12px) calc(50% - 2px);
background-size: 6px 6px, 6px 6px;
background-repeat: no-repeat;
padding-right: 36px;
}
h1,
h2 {
font-family: var(--heading);
@@ -157,7 +172,7 @@ code {
}
#app {
width: 1126px;
/* width: 1126px; */
max-width: 100%;
margin: 0 auto;
text-align: center;

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,269 @@
<script setup>
import { onMounted, ref } from 'vue'
import { useRouter } from 'vue-router'
import { api } from '../lib/api'
import { toApiUrl } from '../lib/runtime'
import { useToast } from '../composables/useToast'
const router = useRouter()
const toast = useToast()
const favorites = ref([])
const query = ref('')
const sort = ref('favorited')
function fmt(ts) {
return new Date(ts).toLocaleString(undefined, {
year: 'numeric',
month: '2-digit',
day: '2-digit',
hour: '2-digit',
minute: '2-digit',
})
}
function displayNameOf(tierList) {
return tierList.authorName || '알 수 없음'
}
function avatarSrcOf(tierList) {
return tierList.authorAvatarSrc ? toApiUrl(tierList.authorAvatarSrc) : ''
}
function avatarFallbackOf(tierList) {
return (tierList.authorAccountName || 'u').trim().charAt(0).toUpperCase() || '?'
}
function tierListThumbnailUrl(tierList) {
return tierList.thumbnailSrc ? toApiUrl(tierList.thumbnailSrc) : ''
}
async function loadFavorites() {
try {
const data = await api.listMyFavoriteTierLists({ q: query.value, sort: sort.value })
favorites.value = data.tierLists || []
} catch (e) {
toast.error('로그인이 필요해요.')
router.push('/login?redirect=/favorites')
}
}
function openTierList(tierList) {
router.push(`/editor/${tierList.gameId}/${tierList.id}`)
}
async function unfavorite(tierList) {
try {
await api.unfavoriteTierList(tierList.id)
favorites.value = favorites.value.filter((entry) => entry.id !== tierList.id)
toast.success('즐겨찾기를 해제했어요.')
} catch (e) {
toast.error('즐겨찾기 해제에 실패했어요.')
}
}
onMounted(loadFavorites)
</script>
<template>
<section class="wrap">
<div class="head">
<div>
<h2 class="title"> 즐겨찾기</h2>
<div class="desc">마음에 드는 티어표를 모아보고, 원하는 기준으로 정렬할 있어요.</div>
</div>
<div class="toolbar">
<input v-model="query" class="input" placeholder="제목, 게임, 작성자 검색" @keydown.enter.prevent="loadFavorites" />
<select v-model="sort" class="select" @change="loadFavorites">
<option value="favorited">즐겨찾기한 </option>
<option value="updated">최신 업데이트순</option>
<option value="favorites">인기순</option>
</select>
<button class="btn" @click="loadFavorites">검색</button>
</div>
</div>
<div v-if="favorites.length === 0" class="empty">즐겨찾기한 티어표가 없어요.</div>
<div v-else class="list">
<article v-for="tierList in favorites" :key="tierList.id" class="row">
<button class="row__body" @click="openTierList(tierList)">
<div class="row__thumbWrap">
<img v-if="tierListThumbnailUrl(tierList)" class="row__thumb" :src="tierListThumbnailUrl(tierList)" :alt="tierList.title" />
<div v-else class="row__thumbPlaceholder"></div>
</div>
<div class="row__head">
<div class="row__title">{{ tierList.title }}</div>
<div class="row__author">
<img v-if="avatarSrcOf(tierList)" class="row__avatar" :src="avatarSrcOf(tierList)" :alt="displayNameOf(tierList)" />
<div v-else class="row__avatar row__avatar--fallback">{{ avatarFallbackOf(tierList) }}</div>
<span>by {{ displayNameOf(tierList) }}</span>
</div>
</div>
</button>
<div class="row__foot">
<div class="row__meta">
<div>{{ tierList.gameName || tierList.gameId }}</div>
<div>{{ fmt(sort === 'favorited' ? tierList.favoritedAt : tierList.updatedAt) }}</div>
</div>
<button class="favoriteBtn" @click="unfavorite(tierList)"> {{ tierList.favoriteCount || 0 }}</button>
</div>
</article>
</div>
</section>
</template>
<style scoped>
.wrap {
display: grid;
gap: 14px;
}
.head {
display: flex;
gap: 14px;
justify-content: space-between;
align-items: flex-end;
flex-wrap: wrap;
}
.title {
margin: 0;
font-size: 28px;
}
.desc {
margin-top: 6px;
opacity: 0.78;
}
.toolbar {
display: flex;
gap: 10px;
flex-wrap: wrap;
}
.input,
.select {
padding: 10px 12px;
border-radius: 12px;
border: 1px solid rgba(255, 255, 255, 0.12);
background: rgba(0, 0, 0, 0.18);
color: rgba(255, 255, 255, 0.92);
}
.btn {
padding: 10px 12px;
border-radius: 12px;
border: 1px solid rgba(255, 255, 255, 0.14);
background: rgba(255, 255, 255, 0.06);
color: rgba(255, 255, 255, 0.92);
font-weight: 800;
cursor: pointer;
}
.empty {
opacity: 0.76;
}
.list {
display: grid;
grid-template-columns: repeat(3, minmax(0, 1fr));
gap: 14px;
}
.row {
border-radius: 16px;
border: 1px solid rgba(255, 255, 255, 0.12);
background: rgba(255, 255, 255, 0.04);
overflow: hidden;
display: grid;
gap: 10px;
}
.row__body {
border: 0;
background: transparent;
color: inherit;
padding: 0;
text-align: left;
cursor: pointer;
display: grid;
gap: 10px;
}
.row__thumbWrap {
width: 100%;
aspect-ratio: 16 / 9;
background: rgba(255, 255, 255, 0.03);
}
.row__thumb,
.row__thumbPlaceholder {
width: 100%;
height: 100%;
display: block;
}
.row__thumb {
object-fit: cover;
}
.row__thumbPlaceholder {
background: linear-gradient(135deg, rgba(255,255,255,0.06), rgba(255,255,255,0.02));
}
.row__head {
padding: 14px 14px 0;
display: grid;
gap: 10px;
}
.row__title {
font-weight: 800;
font-size: 18px;
}
.row__author {
display: inline-flex;
align-items: center;
gap: 8px;
font-size: 13px;
opacity: 0.86;
}
.row__avatar {
width: 28px;
height: 28px;
border-radius: 999px;
object-fit: cover;
background: rgba(255, 255, 255, 0.08);
}
.row__avatar--fallback {
display: grid;
place-items: center;
font-size: 12px;
font-weight: 900;
}
.row__foot {
padding: 0 14px 14px;
display: flex;
gap: 12px;
align-items: center;
justify-content: space-between;
}
.row__meta {
display: grid;
gap: 4px;
opacity: 0.78;
font-size: 13px;
}
.favoriteBtn {
border: 1px solid rgba(255, 255, 255, 0.12);
background: rgba(255, 255, 255, 0.05);
color: rgba(255, 255, 255, 0.92);
border-radius: 999px;
padding: 7px 10px;
cursor: pointer;
font-weight: 800;
}
@media (max-width: 1100px) {
.list {
grid-template-columns: repeat(2, minmax(0, 1fr));
}
}
@media (max-width: 720px) {
.list {
grid-template-columns: 1fr;
}
.toolbar {
width: 100%;
}
.input,
.select,
.btn {
width: 100%;
}
}
</style>

View File

@@ -2,15 +2,21 @@
import { computed, onMounted, ref } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import { api } from '../lib/api'
import { toApiUrl } from '../lib/runtime'
import { useAuthStore } from '../stores/auth'
import { useToast } from '../composables/useToast'
const route = useRoute()
const router = useRouter()
const auth = useAuthStore()
const toast = useToast()
const gameId = computed(() => route.params.gameId)
const gameName = ref('')
const tierLists = ref([])
const error = ref('')
const query = ref('')
function fmt(ts) {
return new Date(ts).toLocaleString(undefined, {
@@ -19,27 +25,72 @@ function fmt(ts) {
day: '2-digit',
hour: '2-digit',
minute: '2-digit',
second: '2-digit',
})
}
function displayNameOf(tierList) {
return tierList.authorName || '알 수 없음'
}
function avatarSrcOf(tierList) {
return tierList.authorAvatarSrc ? toApiUrl(tierList.authorAvatarSrc) : ''
}
function avatarFallbackOf(tierList) {
return (tierList.authorAccountName || 'u').trim().charAt(0).toUpperCase() || '?'
}
function tierListThumbnailUrl(tierList) {
return tierList.thumbnailSrc ? toApiUrl(tierList.thumbnailSrc) : ''
}
onMounted(async () => {
await loadTierLists()
})
async function loadTierLists() {
try {
const [gameRes, listRes] = await Promise.all([api.getGame(gameId.value), api.listPublicTierLists(gameId.value)])
const [gameRes, listRes] = await Promise.all([
api.getGame(gameId.value),
api.searchPublicTierLists(gameId.value, query.value),
])
gameName.value = gameRes.game?.name || gameId.value
tierLists.value = listRes.tierLists || []
} catch (e) {
error.value = '게임 정보를 불러오지 못했어요.'
}
})
}
function createNew() {
if (!auth.user) {
router.push(`/login?redirect=/editor/${gameId.value}/new`)
return
}
router.push(`/editor/${gameId.value}/new`)
}
function openTierList(id) {
router.push(`/editor/${gameId.value}/${id}`)
}
async function toggleFavorite(tierList) {
if (!auth.user) {
router.push(`/login?redirect=/games/${gameId.value}`)
return
}
try {
const data = tierList.isFavorited ? await api.unfavoriteTierList(tierList.id) : await api.favoriteTierList(tierList.id)
tierLists.value = tierLists.value.map((entry) => (entry.id === tierList.id ? { ...entry, ...data.tierList } : entry))
toast.success(tierList.isFavorited ? '즐겨찾기를 해제했어요.' : '즐겨찾기에 추가했어요.')
} catch (e) {
toast.error('즐겨찾기 처리에 실패했어요.')
}
}
function submitSearch() {
loadTierLists()
}
</script>
<template>
@@ -50,21 +101,43 @@ function openTierList(id) {
<p class="desc"> 티어표를 만들거나, 다른 사람들이 올린 티어표를 확인하세요.</p>
</div>
<div class="head__right">
<button class="primary" @click="createNew">새로운 티어표 만들기</button>
<button class="primary" @click="createNew">{{ auth.user ? '새로운 티어표 만들기' : '로그인 티어표 만들기' }}</button>
</div>
</section>
<div v-if="error" class="error">{{ error }}</div>
<section class="panel">
<div class="panel__title">공개 티어표</div>
<div class="panel__head">
<div class="panel__title">공개 티어표</div>
<div class="searchBar">
<input v-model="query" class="searchBar__input" placeholder="제목 또는 작성자 검색" @keydown.enter.prevent="submitSearch" />
<button class="searchBar__button" @click="submitSearch">검색</button>
</div>
</div>
<div v-if="tierLists.length === 0" class="empty">아직 공개 티어표가 없어요.</div>
<div v-else class="list">
<button v-for="t in tierLists" :key="t.id" class="row" @click="openTierList(t.id)">
<div class="row__title">{{ t.title }}</div>
<div class="row__meta">
작성자: {{ t.authorName || '알 수 없음' }} · 저장: {{ fmt(t.createdAt || t.updatedAt) }} · 업데이트: {{ fmt(t.updatedAt) }}
<article v-for="t in tierLists" :key="t.id" class="row">
<button class="row__body" @click="openTierList(t.id)">
<div class="row__thumbWrap">
<img v-if="tierListThumbnailUrl(t)" class="row__thumb" :src="tierListThumbnailUrl(t)" :alt="t.title" />
<div v-else class="row__thumbPlaceholder"></div>
</div>
<div class="row__head">
<div class="row__title">{{ t.title }}</div>
<div class="row__author">
<img v-if="avatarSrcOf(t)" class="row__avatar" :src="avatarSrcOf(t)" :alt="displayNameOf(t)" />
<div v-else class="row__avatar row__avatar--fallback">{{ avatarFallbackOf(t) }}</div>
<span>by {{ displayNameOf(t) }}</span>
</div>
</div>
</button>
<div class="row__foot">
<div class="row__meta">{{ fmt(t.updatedAt) }}</div>
<button class="favoriteBtn" @click="toggleFavorite(t)">
{{ t.isFavorited ? '' : '' }} {{ t.favoriteCount || 0 }}
</button>
</div>
</button>
</article>
</div>
</section>
</template>
@@ -118,33 +191,158 @@ function openTierList(id) {
}
.panel__title {
font-weight: 800;
}
.panel__head {
display: flex;
gap: 12px;
align-items: center;
justify-content: space-between;
flex-wrap: wrap;
margin-bottom: 10px;
}
.searchBar {
display: flex;
gap: 10px;
align-items: center;
flex-wrap: wrap;
}
.searchBar__input {
min-width: 240px;
padding: 10px 12px;
border-radius: 12px;
border: 1px solid rgba(255, 255, 255, 0.12);
background: rgba(0, 0, 0, 0.18);
color: rgba(255, 255, 255, 0.92);
}
.searchBar__button {
padding: 10px 12px;
border-radius: 12px;
border: 1px solid rgba(255, 255, 255, 0.14);
background: rgba(255, 255, 255, 0.06);
color: rgba(255, 255, 255, 0.92);
font-weight: 800;
cursor: pointer;
}
.empty {
opacity: 0.75;
}
.list {
display: grid;
gap: 10px;
grid-template-columns: repeat(3, minmax(0, 1fr));
gap: 14px;
}
.row {
text-align: left;
padding: 12px;
border-radius: 14px;
border-radius: 16px;
border: 1px solid rgba(255, 255, 255, 0.12);
background: rgba(255, 255, 255, 0.03);
background: rgba(255, 255, 255, 0.04);
color: rgba(255, 255, 255, 0.92);
cursor: pointer;
display: grid;
gap: 10px;
align-content: start;
min-height: 168px;
overflow: hidden;
}
.row:hover {
background: rgba(255, 255, 255, 0.05);
}
.row__body {
text-align: left;
padding: 0;
border: 0;
background: transparent;
color: inherit;
cursor: pointer;
width: 100%;
display: grid;
gap: 10px;
}
.row__thumbWrap {
width: 100%;
aspect-ratio: 16 / 9;
background: rgba(255, 255, 255, 0.03);
}
.row__thumb {
width: 100%;
height: 100%;
object-fit: cover;
display: block;
}
.row__thumbPlaceholder {
width: 100%;
height: 100%;
background:
linear-gradient(135deg, rgba(255,255,255,0.06), rgba(255,255,255,0.02));
}
.row__title {
font-weight: 800;
min-width: 0;
font-size: 18px;
line-height: 1.35;
}
.row__head {
padding: 14px 14px 0;
display: grid;
gap: 12px;
align-content: start;
}
.row__author {
display: inline-flex;
gap: 8px;
align-items: center;
font-size: 13px;
opacity: 0.86;
flex: 0 0 auto;
}
.row__avatar {
width: 28px;
height: 28px;
border-radius: 999px;
object-fit: cover;
border: 1px solid rgba(255, 255, 255, 0.12);
background: rgba(255, 255, 255, 0.08);
}
.row__avatar--fallback {
display: grid;
place-items: center;
font-size: 12px;
font-weight: 900;
}
.row__meta {
opacity: 0.78;
margin-top: 6px;
font-size: 13px;
}
.row__foot {
padding: 0 14px 14px;
display: flex;
gap: 12px;
align-items: center;
justify-content: space-between;
margin-top: auto;
}
.favoriteBtn {
border: 1px solid rgba(255, 255, 255, 0.12);
background: rgba(255, 255, 255, 0.05);
color: rgba(255, 255, 255, 0.92);
border-radius: 999px;
padding: 7px 10px;
cursor: pointer;
font-weight: 800;
}
.favoriteBtn:hover {
background: rgba(255, 255, 255, 0.09);
}
@media (max-width: 1100px) {
.list {
grid-template-columns: repeat(2, minmax(0, 1fr));
}
}
@media (max-width: 720px) {
.list {
grid-template-columns: 1fr;
}
.searchBar__input {
min-width: 0;
width: 100%;
}
}
</style>

View File

@@ -3,15 +3,14 @@ import { computed, onMounted, ref } from 'vue'
import { useRouter } from 'vue-router'
import { api } from '../lib/api'
import { toApiUrl } from '../lib/runtime'
import { useAuthStore } from '../stores/auth'
const router = useRouter()
const auth = useAuthStore()
const items = ref([])
const error = ref('')
const games = computed(() => items.value)
const suggestOpen = ref(false)
const suggestName = ref('')
const suggestError = ref('')
const games = computed(() => items.value.filter((item) => item.id !== 'freeform'))
onMounted(async () => {
try {
@@ -26,37 +25,28 @@ function goGame(gameId) {
router.push(`/games/${gameId}`)
}
function goFreeform() {
if (!auth.user) {
router.push('/login?redirect=/editor/freeform/new')
return
}
router.push('/editor/freeform/new')
}
function thumbUrl(g) {
if (!g.thumbnailSrc) return ''
return toApiUrl(g.thumbnailSrc)
}
async function submitSuggest() {
suggestError.value = ''
const name = (suggestName.value || '').trim()
if (!name) {
suggestError.value = '게임 이름을 입력해주세요.'
return
}
try {
await api.suggestGame(name)
suggestName.value = ''
suggestOpen.value = false
} catch (e) {
suggestError.value = '제안 전송에 실패했어요.'
}
}
</script>
<template>
<section class="hero">
<h1 class="hero__title">티어표 메이커</h1>
<p class="hero__desc">
게임을 선택하면 티어표를 만들거나, 다른 사람들이 올린 티어표를 있어요.
</p>
<div class="hero__actions">
<button class="smallBtn" @click="suggestOpen = true">새로운 게임 제안</button>
<section class="topBar">
<div class="topBar__copy">
<h1 class="topBar__title">게임 선택</h1>
<p class="topBar__desc">관리자 고정 순서가 있으면 먼저 보여주고, 게임은 최근 생성순으로 정렬됩니다.</p>
</div>
<button class="customTierBtn" @click="goFreeform">{{ auth.user ? '커스텀 티어표 만들기' : '로그인 커스텀 티어표 만들기' }}</button>
</section>
<div v-if="error" class="error">{{ error }}</div>
@@ -69,59 +59,43 @@ async function submitSuggest() {
<div class="card__title">{{ g.name }}</div>
</button>
</section>
<div v-if="suggestOpen" class="modalBack" @click.self="suggestOpen = false">
<div class="modal">
<div class="modal__title">새로운 게임 제안</div>
<div class="modal__desc">목록에 없는 게임을 입력해 주세요. (관리자가 확인 추가)</div>
<input v-model="suggestName" class="modal__input" placeholder="게임 이름" @keydown.enter.prevent="submitSuggest" />
<div v-if="suggestError" class="modal__error">{{ suggestError }}</div>
<div class="modal__actions">
<button class="smallBtn" @click="suggestOpen = false">닫기</button>
<button class="smallBtn smallBtn--primary" @click="submitSuggest">제안하기</button>
</div>
</div>
</div>
</template>
<style scoped>
.hero {
padding: 18px 2px 14px;
.topBar {
display: flex;
gap: 16px;
justify-content: space-between;
align-items: flex-start;
flex-wrap: wrap;
margin-top: 4px;
}
.hero__title {
font-size: 34px;
letter-spacing: -0.03em;
margin: 0 0 8px;
.topBar__copy {
display: grid;
gap: 6px;
}
.hero__desc {
.topBar__title {
margin: 0;
opacity: 0.86;
font-size: 30px;
letter-spacing: -0.03em;
}
.topBar__desc {
margin: 0;
opacity: 0.78;
line-height: 1.5;
}
.hero__actions {
margin-top: 12px;
}
.smallBtn {
padding: 8px 10px;
border-radius: 12px;
border: 1px solid rgba(255, 255, 255, 0.14);
background: rgba(255, 255, 255, 0.06);
color: rgba(255, 255, 255, 0.92);
.customTierBtn {
padding: 12px 16px;
border-radius: 14px;
border: 1px solid rgba(96, 165, 250, 0.28);
background: linear-gradient(135deg, rgba(96, 165, 250, 0.2), rgba(16, 185, 129, 0.16));
color: rgba(255, 255, 255, 0.96);
font-weight: 900;
cursor: pointer;
font-weight: 800;
}
.smallBtn:hover {
background: rgba(255, 255, 255, 0.08);
}
.smallBtn--primary {
background: rgba(96, 165, 250, 0.18);
}
.smallBtn--primary:hover {
background: rgba(96, 165, 250, 0.24);
}
.grid {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
grid-template-columns: repeat(3, minmax(0, 1fr));
gap: 14px;
margin-top: 14px;
}
@@ -150,7 +124,7 @@ async function submitSuggest() {
}
.thumbWrap {
width: 100%;
height: 140px;
aspect-ratio: 16 / 9;
border-radius: 14px;
border: 1px solid rgba(255, 255, 255, 0.12);
background: rgba(0, 0, 0, 0.18);
@@ -172,58 +146,20 @@ async function submitSuggest() {
font-weight: 800;
letter-spacing: -0.02em;
}
.modalBack {
position: fixed;
inset: 0;
background: rgba(0, 0, 0, 0.55);
display: grid;
place-items: center;
z-index: 50;
}
.modal {
width: min(520px, 92vw);
border-radius: 16px;
border: 1px solid rgba(255, 255, 255, 0.14);
background: rgba(11, 18, 32, 0.92);
backdrop-filter: blur(10px);
padding: 14px;
}
.modal__title {
font-weight: 900;
font-size: 18px;
}
.modal__desc {
margin-top: 6px;
opacity: 0.78;
font-size: 13px;
}
.modal__input {
margin-top: 12px;
width: 100%;
padding: 10px 12px;
border-radius: 12px;
border: 1px solid rgba(255, 255, 255, 0.12);
background: rgba(0, 0, 0, 0.18);
color: rgba(255, 255, 255, 0.92);
outline: none;
box-sizing: border-box;
}
.modal__error {
margin-top: 10px;
padding: 10px 12px;
border-radius: 12px;
border: 1px solid rgba(239, 68, 68, 0.3);
background: rgba(239, 68, 68, 0.12);
}
.modal__actions {
margin-top: 12px;
display: flex;
justify-content: flex-end;
gap: 8px;
}
@media (max-width: 720px) {
.topBar {
align-items: stretch;
}
.customTierBtn {
width: 100%;
}
.grid {
grid-template-columns: 1fr;
}
}
@media (min-width: 721px) and (max-width: 1100px) {
.grid {
grid-template-columns: repeat(2, minmax(0, 1fr));
}
}
</style>

View File

@@ -1,11 +1,14 @@
<script setup>
import { onMounted, ref } from 'vue'
import { useRouter } from 'vue-router'
import { onMounted, ref, watch } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import { useAuthStore } from '../stores/auth'
import { api } from '../lib/api'
import { useToast } from '../composables/useToast'
const router = useRouter()
const route = useRoute()
const auth = useAuthStore()
const toast = useToast()
const email = ref('')
const password = ref('')
@@ -13,6 +16,12 @@ const mode = ref('login')
const error = ref('')
const hasUsers = ref(true)
watch(error, (message) => {
if (!message) return
toast.error(message)
error.value = ''
})
onMounted(async () => {
try {
const meta = await api.authMeta()
@@ -27,7 +36,7 @@ async function submit() {
try {
if (mode.value === 'signup') await auth.signup(email.value, password.value)
else await auth.login(email.value, password.value)
router.push('/me')
router.push(typeof route.query.redirect === 'string' ? route.query.redirect : '/me')
} catch (e) {
error.value = '로그인/회원가입에 실패했어요.'
}
@@ -45,9 +54,6 @@ async function submit() {
회원가입
</button>
</div>
<div v-if="error" class="error">{{ error }}</div>
<label class="label">이메일</label>
<input v-model="email" class="input" placeholder="you@example.com" autocomplete="email" />
@@ -102,13 +108,6 @@ async function submit() {
background: rgba(96, 165, 250, 0.18);
border-color: rgba(255, 255, 255, 0.16);
}
.error {
margin-bottom: 10px;
padding: 10px 12px;
border-radius: 12px;
border: 1px solid rgba(239, 68, 68, 0.3);
background: rgba(239, 68, 68, 0.12);
}
.label {
display: block;
font-size: 13px;
@@ -146,4 +145,3 @@ async function submit() {
font-size: 13px;
}
</style>

View File

@@ -1,12 +1,21 @@
<script setup>
import { onMounted, ref } from 'vue'
import { onMounted, ref, watch } from 'vue'
import { useRouter } from 'vue-router'
import { api } from '../lib/api'
import { toApiUrl } from '../lib/runtime'
import { useToast } from '../composables/useToast'
const router = useRouter()
const toast = useToast()
const myLists = ref([])
const error = ref('')
watch(error, (message) => {
if (!message) return
toast.error(message)
error.value = ''
})
function fmt(ts) {
return new Date(ts).toLocaleString(undefined, {
year: 'numeric',
@@ -14,40 +23,77 @@ function fmt(ts) {
day: '2-digit',
hour: '2-digit',
minute: '2-digit',
second: '2-digit',
})
}
function displayNameOf(tierList) {
return tierList.authorName || '알 수 없음'
}
function avatarSrcOf(tierList) {
return tierList.authorAvatarSrc ? toApiUrl(tierList.authorAvatarSrc) : ''
}
function avatarFallbackOf(tierList) {
return (tierList.authorAccountName || 'u').trim().charAt(0).toUpperCase() || '?'
}
function tierListThumbnailUrl(tierList) {
return tierList.thumbnailSrc ? toApiUrl(tierList.thumbnailSrc) : ''
}
onMounted(async () => {
try {
const data = await api.listMyTierLists()
myLists.value = data.tierLists || []
} catch (e) {
error.value = '로그인이 필요해요.'
toast.error('로그인이 필요해요.')
router.push('/login?redirect=/me')
}
})
function openList(t) {
router.push(`/editor/${t.gameId}/${t.id}`)
}
async function removeList(t) {
error.value = ''
try {
const ok = window.confirm(`"${t.title}" 티어표를 삭제할까요?`)
if (!ok) return
await api.deleteTierList(t.id)
myLists.value = myLists.value.filter((entry) => entry.id !== t.id)
toast.success('티어표를 삭제했어요.')
} catch (e) {
error.value = '티어표 삭제에 실패했어요.'
}
}
</script>
<template>
<section class="wrap">
<h2 class="title"> 티어표</h2>
<div class="card">
<div v-if="error" class="error">
{{ error }}
<button class="link" @click="$router.push('/login')">로그인 하러가기</button>
</div>
<div v-if="myLists.length === 0" class="empty">아직 저장한 티어표가 없어요.</div>
<div v-else class="list">
<button v-for="t in myLists" :key="t.id" class="row" @click="openList(t)">
<div class="row__title">{{ t.title }}</div>
<div class="row__meta">
{{ t.gameId }} · 저장: {{ fmt(t.createdAt || t.updatedAt) }} · 업데이트: {{ fmt(t.updatedAt) }}
</div>
</button>
<article v-for="t in myLists" :key="t.id" class="row">
<button class="row__body" @click="openList(t)">
<div class="row__thumbWrap">
<img v-if="tierListThumbnailUrl(t)" class="row__thumb" :src="tierListThumbnailUrl(t)" :alt="t.title" />
<div v-else class="row__thumbPlaceholder"></div>
</div>
<div class="row__head">
<div class="row__title">{{ t.title }}</div>
<div class="row__author">
<img v-if="avatarSrcOf(t)" class="row__avatar" :src="avatarSrcOf(t)" :alt="displayNameOf(t)" />
<div v-else class="row__avatar row__avatar--fallback">{{ avatarFallbackOf(t) }}</div>
<span>by {{ displayNameOf(t) }}</span>
</div>
</div>
<div class="row__meta">{{ fmt(t.updatedAt) }}</div>
</button>
<button class="link link--danger" @click="removeList(t)">삭제</button>
</article>
</div>
</div>
</section>
@@ -68,17 +114,6 @@ function openList(t) {
border-radius: 16px;
padding: 14px;
}
.error {
margin-bottom: 12px;
padding: 10px 12px;
border-radius: 12px;
border: 1px solid rgba(239, 68, 68, 0.3);
background: rgba(239, 68, 68, 0.12);
display: flex;
gap: 10px;
align-items: center;
justify-content: space-between;
}
.link {
padding: 8px 10px;
border-radius: 10px;
@@ -93,24 +128,99 @@ function openList(t) {
}
.list {
display: grid;
gap: 10px;
grid-template-columns: repeat(3, minmax(0, 1fr));
gap: 14px;
}
.row {
text-align: left;
cursor: pointer;
padding: 12px;
display: grid;
gap: 10px;
border-radius: 14px;
border: 1px solid rgba(255, 255, 255, 0.10);
background: rgba(0, 0, 0, 0.16);
color: rgba(255, 255, 255, 0.92);
overflow: hidden;
}
.row__body {
flex: 1 1 auto;
min-width: 0;
text-align: left;
cursor: pointer;
border: 0;
background: transparent;
color: inherit;
padding: 0;
display: grid;
gap: 10px;
}
.row__thumbWrap {
width: 100%;
aspect-ratio: 16 / 9;
background: rgba(255, 255, 255, 0.03);
}
.row__thumb {
width: 100%;
height: 100%;
object-fit: cover;
display: block;
}
.row__thumbPlaceholder {
width: 100%;
height: 100%;
background:
linear-gradient(135deg, rgba(255,255,255,0.06), rgba(255,255,255,0.02));
}
.row__title {
font-weight: 900;
min-width: 0;
}
.row__head {
padding: 0 14px;
display: flex;
gap: 12px;
align-items: center;
justify-content: space-between;
flex-wrap: wrap;
}
.row__author {
display: inline-flex;
gap: 8px;
align-items: center;
font-size: 13px;
opacity: 0.84;
}
.row__avatar {
width: 28px;
height: 28px;
border-radius: 999px;
object-fit: cover;
border: 1px solid rgba(255, 255, 255, 0.12);
background: rgba(255, 255, 255, 0.08);
}
.row__avatar--fallback {
display: grid;
place-items: center;
font-size: 12px;
font-weight: 900;
}
.row__meta {
padding: 0 14px;
margin-top: 6px;
opacity: 0.76;
font-size: 13px;
}
.link--danger {
background: rgba(239, 68, 68, 0.14);
border-color: rgba(239, 68, 68, 0.28);
margin: 0 14px 14px;
}
@media (max-width: 1100px) {
.list {
grid-template-columns: repeat(2, minmax(0, 1fr));
}
}
@media (max-width: 720px) {
.list {
grid-template-columns: 1fr;
}
}
</style>

View File

@@ -1,11 +1,13 @@
<script setup>
import { computed, onMounted, ref } from 'vue'
import { computed, onMounted, ref, watch } from 'vue'
import { useRouter } from 'vue-router'
import { useAuthStore } from '../stores/auth'
import { toApiUrl } from '../lib/runtime'
import { useToast } from '../composables/useToast'
const router = useRouter()
const auth = useAuthStore()
const toast = useToast()
const error = ref('')
const saving = ref(false)
@@ -13,6 +15,12 @@ const nickname = ref('')
const previewUrl = ref('')
const avatarFile = ref(null)
watch(error, (message) => {
if (!message) return
toast.error(message)
error.value = ''
})
const avatarUrl = computed(() => {
if (previewUrl.value) return previewUrl.value
if (!auth.user?.avatarSrc) return ''
@@ -55,6 +63,7 @@ async function saveProfile() {
URL.revokeObjectURL(previewUrl.value)
previewUrl.value = ''
}
toast.success('프로필을 저장했어요.')
} catch (e2) {
error.value = '프로필 저장에 실패했어요.'
} finally {
@@ -66,7 +75,6 @@ async function saveProfile() {
<template>
<section class="wrap">
<h2 class="title">프로필</h2>
<div v-if="error" class="error">{{ error }}</div>
<div class="card" v-if="auth.user">
<div class="row">
@@ -102,13 +110,6 @@ async function saveProfile() {
font-size: 26px;
letter-spacing: -0.02em;
}
.error {
margin-bottom: 10px;
padding: 10px 12px;
border-radius: 12px;
border: 1px solid rgba(239, 68, 68, 0.3);
background: rgba(239, 68, 68, 0.12);
}
.card {
max-width: 520px;
border: 1px solid rgba(255, 255, 255, 0.12);

File diff suppressed because it is too large Load Diff

28
package-lock.json generated
View File

@@ -13,7 +13,6 @@
"cors": "^2.8.6",
"express": "^5.2.1",
"express-session": "^1.19.0",
"lowdb": "^7.0.1",
"multer": "^2.1.1",
"nanoid": "^5.1.7",
"session-file-store": "^1.5.0",
@@ -839,21 +838,6 @@
"node": ">6"
}
},
"node_modules/lowdb": {
"version": "7.0.1",
"resolved": "https://registry.npmjs.org/lowdb/-/lowdb-7.0.1.tgz",
"integrity": "sha512-neJAj8GwF0e8EpycYIDFqEPcx9Qz4GUho20jWFR7YiFeXzF1YMLdxB36PypcTSPMA+4+LvgyMacYhlr18Zlymw==",
"license": "MIT",
"dependencies": {
"steno": "^4.0.2"
},
"engines": {
"node": ">=18"
},
"funding": {
"url": "https://github.com/sponsors/typicode"
}
},
"node_modules/math-intrinsics": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz",
@@ -1475,18 +1459,6 @@
"node": ">= 0.8"
}
},
"node_modules/steno": {
"version": "4.0.2",
"resolved": "https://registry.npmjs.org/steno/-/steno-4.0.2.tgz",
"integrity": "sha512-yhPIQXjrlt1xv7dyPQg2P17URmXbuM5pdGkpiMB3RenprfiBlvK415Lctfe0eshk90oA7/tNq7WEiMK8RSP39A==",
"license": "MIT",
"engines": {
"node": ">=18"
},
"funding": {
"url": "https://github.com/sponsors/typicode"
}
},
"node_modules/streamsearch": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/streamsearch/-/streamsearch-1.1.0.tgz",

View File

@@ -15,7 +15,6 @@
"cors": "^2.8.6",
"express": "^5.2.1",
"express-session": "^1.19.0",
"lowdb": "^7.0.1",
"multer": "^2.1.1",
"nanoid": "^5.1.7",
"session-file-store": "^1.5.0",