Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Redis JavaScript API

Small Express API demonstrating Redis-backed banner storage and MongoDB connectivity checks.

Features

  • 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)

Tech Stack

  • Node.js (ES modules)
  • Express
  • ioredis
  • Mongoose
  • Docker Compose (Redis + MongoDB)

Project Structure

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

Documentation

Each topic has its own detailed guide with concepts, endpoints, and test commands:

Prerequisites

  • Node.js 18+
  • npm
  • Docker Desktop (or Docker Engine + Compose)

Setup

  1. Install dependencies:
npm install
  1. Start Redis and MongoDB:
docker compose up -d
  1. Run the API:
npm run dev

This uses nodemon, so the server auto-restarts when files change.

For normal runtime (without auto-reload):

npm start

Server runs at http://localhost:3000.

NPM Scripts

  • npm run dev: development mode with nodemon
  • npm start: run with Node.js (no file watching)
  • npm run worker: start the BullMQ worker (job consumer) as a separate process
  • npm run sub: start the Pub/Sub subscriber (listener) as a separate process

Environment Variables

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_redis

API Endpoints & Test Commands

See the per-topic guides in the Documentation section above - each includes full endpoint references and curl test commands.

Stop Local Services

docker compose down

About

Hands-on Node.js + Express playground exploring Redis patterns: strings, TTL/OTP, JSON vs Hash, list queues, and BullMQ background jobs.

Topics

Resources

Stars

Watchers

Forks

Contributors

Languages