feat: migrate to Vercel + Upstash with KEY_PREFIX namespacing

Phases 1-5 of consolidate-vercel-upstash plan. Replaces Cloudflare
Workers + KV with Vercel serverless functions + Upstash Redis. Inlines
app-store-scraper / google-play-scraper npm libs (drops the
store-scraper.vercel.app HTTP roundtrip). KEY_PREFIX (default
'store-scraper-bot:') namespaces all Redis keys so the Upstash DB can
be safely shared with other Vercel projects.

- vercel.json + .vercelignore + Vercel-aware package.json scripts
- api/webhook.js + api/cron.js Vercel functions (with shared
  src/app-builder.js); cron auth fails closed when CRON_SECRET unset
- src/repository/upstash.js replaces kv.js; all 4 repos take a handle
  bundling client + prefix
- scripts/migrate-atlas-to-upstash.js writes legacy Java Atlas state
  directly to Upstash with --dry-run + --include-cache flags
- .env.example refreshed for the new env surface

Phases 6 (Vercel deploy + webhook cutover) and 7 (Docker + wrangler
cleanup) remain operator-driven post-deploy.
This commit is contained in:
tiennm99 committed 2026-05-09 20:07:07 +07:00
1 parent cf17071679
commit 73762fa0a0
33 files changed
+4011 -488

No files matched your search

+14 -11
View File
@@ -1,18 +1,21 @@
# Telegram Configuration
# Telegram
TELEGRAM_BOT_TOKEN=your_bot_token_here
TELEGRAM_BOT_USERNAME=your_bot_username
TELEGRAM_WEBHOOK_SECRET=generate_a_random_string_at_least_32_chars
# MongoDB Configuration (MONGODB_CONNECTION_STRING preferred; MONGO_URI fallback)
MONGODB_CONNECTION_STRING=mongodb://localhost:27017
MONGO_DATABASE=store_scraper_bot
MONGO_TIMEOUT_SECONDS=10
# Upstash Redis (REST API; same DB can be shared with other Vercel projects
# because KEY_PREFIX namespaces this bot's keys)
UPSTASH_REDIS_REST_URL=https://xxx.upstash.io
UPSTASH_REDIS_REST_TOKEN=your_upstash_rest_token
KEY_PREFIX=store-scraper-bot:
# Application Configuration
ENV=DEVELOPMENT
# Vercel Cron auth — protects /api/cron from random POSTs.
CRON_SECRET=generate_another_random_string_at_least_32_chars
# Bot config
ADMIN_IDS=123456789,987654321
SOURCE_COMMIT=unknown
# Optional overrides
APP_CACHE_SECONDS=600
NUM_DAYS_WARNING_NOT_UPDATED=30
SCHEDULE_CHECK_APP_TIME=0 7 * * *
# One-shot migration only (Phase 5: legacy Atlas → Upstash). Remove after migration done.
MONGODB_URI=mongodb+srv://user:pass@cluster.mongodb.net/dbname