The sequel for the AI era: ai-cheat — tested fixes for the problems developers (and their AI assistants) get stuck on, each one answering a real question.
Small, runnable Node.js examples for everyday tasks: cloud storage, payments, email/SMS, real-time chat, files, databases and more. They were first written in 2016–2018 and rewritten in 2026 for current Node.js and current library versions.
- Node.js 22+ (
.nvmrcpins 24), native ES modules,node:built-ins async/awaiteverywhere and built-infetch; no callbacks,request,qorasync.js- Current SDKs: AWS SDK v3, Stripe PaymentIntents, Express 5, socket.io 4, MongoDB 7, Mongoose 9, node-redis, twitter-api-v2, xero-node
- No credentials in code. Everything is read from environment variables (see
.env.example) - Input validated at the edges, no stack traces sent to clients, path-traversal and XSS guards where relevant
nvm use # Node 24
npm install
cp .env.example .env # fill in what your example needs
node --env-file=.env web/express/app.jsFolders with their own package.json (the chat and WebRTC apps, the Passport apps in auth/, web/express-generator-app, and a few in stackoverflow_answers/) are installed and run from inside that folder.
Each top-level folder is one category.
- S3 bucket CRUD · Upload base64 data to S3
- Stream uploads straight to S3 with multer-s3
- Lambda: merge images with sharp
- SQS polling worker · Start a Step Functions execution
payments/ — Stripe
- Email (SendGrid): send · reusable module · event webhook · subusers · raw v3 API
- SMS with Twilio · Fax with Telnyx
- Push notifications: FCM + APNs
- socket.io chat: one-to-one · simple room
- WebRTC video chat with socket.io signaling
- Express 5: routes & API · gzip compression · safe child processes · views · generator layout
- HTTPS with Node and with Express · Static hosting · Graceful shutdown
- Rate limiting · Restrict static files
- Read a file · Write a file · Read line by line · Read a directory
- Downloads: http · Express · Express & Koa static
- Write .xlsx · Unzip
- ffmpeg thumbnails · Serve a PDF
- Website screenshots · Headless scraping · Image size without a full download
- MongoDB: bulk update · GridFS streaming upload
- Redis: service wrapper · reconnect strategy
apis/ — third-party HTTP APIs
- Search X posts · Xero OAuth 2 · YouTube channel videos
- Google Sheets · Alfred workflow over a sheet
- Exchange rates · Gender by name · Expand short URLs · Parallel API calls
- HMAC signatures · Generate key pairs · Coupon codes
- Language detection · Transliteration · Durations
- Cron jobs · Dynamic imports · Local IP · List built-in modules · npm cleanup
- Essentials: events, streams, readline, timers, process
- Callbacks → async/await · Modern JS features · TypeScript with plain
node
Promises in loops · Error handling · finally · Deep copy a directory · AES-256-GCM encryption · Nested plugin loading · Streaming XML · Resample WAV to 8 kHz · and more
One-liners and tips collected over the years.
npm run lint # ESLint 10 with eslint-plugin-security
npm run format:check # Prettier
npm test # every example parses as ESM, uses no require(), and declares its importsCI runs all of these on Node 22 and 24, plus npm audit and CodeQL. Dependabot keeps dependencies current.
See SECURITY.md. These are teaching examples. Add authentication and review them before you deploy any of them.
ISC