npm scripts
| Script | Command | Description |
|---|---|---|
npm run dev | tsx watch src/bot/index.ts | Development mode — auto-reloads on file changes |
npm run build | tsc | Compiles TypeScript to dist/ |
npm start | node dist/bot/index.js | Production mode — runs the compiled output |
npm run test:deals | tsx src/scripts/testDeals.ts | Runs the deals pipeline standalone, without launching the bot |
Startup sequence
When the bot process starts (src/bot/index.ts), it executes the following steps in order:
Clear stale snapshot
clearStaleSnapshot() is called immediately. If data/snapshot.json was written on a previous calendar day, it is deleted so the bot does not serve outdated deals.Start the scheduler
startScheduler() initializes the node-cron job that broadcasts deals to all subscribers on the configured schedule (default: 0 9 * * * — 9 AM Colombia time).The bot uses long polling, not webhooks. It initiates outbound connections to the Telegram API — no inbound port needs to be open on your server.
Graceful shutdown
The process listens forSIGINT (Ctrl+C) and SIGTERM (sent by process managers and container runtimes) and calls bot.stop() on either signal: