feat: npm run setup (yt-dlp + deps + build); lift upload size limit

scripts/setup.mjs runs `npm install`, downloads the platform-specific
yt-dlp binary from GitHub releases to ./bin/yt-dlp (which src/youtube.ts
already prefers), checks for ffmpeg and prints install hints, then runs
`tsc`. One command replaces three for fresh checkouts.

While verifying setup, hit `MulterError: File too large` (LIMIT_FILE_SIZE)
on a 10 GB mkv upload, and ETXTBSY on freshly downloaded yt-dlp.

- ETXTBSY: the redirect path in downloadFile opened a writestream to the
  destination before following the redirect, so the (unused) outer stream
  still held the file open when the post-download spawnSync ran. Split
  redirect-following from file writing so only the final 200 response
  opens the destination file.
- LIMIT_FILE_SIZE: removed the hard-coded 4 GB cap. Upload limit now
  defaults to Infinity and is configurable via UPLOAD_MAX_BYTES.
  Wrapped multer's middleware so its errors (LIMIT_FILE_SIZE etc.) come
  back as a clean 413 JSON instead of a stack trace from the global
  error handler.
- Also disabled Node's default 5 minute requestTimeout so 10 GB uploads
  over slow links don't get cut mid-stream. Configurable via
  HTTP_REQUEST_TIMEOUT_MS.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-05-15 17:13:47 +09:00
parent bb116f5c24
commit cb9406d88e
6 changed files with 213 additions and 7 deletions

View File

@@ -3,20 +3,31 @@
## 실행
처음 한 번은 `setup` 으로 의존성 + yt-dlp 바이너리 + 빌드까지 한 번에 끝낼 수 있어요:
```bash
npm run setup # npm install + ./bin/yt-dlp 다운로드 + tsc
npm start # 기본 http://127.0.0.1:3000 (PORT=3000, HOST=127.0.0.1)
```
수동으로 단계별로 하고 싶다면:
```bash
npm install
npm run build
npm start # 기본 http://127.0.0.1:3000 (PORT=3000, HOST=127.0.0.1)
npm start
```
- 외부 노출이 필요하면 `HOST=0.0.0.0 npm start`
- 관리자 비밀번호는 `account.json``password` 값 (초기값 `admin`, 운영 시 반드시 변경)
- 세션 비밀은 `SESSION_SECRET` 환경변수로 덮어쓰기 권장
- 업로드 용량 한도: 기본 무제한. 제한하려면 `UPLOAD_MAX_BYTES=<바이트>` 설정
- 대용량 업로드용 HTTP 요청 타임아웃: 기본 무제한(0). 필요시 `HTTP_REQUEST_TIMEOUT_MS=<밀리초>`
## 외부 의존
- `yt-dlp` — YouTube 영상 가져오기 (`PATH` 또는 `./bin/yt-dlp` 에 설치)
- `ffmpeg` — 영상 트림 저장 (`PATH` 에 설치). 없으면 trim 설정만 저장됩니다.
- `yt-dlp` — YouTube 영상 가져오기. `npm run setup` `./bin/yt-dlp` 로 자동 설치하지만 PATH 에 이미 있어도 됩니다.
- `ffmpeg` — 영상 트림 저장 (`PATH` 에 설치). 없으면 trim 설정만 저장됩니다. `npm run setup` 이 설치 여부를 검사해 안내 메시지를 출력합니다.
## 데이터 위치