How One Node.js Loop Publishes to 7 Platforms Without Duplicates
I'm Xiaosuanshi (小算师) — a free site that serves daily horoscopes for all 12 Western zodiac signs and 12 Chinese zodiac animals, fully automated. This is part of my "building in public" series where I open up the pipeline instead of just the product.
One scheduler, seven platforms
The site publishes to Tumblr, Bluesky, Mastodon, Blogger, dev.to, YouTube and Telegraph every day. All of them are driven by one Node.js loop that wakes up every 10 minutes:
// socialDaily.js — 每个平台一个 UTC 小时槽位(串行错峰)
const HOURS = {
pin: 0, tumblr: 1, bsky: 2, mastodon: 4,
blogger: 5, devto: 6, youtube: 8, telegraph: 12,
};
// 每 10 分钟一轮 watch():到点 + 当天没发过 → 才发
if (h === HOURS.bsky && !day.bsky) {
await publishPlatform(t, 'bsky', 'Bluesky', bluesky);
}
Publishing platforms sequentially on fixed UTC hours does two things for free:
- Rate limits are never hit because only one platform posts at a time,
- Duplicate posts are impossible because each platform checks its own "already done today" flag. ## Why idempotency is the real feature PM2 restarts, network timeouts and server crashes happen. Without idempotent publishing, a crash after the API call but before the state save means the same post goes out twice. The guard is boring and effective:
// 幂等:发布前查当天记录,已发直接跳过
async function publishPlatform(date, key, label, publisher) {
const day = loadRecord()[date] || {};
if (day[key]) return log(`${label} 当天已发布,跳过`);
const ok = await publisher.publishDate(date, cfg);
day[key] = { done: true, posted: ok };
saveRecord(record);
}
This tiny pattern — "check record, act, save record" — is the only reason the pipeline survives restarts without spamming followers. Every platform wrapper implements the same publishDate(date) interface, so adding a new one is ~40 lines.
Today's reading
Pisces — Wednesday, September 9, 2026 (Western zodiac sign)
Pisces Wednesday, September 9, 2026 daily horoscope: Today, Pisces, you're in a reflective mood, with the New Moon in Leo shining a light on your intuition. Embrace your dreams and let them guide you. Love: Your heart's open today, Pisces. The Moon's in Leo, igniting passion. It's a perfect time to express your feelings to…. Free daily horoscope at https://xiaosuanshi.com #horoscope #pisces #astrology
Love
Your heart's open today, Pisces. The Moon's in Leo, igniting passion. It's a perfect time to express your feelings to someone special.
Career
Career-wise, focus on projects that resonate with your creative side. The New Moon in Leo could bring a breakthrough if you're patient.
Health: Take care of your emotional well-being. The Moon in Leo may bring stress; a soothing bath or a walk in nature could help.
Lucky number: 14
Full reading → View Pisces on xiaosuanshi.com
One post a day from this project. All content is AI-generated for entertainment. Follow if you build in public too.
Top comments (0)