Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# 코멘트 저장소 (Turso / libSQL)
# Vercel 프로젝트 환경변수에도 동일하게 등록하세요.
TURSO_DATABASE_URL=libsql://your-db.turso.io
TURSO_AUTH_TOKEN=your-turso-auth-token

# IP 해시용 솔트 (레이트리밋/중복 판별에만 사용, 원본 IP는 저장하지 않음)
COMMENT_IP_SALT=change-me
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ yarn-error.log*

.cached

# local comment db (libSQL/Turso dev)
comments.db
comments.db-*

dist
.astro
public/search-db.json
Expand Down
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,27 @@ CREATE TABLE link (
url TEXT NOT NULL
);
```

## 코멘트

메모별 코멘트는 별도 libSQL(Turso) DB에 저장합니다. Vercel 서버리스 API(`/api/comments`)가
읽기/쓰기를 담당하고, 정적 사이트가 CORS로 호출합니다.

```sql
CREATE TABLE comment (
id INTEGER PRIMARY KEY AUTOINCREMENT,
memo_id TEXT NOT NULL,
author TEXT NOT NULL,
body TEXT NOT NULL,
status TEXT NOT NULL DEFAULT 'pending'
CHECK(status IN ('pending', 'approved', 'hidden', 'spam')),
ip_hash TEXT,
ctime DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
);
```

- 초기화: `node scripts/init-comments.mjs`
- 사전 승인 큐: 작성 시 `pending`으로 저장 → `approve` 해야 노출
- 모더레이션: `node scripts/moderate-comments.mjs pending|list|approve|hide|spam|delete`
- 환경변수: `.env.example` 참고 (`TURSO_DATABASE_URL`, `TURSO_AUTH_TOKEN`, `COMMENT_IP_SALT`)
- 스팸 방어: 허니팟 필드 + IP 레이트리밋(60초당 3개) + 사전 승인
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"@astrojs/sitemap": "^3.7.3",
"@astrojs/vercel": "^11.0.0",
"@formkit/tempo": "^0.0.16",
"@libsql/client": "^0.17.4",
"@shikijs/transformers": "^1.10.0",
"@tailwindcss/vite": "4.3.1",
"@testing-library/jest-dom": "latest",
Expand Down Expand Up @@ -59,7 +60,8 @@
"eslint-plugin-astro": "^1.2.3",
"eslint-plugin-jsx-a11y": "^6.9.0",
"fast-glob": "^3.3.2",
"husky": "^9.1.7"
"husky": "^9.1.7",
"vite": "8.1.0"
},
"packageManager": "pnpm@9.7.0",
"pnpm": {
Expand Down
Loading
Loading