Mirror of gitea.com/fargeiw/morning-digest
- HTML 50.3%
- JavaScript 49.7%
|
|
||
|---|---|---|
| api | ||
| lib | ||
| scripts | ||
| .env.example | ||
| .gitignore | ||
| index.html | ||
| middleware.js | ||
| package-lock.json | ||
| package.json | ||
| README.md | ||
| vercel.json | ||
morning-digest
A Vercel-hosted personal page that, each morning at 08:00 Asia/Tbilisi, shows every Telegram message you received overnight — grouped by chat, raw, no summarization. Open it from bed; skim what arrived while you slept.
Status: All build-plan steps shipped. Live page renders, cron is scheduled, manual Refresh works, per-sender colors + on-demand Thai→English translation are in.
- Live: https://morning-digest-woad.vercel.app (login:
admin/admin— rotate before any real data is rendered) - Vercel project:
yvg9phjqsb-7865s-projects/morning-digest - Gitea: https://gitea.com/fargeiw/morning-digest
Architecture
- Source: Telegram user API via
gramjs(telegramnpm package), authenticated as the user (not a bot) - Storage: Vercel Blob — one JSON file per date (
digests/YYYY-MM-DD.json) - Schedule: Vercel Cron,
0 4 * * *UTC = 08:00 Asia/Tbilisi - Display: Static
index.html+/api/today+/api/history, all behind HTTP Basic Auth viamiddleware.js - Color coding: each sender gets a deterministic color (hash of
senderId→ 12-color palette, dark/light-mode aware), applied to the sender name and a left border on each message - Translation: Thai messages get a per-message Translate link →
POST /api/translate→ Google Translate's free public endpoint (translate.googleapis.com/translate_a/single, no API key) → cached inlocalStoragebychatId:msgId. Other languages render verbatim.
Auth
middleware.js gates every path except /api/cron/* behind HTTP Basic Auth. Defaults to admin / admin; override via DIGEST_USERNAME / DIGEST_PASSWORD env vars on Vercel.
The cron endpoint stays open at the middleware layer but is gated inside the handler by a Bearer ${CRON_SECRET} check, so only Vercel's scheduler (or you with the secret) can trigger it.
Layout
api/
├── today.mjs GET — today's digest (or ?date=YYYY-MM-DD)
├── history.mjs GET — list of available dates
├── refresh.mjs POST — manual re-run of the digest job
├── translate.mjs POST — Thai→English via Google Translate free endpoint
└── cron/digest.mjs Cron: fetch last 24h, store JSON to Vercel Blob
scripts/
└── login.mjs Two-step non-interactive Telegram login
middleware.js Basic Auth gate
index.html Web UI
vercel.json Cron schedule + function config
Setup
npm install- Telegram API credentials at https://my.telegram.org → set
TELEGRAM_API_IDandTELEGRAM_API_HASHin.env.local npm run login -- request +<phone>→ triggers Telegram to send a login codenpm run login -- verify <code> [2fa-pass]→ completes sign-in, writesTELEGRAM_SESSIONto.env.localvercel link(already done) andvercel blob create-store morning-digest-blob --access private --yes- Push secrets to Vercel:
vercel env add <NAME> production --value <VAL> --yesfor each ofTELEGRAM_API_ID,TELEGRAM_API_HASH,TELEGRAM_SESSION,DIGEST_TIMEZONE,CRON_SECRET. (Translate uses Google's free endpoint — no API key needed.) - Deploy:
vercel --prod --yes
Build plan
- ✅ Scaffold + GitLab + Vercel link + first prod deploy
- ✅ Telegram login (non-interactive two-step CLI)
- ✅ Cron handler — fetches last 24h of DMs + groups, writes to Vercel Blob;
/api/today,/api/history,/api/refreshendpoints; collapsible chat UI, DMs sorted above groups - ✅ Basic Auth gate via
middleware.js - ✅ Env wiring (Telegram creds,
CRON_SECRET,DIGEST_TIMEZONE, Blob token all set in Vercel) - ✅ Per-sender colors + on-demand Thai→English translation (Google free endpoint, no API key)