Small Express API demonstrating Redis-backed banner storage and MongoDB connectivity checks.
- Manage a banner message in Redis
- Generate and verify OTPs with Redis TTL
- Store and fetch user profiles as Redis JSON string or Redis hash
- Check Redis connectivity
- Check MongoDB connectivity using Mongoose
- Local development with Docker Compose (Redis + MongoDB)
- Node.js (ES modules)
- Express
- ioredis
- Mongoose
- Docker Compose (Redis + MongoDB)
src/
index.js # app bootstrap and non-banner routes
banner.js # /banner router and handlers
otp-ttl.js # /otp router and handlers
jsonVsHash.js # /user router for JSON vs Hash storage
queue.js # /emails-queue router (Redis list queue)
bullMQ/ # BullMQ queue, producer router, and worker
queue.js # emails queue definition + Redis connection
api.js # /bullmq producer router
worker.js # background worker (job consumer)
pub-sub/ # Redis Pub/Sub notifications
api.js # /notifications publisher router
subscriber.js # channel subscriber (listener)
docs/ # per-topic documentation
docker-compose.yml
package.json
Each topic has its own detailed guide with concepts, endpoints, and test commands:
- Banner (Redis String)
- OTP with TTL (Redis Expiry)
- User Profile: JSON vs Hash
- Email Queue (Redis List)
- BullMQ Job Queue (Producer + Worker)
- Pub/Sub Notifications
- Health / Connectivity
- Node.js 18+
- npm
- Docker Desktop (or Docker Engine + Compose)
- Install dependencies:
npm install- Start Redis and MongoDB:
docker compose up -d- Run the API:
npm run devThis uses nodemon, so the server auto-restarts when files change.
For normal runtime (without auto-reload):
npm startServer runs at http://localhost:3000.
npm run dev: development mode with nodemonnpm start: run with Node.js (no file watching)npm run worker: start the BullMQ worker (job consumer) as a separate processnpm run sub: start the Pub/Sub subscriber (listener) as a separate process
Optional environment variables:
REDIS_URL(default:redis://localhost:6379)MONGO_URI(default:mongodb://localhost:27017/JS_redis)
Example:
REDIS_URL=redis://localhost:6379
MONGO_URI=mongodb://localhost:27017/JS_redisSee the per-topic guides in the Documentation section above - each includes full endpoint references and curl test commands.
docker compose down